kumuluz / kumuluzee

Lightweight open-source framework for developing microservices using standard Java EE technologies and migrating Java EE to cloud-native architecture.
https://ee.kumuluz.com
MIT License
291 stars 71 forks source link

kumuluzee:run class path issue #220

Open kpihlblad opened 1 year ago

kpihlblad commented 1 year ago

I can't get kumuluzee:run to work with the jax-rs example, or in my application that uses jax-rs using the microprofile-1.0 dependency.

kumuluzee:run

$ cd kumuluzee-samples/jax-rs
$ mvn kumuluzee:run

Gives this log:

...
com.kumuluz.ee.EeApplication -- KumuluzEE running in an exploded class and dependency runtime.
...
org.eclipse.jetty.server.Server -- jetty-10.0.9; built: 2022-03-30T16:46:32.527Z; git: a9eaf8d5d73369acf610ce88f850c0d56c4b1113; jvm 17.0.5+8-Ubuntu-2ubuntu122.04
org.eclipse.jetty.webapp.StandardDescriptorProcessor -- NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
org.eclipse.jetty.server.session.DefaultSessionIdManager -- Session workerName=node0
org.eclipse.jetty.server.handler.ContextHandler -- Started o.e.j.w.WebAppContext@5641e957{/,file:///home/kalle/seb/kumuluzee-samples/jax-rs/target/classes/webapp/,AVAILABLE}
org.eclipse.jetty.server.AbstractConnector -- Started ServerConnector@28d9b4ba{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
org.eclipse.jetty.server.Server -- Started Server@2e8d6594{STARTING}[10.0.9,sto=0] @1335ms
com.kumuluz.ee.EeApplication -- KumuluzEE started successfully

Outcome:

curl http://localhost:8080/v1/customers
HTTP ERROR 404 Not Found
URI: /v1/customers
404 Not Found
default 

java -jar target/my.jar

Running the jar instead works fine and gives an empty array as the expected result.

(Using repackage as the goal for the build plugin.)

$ mvn clean package
$ java -jar target/jax-rs-3.13.0-SNAPSHOT.jar

Logs:

...
com.kumuluz.ee.EeApplication -- KumuluzEE running inside a JAR runtime.
....
org.eclipse.jetty.server.Server -- jetty-10.0.9; built: 2022-03-30T16:46:32.527Z; git: a9eaf8d5d73369acf610ce88f850c0d56c4b1113; jvm 17.0.5+8-Ubuntu-2ubuntu122.04
org.eclipse.jetty.webapp.StandardDescriptorProcessor -- NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
org.eclipse.jetty.server.session.DefaultSessionIdManager -- Session workerName=node0
org.glassfish.jersey.server.wadl.WadlFeature -- JAXBContext implementation could not be found. WADL feature is disabled.
org.eclipse.jetty.server.handler.ContextHandler -- Started o.e.j.w.WebAppContext@7494f96a{/,jar:file:/home/kalle/seb/kumuluzee-samples/jax-rs/target/jax-rs-3.13.0-SNAPSHOT.jar!/webapp,AVAILABLE}
org.eclipse.jetty.server.AbstractConnector -- Started ServerConnector@2e3fc542{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
org.eclipse.jetty.server.Server -- Started Server@233fe9b6{STARTING}[10.0.9,sto=0] @635ms
com.kumuluz.ee.EeApplication -- KumuluzEE started successfully

Testing with curl

$ curl http://localhost:8080/v1/customers
[]

java -cp /target/classes:target/dependency

Changing to copy-dependencies in the pom.xml, also works fine.

$ mvn clean package
$ java -cp target/classes:target/dependency/* com.kumuluz.ee.EeApplication

Logs:

...
org.glassfish.jersey.server.wadl.WadlFeature -- JAXBContext implementation could not be found. WADL feature is disabled.
org.eclipse.jetty.server.handler.ContextHandler -- Started o.e.j.w.WebAppContext@c86b9e3{/,file:///home/kalle/seb/kumuluzee-samples/jax-rs/target/classes/webapp/,AVAILABLE}
org.eclipse.jetty.server.AbstractConnector -- Started ServerConnector@51c8530f{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
org.eclipse.jetty.server.Server -- Started Server@2133814f{STARTING}[10.0.9,sto=0] @612ms
com.kumuluz.ee.EeApplication -- KumuluzEE started successfully

Testing with curl

$ curl http://localhost:8080/v1/customers
[]

Additional info

In my project i use kumuluzee-streaming-kafka and the @StreamProcessor in it autostarts just fine, it's just the rest endpoint that is not starting.

The log output between kumuluz:run and the exploded java variant is identical except this line in the working variant:

org.glassfish.jersey.server.wadl.WadlFeature -- JAXBContext implementation could not be found. WADL feature is disabled.
[DEBUG]   (f) mainClass = com.kumuluz.ee.EeApplication
[DEBUG]   (f) arguments = [-classpath, target/classes:target/dependency/*]

It seems to me as it matches the command-line variant.

java -cp target/classes:target/dependency/* com.kumuluz.ee.EeApplication

I don't get any further than that. I must admit that I don't understand what the exec-maven-plugin is doing, and I couldn't figure out what the actual classpath actually is. There is some sort of Plexus Classworlds Launcher that's a bit opaque.

kpihlblad commented 1 year ago

Added a pull request. I think there is a conflict between the Plexus Launcher and the Kumuluz Launcher. https://github.com/kumuluz/kumuluzee/pull/221