Reputation: 51
I have a Java11 app on Google App Engine and it uses the Jetty "bundled service" with Jersey as the REST server.
There were warnings on the Google cloud console to move from Java1 to Java17 before 31Oct2024.
So I changed my code from Java11 to Java17 and deployed the app. The console warnings went away. So far, so good.
However, my app still uses the Jetty "bundled service" with Jersey as the REST server. But what if I want to launch a Java application and from that Java application, start a Jetty server and while starting that Jetty instance, specify "jersey.config.server.provider.packages"?
In other words, I would like to move away from the "bundled service" insofar as Jetty in concerned.
I tried several combinations of Jetty and Jersey versions and finally these entries in the pom worked, as is, the Java application started and it, in turn, started the Jetty server on port 8080.
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.2.3.v20140905</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.2.3.v20140905</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.2.3.v20140905</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.2.3.v20140905</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.35</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.35</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.35</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.35</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.35</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.27</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-http</artifactId>
<version>2.35</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.35</version>
</dependency>
This is the code in the public static void main method....
srvtCtxtHdlr = new ServletContextHandler(ServletContextHandler.SESSIONS);
srvtCtxtHdlr.setContextPath("/");
wappCtxt = new WebAppContext();
wappCtxt.setContextPath("/");
wappCtxt.setWar(args[0]);
jttySrvr = new Server(8080);
jttySrvr.setHandler(wappCtxt);
try {
jttySrvr.start();
jttySrvr.join();
}
catch(Exception e) {
logger.severe("Exception caught: " + e.getMessage());
e.printStackTrace();
}
The problem is, when I navigate to http://localhost:8080
, I get a 503. The server log says...:
java.lang.IllegalArgumentException: org.glassfish.hk2.api.ProxyCtl referenced from a method is not visible from class loader: org.jvnet.hk2.internal.DelegatingClassLoader
java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.myCompany.myProd.serverApp.fltr.ResponseFilter errors were found
Any suggestion on where I could be going wrong?
Also note the following (can be found at list of sample code from GAE)
This list contains "appengine-java11 bundled service", "appengine-java11" and "appengine-java17 bundled service". But it does not contains "appengine-java17".
The node "appengine-java11" describes how to launch a Jetty instance from inside a public static void main.
So does this mean that it is not (yet) possible to do the same with Java17 and therefore I am shooting in the dark??
Upvotes: 0
Views: 150
Reputation: 49545
First, Jetty 9.x is at End of Life. (so is Jetty 10 and Jetty 11)
You should be using a supported version of Jetty at this point in time.
Jetty 12 is that version (and yes, you can use javax.servlet
on Jetty 12 with the ee8
environment.
Next, Jetty 9.2.3.v20140905
does not support the features present in your dependencies or your version of Java.
Jetty 9.4.9.v20180320
(prior versions fail in various ways, often silently, during servlet initialization due to classloader and bytecode scanning changes in the JVM).10.0.7
.Upvotes: 0