OpenLiberty / liberty-arquillian

Arquillian Liberty Managed and Remote containers
Apache License 2.0
10 stars 29 forks source link

Is Java EE 8 supported? #62

Open Legion2 opened 4 years ago

Legion2 commented 4 years ago
Issue Overview

I try to use the liberty-managed container for running test. I'm using liberty features like jsonb-1.0 and cdi-2.0 that are not compatible with the configuration of the liberty-managed test container.

Unable to load conflicting versions of features "com.ibm.websphere.appserver.javaeeCompatible-6.0" and "com.ibm.websphere.appserver.javaeeCompatible-8.0".  The feature dependency chains that led to the conflict are: com.ibm.websphere.appserver.jsp-2.2 -> com.ibm.websphere.appserver.javaeeCompatible-6.0 and com.ibm.websphere.appserver.jsonb-1.0 -> com.ibm.websphere.appserver.jsonbInternal-1.0 -> com.ibm.websphere.appserver.jsonbImpl-1.0.1 -> com.ibm.websphere.appserver.jsonp-1.1 -> com.ibm.websphere.appserver.jsonpInternal-1.1 -> com.ibm.websphere.appserver.jsonpImpl-1.1.1 -> com.ibm.websphere.appserver.javaeeCompatible-8.0
Expected Behaviour

I can use liberty-managed container to run tests for my Java EE 8 application.

Current Behaviour

Dependency conflict, can't run the tests.

Steps To Reproduce
  1. add jsonb-1.0 to the server.xml features
  2. add the features for the test container
    <!-- Enable features -->
    <featureManager>
    <feature>jsp-2.2</feature>
    <feature>localConnector-1.0</feature>
    <feature>j2eeManagement-1.1</feature> <!-- Optional, needed to allow injection on ArquillianResources related to servlets -->
    <feature>usr:arquillian-support-1.0</feature> <!-- Optional, needed for reliable reporting of correct DeploymentExceptions -->
    </featureManager>
  3. run an arquillian test
Additional Information

Java EE 8 uses servlet-4.0 and this is not supported by arquillian.

cherylking commented 4 years ago

@Legion2 Can you try using feature jsp-2.3 instead of jsp-2.2? That is the correct feature to use with Java EE 8 features such as servlet-4.0, and jsonb-1.0. Note that we have not tested the liberty-managed container with Java EE 8 as of yet. So changes may in fact be needed.

Legion2 commented 4 years ago

When I use jsp-2.3 I don't get the dependency conflict but the tests are not executed. Only the @BeforeClass is executed and all @Test are not executed. The test execution passes with Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 65.428 s but there should be some tests executed.

chyt commented 4 years ago

If the tests were running when you were using jsp-2.2 and the only thing you change is to upgrade that feature to jsp-2.3, then it should have no effect on whether the tests run or not. Open Liberty or the Liberty Arquillian container does not decide which tests will be run.

I've re-run our admittedly primitive Arquillian tests from our Liberty Maven Plugin build against io.openliberty:openliberty-runtime:20.0.0.1 using jsp-2.3 and cdi-2.0 (upgraded from servlet-3.1 and cdi-1.2) and the tests ran and passed. Where did you see that "Java EE 8 uses servlet-4.0 and this is not supported by arquillian."? Because it seems to work fine for me.

It's interesting that @BeforeClass is running but @Test is not. If you are still having problems, can you share a project or instructions to replicate this issue so I can investigate further?

Legion2 commented 4 years ago

The tests never run with jsp-2.2 it's a new project started with Java EE 8 features (Eclipse Micro Profile). And I don't use jsp I only add it because liberty-arquillian requires it. This is some log output when running a test.

<featureManager>
    <feature>websocket-1.1</feature>
    <feature>jsonb-1.0</feature>
    <!-- <feature>cdi-2.0</feature> -->
    <feature>mpConfig-1.3</feature>
    <feature>mpMetrics-2.0</feature>
    <feature>mpHealth-2.0</feature>
    <feature>concurrent-1.0</feature>
    <!-- <feature>mpReactiveMessaging-1.0</feature> -->
    <feature>mpRestClient-1.3</feature>
    <!-- Enable the following features to run tests with Arquillian managed container -->
    <feature>jsp-2.3</feature>
    <feature>localConnector-1.0</feature>
    <feature>j2eeManagement-1.1</feature> 
    <feature>usr:arquillian-support-1.0</feature>
