javaee-samples / javaee8-samples

Java EE 8 Samples
Other
376 stars 238 forks source link

SseResourceTest fails with payara-embedded profile #23

Closed dmatej closed 6 years ago

dmatej commented 6 years ago

This test fails with embedded Payara 5.181, 5.182 even 5.183-SNAPSHOT (built 28.7.2018). (5.181 hangs, newer fails). (payara-remote with 5.183-SNAPSHOT was successful)

INFO: Loading application [a201427e-35b6-49a1-a02e-a55d7893e99c] at [/a201427e-35b6-49a1-a02e-a55d7893e99c]
Čvc 29, 2018 9:01:37 ODP. com.hazelcast.internal.partition.impl.PartitionStateManager
INFO: [192.168.1.190]:4900 [development] [3.10.2] Initializing cluster partition table arrangement...
Čvc 29, 2018 9:01:37 ODP. org.glassfish.deployment.admin.DeployCommand execute
INFO: a201427e-35b6-49a1-a02e-a55d7893e99c was successfully deployed in 4 938 milliseconds.
Čvc 29, 2018 9:01:38 ODP. com.sun.enterprise.admin.cli.embeddable.DeployerImpl undeploy
INFO: a201427e-35b6-49a1-a02e-a55d7893e99c was successfully undeployed
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 17.386 s <<< FAILURE! - in org.javaee8.jaxrs.sseproducer.SseResourceTest
[ERROR] testSSE(org.javaee8.jaxrs.sseproducer.SseResourceTest)  Time elapsed: 0.118 s  <<< ERROR!
java.lang.IllegalArgumentException: Argument fish.payara.requesttracing.jaxrs.client.decorators.JaxrsWebTargetDecorator@62c02089 is not a valid JerseyWebTarget instance. SseEventSource does not support other WebTarget implementations.
        at org.javaee8.jaxrs.sseproducer.SseResourceTest.setup(SseResourceTest.java:58)

Čvc 29, 2018 9:01:38 ODP. org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread shutdown

I'm not sure yet if it is Payara error or test error.

dmatej commented 6 years ago

Failed also with glassfish-embedded. Is this test successful with any other profile? Also I noticed that jaxrs folder is not run on Travis ...

WARNING: The following warnings have been detected: HINT: A HTTP GET method, public void org.javaee8.jaxrs.sseproducer.producer.SseResource.register(javax.ws.rs.sse.SseEventSink), returns a void type. It can be intentional and perfectly fine, but it is a little uncommon that GET method returns always "204 No Content".

Čvc 29, 2018 9:15:34 ODP. com.sun.enterprise.web.WebApplication start
INFO: Loading application [000fcc0c-9628-4bc5-b94d-79df2b930261] at [/000fcc0c-9628-4bc5-b94d-79df2b930261]
Čvc 29, 2018 9:15:35 ODP. org.glassfish.deployment.admin.DeployCommand execute
INFO: 000fcc0c-9628-4bc5-b94d-79df2b930261 was successfully deployed in 2 830 milliseconds.
PlainTextActionReporterSUCCESSNo monitoring data to report.
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 7.412 s <<< FAILURE! - in org.javaee8.jaxrs.sseproducer.SseResourceTest
[ERROR] testSSE(org.javaee8.jaxrs.sseproducer.SseResourceTest)  Time elapsed: 0.094 s  <<< ERROR!
java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.media.sse.internal.JerseySseEventSource$Builder
        at org.javaee8.jaxrs.sseproducer.SseResourceTest.setup(SseResourceTest.java:58)
Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.media.sse.internal.JerseySseEventSource$Builder
        at org.javaee8.jaxrs.sseproducer.SseResourceTest.setup(SseResourceTest.java:58)

Čvc 29, 2018 9:15:35 ODP. org.glassfish.admin.mbeanserver.JMXStartupService shutdown
INFO: JMXStartupService and JMXConnectors have been shut down.
dmatej commented 6 years ago

Also I noticed that jaxrs folder is not run on Travis ... And last point - I looked on the test sources and I dislike the quality of the test. Does sombody here any code review or any garbage is accepted?:

  1. Undocumented Thread.sleep
  2. Undocumented anything except who is the author.
  3. Undocumented for cycle 1 to 5 (the purpose?)
  4. Unused jsonb instance (why?)
  5. Why are Jsonb and Jsonbuilder classes added to the war file?
  6. try - catch Exception in the unit test ... wtf?
  7. Test fails.

Sorry that I'm a little bit angry, I would like to help but I'm not even sure with the meaning of this test.

arjantijms commented 6 years ago

Hi, I agree that test was not of the best quality.

With projects such as this there are not that many contributions, and you don't want to put of new/junior devs too much. I already went once through this test to update some of naming, as that was initially not quite correct as well.

If my memory serves me correctly this test was successful with at least Payara Server.

GlassFish/Payara embedded have always been slightly difficult to get running perfectly. I've seen some issues with them with other tests as well.

The overal purpose of the test should be to show a sample/test the SSE feature of JAX-RS 2.1, see https://blogs.oracle.com/pavelbucek/jax-rs-21-server-sent-events

As for 4/5, and mentioned this was a somewhat inexperienced Java developer. If time allowed I'll go through the test. Perhaps I should indeed not have accepted it in this state, but what has been done has been done.

Thanks for your report!

dmatej commented 6 years ago

I use both embedded Payara and micro Payara without any problems for years, resp. the only problem is to avoid "dependency hell" (classpath conflicts). Give me some time, I will try to prepare some pull request ;-) My original intention was to add some other examples but I could not pass even the current repo state.

dmatej commented 6 years ago

I got it - as I expected, the problem is with the classpath of embedded payara. The remote version has it's own JVM, and even uses endorsed directories mechanism to block overriding implementations of some components (I think it is unsupported from JDK9). But the embedded/micro/... distributions are started in the same JVM and then it's little bit harder to separate server and client implementations and their "global" configurations (service locators, order of dependencies on classpath, registered extensions, etc.). I will create a pull request (and check another profiles).