</featureManager>
[INFO] --- maven-failsafe-plugin:3.0.0-M4:integration-test (default) @ websocket-api-impl ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running de.uni_stuttgart.tik.viplab.websocket_api.ComputationWebSocketIntegrationTest
Picked up JAVA_TOOL_OPTIONS: -Dcom.ibm.ws.logging.console.log.level=INFO 
Launching ArquillianManagedServer (Open Liberty 20.0.0.2/wlp-1.0.37.cl200220200121-0810) on Java HotSpot(TM) 64-Bit Server VM, version 13.0.2+8 (en_DE)
[AUDIT   ] CWWKE0001I: The server ArquillianManagedServer has been launched.
[AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: C:\Users\Leon\git\TIK\vip\websocket-api\websocket-api-impl\target\liberty\wlp\usr\servers\ArquillianManagedServer\configDropins\overrides\server.xml
[INFO    ] TRAS0018I: The trace state has been changed. The new trace state is *=info:de.uni_stuttgart.*=all.
[INFO    ] CWWKE0002I: The kernel started after 4,563 seconds
[INFO    ] CWWKF0007I: Feature update started.
[INFO    ] Aries Blueprint packages not available. So namespaces will not be registered
[INFO    ] Aries Blueprint packages not available. So namespaces will not be registered
[INFO    ] CWWKS0007I: The security service is starting...
[INFO    ] OSGi Work Path [ C:\Users\Leon\git\TIK\vip\websocket-api\websocket-api-impl\target\liberty\wlp\usr\servers\ArquillianManagedServer\workarea\org.eclipse.osgi\42\data ]
[AUDIT   ] CWWKZ0058I: Monitoring dropins for applications.
[INFO    ] DYNA1001I: WebSphere Dynamic Cache instance named baseCache initialized successfully.
[INFO    ] DYNA1071I: The cache provider default is being used.
[INFO    ] DYNA1056I: Dynamic Cache (object cache) initialized successfully.
[AUDIT   ] CWPKI0820A: The default keystore has been created using the 'keystore_password' environment variable.
[INFO    ] CWWKS1123I: The collective authentication plugin with class name NullCollectiveAuthenticationPlugin has been activated. 
[INFO    ] CWWKS4105I: LTPA configuration is ready after 0,235 seconds.
[INFO    ] Successfully loaded default keystore: C:/Users/Leon/git/TIK/vip/websocket-api/websocket-api-impl/target/liberty/wlp/usr/servers/ArquillianManagedServer/resources/security/key.p12 of type: PKCS12
[INFO    ] SESN8501I: The session manager did not find a persistent storage location; HttpSession objects will be stored in the local application server's memory.
[INFO    ] CWWKO0219I: TCP Channel defaultHttpEndpoint has been started and is now listening for requests on host kubernetes.docker.internal  (IPv4: 127.0.0.1) port 8081.
[AUDIT   ] CWWKF0012I: The server installed the following features: [cdi-2.0, concurrent-1.0, distributedMap-1.0, el-3.0, j2eeManagement-1.1, jaxrsClient-2.1, jndi-1.0, json-1.0, jsonb-1.0, jsonp-1.1, jsp-2.3, localConnector-1.0, mpConfig-1.3, mpHealth-2.0, mpMetrics-2.0, mpRestClient-1.3, servlet-4.0, ssl-1.0, usr:arquillian-support-1.0, websocket-1.1].
[INFO    ] CWWKF0008I: Feature update completed in 5,871 seconds.
[AUDIT   ] CWWKF0011I: The ArquillianManagedServer server is ready to run a smarter planet. The ArquillianManagedServer server started in 10,454 
seconds.
[INFO    ] Requested jdkSourceLevel=17, but forcing to 17 because it is the min supported by Java 12+
[INFO    ] Requested jdkSourceLevel=17, but forcing to 17 because it is the min supported by Java 12+
[INFO    ] Requested jdkSourceLevel=17, but forcing to 17 because it is the min supported by Java 12+
[INFO    ] Requested jdkSourceLevel=17, but forcing to 17 because it is the min supported by Java 12+
[INFO    ] SRVE0169I: Loading Web Module: health.
[INFO    ] SRVE0169I: Loading Web Module: PublicMicroProfileMetrics.
[INFO    ] SRVE0250I: Web Module health has been bound to default_host.
[INFO    ] SRVE0169I: Loading Web Module: arquillian-liberty-support.
[INFO    ] SRVE0250I: Web Module arquillian-liberty-support has been bound to default_host.
[INFO    ] SRVE0250I: Web Module PublicMicroProfileMetrics has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:8081/health/
[INFO    ] SRVE0169I: Loading Web Module: ibm/api.
[INFO    ] SRVE0250I: Web Module ibm/api has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:8081/ibm/api/
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:8081/arquillian-support/
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:8081/metrics/
[INFO    ] SRVE9103I: A configuration file for a web server plugin was automatically generated for this server at C:\Users\Leon\git\TIK\vip\websocket-api\websocket-api-impl\target\liberty\wlp\usr\servers\ArquillianManagedServer\logs\state\plugin-cfg.xml.
[INFO    ] SESN0176I: A new session context will be created for application key default_host/health
[INFO    ] SESN0176I: A new session context will be created for application key default_host/ibm/api
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] SESN0176I: A new session context will be created for application key default_host/metrics
[INFO    ] SESN0176I: A new session context will be created for application key default_host/arquillian-support
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[INFO    ] DYNA1056I: Dynamic Cache (object cache) initialized successfully.
[INFO    ] SRVE0242I: [com.ibm.ws.microprofile.health.2.0] [/health] [HealthCheckReadinessServlet]: Initialization successful.
[INFO    ] SRVE0242I: [com.ibm.ws.microprofile.health.2.0] [/health] [HealthCheckServlet]: Initialization successful.
[INFO    ] SRVE0242I: [com.ibm.ws.microprofile.health.2.0] [/health] [HealthCheckLivenessServlet]: Initialization successful.
[INFO    ] SRVE0242I: [com.ibm.ws.microprofile.metrics.public] [/metrics] [PublicMetricsRESTProxyServlet]: Initialization successful.
Jan. 28, 2020 1:07:47 PM org.jboss.shrinkwrap.resolver.impl.maven.logging.LogTransferListener transferFailed
WARNING: Failed downloading org/jboss/spec/javax/servlet/jboss-servlet-api_3.0_spec/maven-metadata.xml from https://jitpack.io/. Reason:
org.eclipse.aether.transfer.MetadataNotFoundException: Could not find metadata org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec/maven-metadata.xml in jitpack.io (https://jitpack.io)
Jan. 28, 2020 1:07:47 PM org.jboss.shrinkwrap.resolver.impl.maven.logging.LogTransferListener transferFailed
WARNING: Failed downloading org/jboss/spec/javax/servlet/jboss-servlet-api_3.0_spec/maven-metadata.xml from https://oss.sonatype.org/content/repositories/snapshots/. Reason:
org.eclipse.aether.transfer.MetadataNotFoundException: Could not find metadata org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec/maven-metadata.xml in oss-sonatype (https://oss.sonatype.org/content/repositories/snapshots/)
[INFO    ] CWWKZ0018I: Starting application test-websocket-api.
[INFO    ] CWWKZ0136I: The test-websocket-api application is using the archive file at the C:\Users\Leon\git\TIK\vip\websocket-api\websocket-api-impl\target\liberty\wlp\usr\servers\ArquillianManagedServer\dropins\test-websocket-api.war location.
[INFO    ] Requested jdkSourceLevel=17, but forcing to 17 because it is the min supported by Java 12+
[INFO    ] WELD-000900: 3.1.1 (Final)
[INFO    ] Analyzing mediator bean: Managed Bean [class de.uni_stuttgart.tik.viplab.websocket_api.ecs.ECSComputationService] with qualifiers [@Any @Default]
[INFO    ] Scanning Type: class de.uni_stuttgart.tik.viplab.websocket_api.ecs.ECSComputationService
[INFO    ] Deployment done... start processing
[INFO    ] Found incoming connectors: [ecs, smallrye-in-memory]
[INFO    ] Found outgoing connectors: [ecs, smallrye-in-memory]
[INFO    ] Stream manager initializing...
[INFO    ] Initializing mediators
[INFO    ] Connecting mediators
[INFO    ] Attempt to resolve de.uni_stuttgart.tik.viplab.websocket_api.ecs.ECSComputationService#processResults
[INFO    ] Connecting de.uni_stuttgart.tik.viplab.websocket_api.ecs.ECSComputationService#processResults to `[results]` (org.eclipse.microprofile.reactive.streams.operators.core.PublisherBuilderImpl@6de10182)
[INFO    ] Connecting emitter to sink solutions
[INFO    ] SRVE0169I: Loading Web Module: test-websocket-api.
[INFO    ] SRVE0250I: Web Module test-websocket-api has been bound to default_host.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:8081/test-websocket-api/
[INFO    ] SESN0176I: A new session context will be created for application key default_host/test-websocket-api
[INFO    ] SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[AUDIT   ] CWWKZ0001I: Application test-websocket-api started in 25,571 seconds.
kldsjfjlms,cfsklcfskjfksdjflksd
[INFO    ] FFDC1015I: An FFDC Incident has been created: "java.nio.file.NoSuchFileException: C:\Users\Leon\git\TIK\vip\websocket-api\websocket-api-impl\target\liberty\wlp\usr\servers\ArquillianManagedServer\dropins\test-websocket-api.war com.ibm.ws.artifact.zip.internal.ZipFileContainerFactory 370" at ffdc_20.01.28_13.08.18.0.log
[WARNING ] jsp error failed to load tld in jar. uri = [/WEB-INF/lib/smallrye-reactive-messaging-provider-05c4db2e1f.jar]
java.lang.NullPointerException
[WARNING ] jsp error failed to load tld in jar. uri = [/WEB-INF/lib/smallrye-reactive-streams-operators-1.0.10.jar]
java.lang.NullPointerException
[WARNING ] jsp error failed to load tld in jar. uri = [/WEB-INF/lib/wagon-file-2.6.jar]
java.lang.NullPointerException
[WARNING ] jsp error failed to load tld in jar. uri = [/WEB-INF/lib/wagon-http-lightweight-2.6.jar]
java.lang.NullPointerException
[WARNING ] jsp error failed to load tld in jar. uri = [/WEB-INF/lib/wagon-http-shared-2.6.jar]
java.lang.NullPointerException
[WARNING ] jsp error failed to load tld in jar. uri = [/WEB-INF/lib/wagon-provider-api-2.6.jar]
java.lang.NullPointerException
[WARNING ] jsp error failed to load tld in jar. uri = [/WEB-INF/lib/yasson-1.0.6.jar]
java.lang.NullPointerException
[INFO    ] SRVE9103I: A configuration file for a web server plugin was automatically generated for this server at C:\Users\Leon\git\TIK\vip\websocket-api\websocket-api-impl\target\liberty\wlp\usr\servers\ArquillianManagedServer\logs\state\plugin-cfg.xml.
[INFO    ] CWWKH0046I: Adding a WebSocket ServerEndpoint with the following URI: /computations
[AUDIT   ] CWWKT0017I: Web application removed (default_host): http://localhost:8081/test-websocket-api/
[INFO    ] Cancel subscriptions
[AUDIT   ] CWWKZ0009I: The application test-websocket-api has stopped successfully.
[INFO    ] SRVE9103I: A configuration file for a web server plugin was automatically generated for this server at C:\Users\Leon\git\TIK\vip\websocket-api\websocket-api-impl\target\liberty\wlp\usr\servers\ArquillianManagedServer\logs\state\plugin-cfg.xml.
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 49.898 s - in de.uni_stuttgart.tik.viplab.websocket_api.ComputationWebSocketIntegrationTest
Server ArquillianManagedServer wird gestoppt.
[AUDIT   ] CWWKE0055I: Server shutdown requested on Tuesday, 28 January 2020 at 13:08. The server ArquillianManagedServer is shutting down.
[AUDIT   ] CWWKE1100I: Waiting for up to 30 seconds for the server to quiesce.
[INFO    ] CWWKO0220I: TCP Channel defaultHttpEndpoint has stopped listening for requests on host kubernetes.docker.internal  (IPv4: 127.0.0.1) port 8081.
[AUDIT   ] CWWKT0017I: Web application removed (default_host): http://localhost:8081/health/
[AUDIT   ] CWWKT0017I: Web application removed (default_host): http://localhost:8081/metrics/
[AUDIT   ] CWWKT0017I: Web application removed (default_host): http://localhost:8081/ibm/api/
[AUDIT   ] CWWKT0017I: Web application removed (default_host): http://localhost:8081/arquillian-support/
[INFO    ] CWWKE1101I: Server quiesce complete.
[INFO    ] SRVE0253I: [com.ibm.ws.microprofile.metrics.public] [/metrics] [PublicMetricsRESTProxyServlet]: Destroy successful.
[INFO    ] SRVE0253I: [com.ibm.ws.microprofile.health.2.0] [/health] [HealthCheckReadinessServlet]: Destroy successful.
[INFO    ] SRVE0253I: [com.ibm.ws.microprofile.health.2.0] [/health] [HealthCheckLivenessServlet]: Destroy successful.
[INFO    ] SRVE0253I: [com.ibm.ws.microprofile.health.2.0] [/health] [HealthCheckServlet]: Destroy successful.
[INFO    ] CWWKS1124I: The collective authentication plugin with class name NullCollectiveAuthenticationPlugin has been deactivated.
[INFO    ] CWWKS0009I: The security service has stopped.
[AUDIT   ] CWWKE0036I: The server ArquillianManagedServer stopped after 50,598 seconds.
Der Server ArquillianManagedServer wurde gestoppt.
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]

The kldsjfjlms,cfsklcfskjfksdjflksd is printed in the the BeforeClass:

@BeforeClass
public static void setup() {
    System.out.println("kldsjfjlms,cfsklcfskjfksdjflksd");
}

I also have timing issues. If I run the tests multiple times (mvn install) I get different log output and sometimes FileNotFoundExections for the war file created by ShrinkWrap deployment. Seems like the file is deleted before the tests started/finished.

The arquillian-protocol-servlet artifact uses the jboss-servlet-api_3.0_spec artifact so only servlet-3.0. Also jboss-servlet-api_3.0_spec has been moved and does not work anymore resulting in warning in the logs:

Jan. 28, 2020 10:27:37 AM org.jboss.shrinkwrap.resolver.impl.maven.logging.LogTransferListener transferFailed
WARNING: Failed downloading org/jboss/spec/javax/servlet/jboss-servlet-api_3.0_spec/maven-metadata.xml from https://oss.sonatype.org/content/repositories/snapshots/. Reason: 
org.eclipse.aether.transfer.MetadataNotFoundException: Could not find metadata org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec/maven-metadata.xml in oss-sonatype (https://oss.sonatype.org/content/repositories/snapshots/)

I don't know why it tries to get it from the oss-sonatype snapshot repo.

Maybe these are all irrelevant findings, but I try to get it working for a while now and I only have the logs and google.

Some questions:

  1. how are the tests executed in the managed container?
  2. how are the results of the tests reported back to the jvm that started the managed container?
  3. how is the test engine (Junit) detected? I use Junit 5 with the junit-vintage-engine to support the junit 4 Arquillian tests
chyt commented 4 years ago

You should not require the jsp-2.3 feature - this needs to be updated in our documentation. Arquillian requires a servlet implementation, and I was able to get it working just by adding servlet-4.0. I'm not familiar with the arquillian-protocol-servlet artifact or how it is used within the Arquillian lifecycle.

If your question is just whether Java EE 8 is supported, based on my testing it seems like the answer is yes. It is difficult to say based on the other issues you described whether or not they are relevant to the this project - specifically the Arquillian Liberty Managed container implementation. Again, I would suggest providing a sample project so that I can replicate and investigate these issues.

Legion2 commented 4 years ago

We now open sourced the project, so I can share the code with you. This is the Integration Test that don't work.

To overcome all the issues we moved from openliberty to quarkus. But maybe the old version helps you to understand the issue.

hantsy commented 1 year ago

Check my Jakarta EE 8 template project. https://github.com/hantsy/jakartaee8-starter-boilerplate