Servlet class org.restlet.ext.servlet.ServerServlet is not a jakarta.servlet.Servlet - servlets

What could be causing this error?
Caused by: jakarta.servlet.UnavailableException: Servlet class org.restlet.ext.servlet.ServerServlet is not a jakarta.servlet.Servlet
at org.eclipse.jetty.servlet.ServletHolder.checkServletType (ServletHolder.java:499)
at org.eclipse.jetty.servlet.ServletHolder.doStart (ServletHolder.java:377)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:96)
at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$2 (ServletHandler.java:699)
at java.util.stream.SortedOps$SizedRefSortingSink.end (SortedOps.java:357)
at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:474)
at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining (StreamSpliterators.java:312)
at java.util.stream.Streams$ConcatSpliterator.forEachRemaining (Streams.java:735)
at java.util.stream.ReferencePipeline$Head.forEach (ReferencePipeline.java:658)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:724)
I'm running the web app from mvn jetty:run plugin

jakarta.servlet.UnavailableException: Servlet class [...] is not a jakarta.servlet.Servlet
The jakarta.servlet.Servlet is part of Servlet API version 5.0 which in turn is part of Jakarta EE version 9. This can thus only mean that the servlet class specified in [...] is NOT compiled against Servlet API version 5.0, but against an older version.
You have 2 options:
Upgrade the servlet class specified in [...] to a Servlet API version 5.0 compatible one.
Or, downgrade the servlet container from Servlet API version 5.0 to a previous version, at least the one matching the target Servlet API version of the servlet class specified in [...].
The technical reason is that during the step from Java/Jakarta EE 8 to Jakarta EE 9 all javax.* packages have been renamed to jakarta.* packages. So there is no backwards compatibility anymore since Jakarta EE 9.
When we translate the above facts to your specific situation, your only option is to downgrade the Jetty servlet container to a Servlet 4.0 compatible version. This is because the 3rd party library "Restlet" has currently no Servlet 5.0 compatible version available at all. According to Jetty's version table, Jetty 11.x is Jakarta EE 9 targeted, so you need Jetty version 10.x or older.
Alternatively, you can drop Restlet altogether and use Jersey instead. It has currently a Jakarta EE 9 compatible version available.
See also:
Jetty versions
Getting java.lang.ClassNotFoundException: jakarta.servlet.Filter on Maven/Jersey web service while running on Tomcat 9

I was trying to run a Maven application inside a Wildfly server
I installed 20.0.1.Final, the last version before Jakarta

Related

Spring Kafka 2.9.3 NoClassDefFound - AlterIsrRequest$Builder on EmbeddedKafka Start up

Trying to upgrade the springboot application which uses spring kafka to version 2.9.3 from 2.8.4.
I have followed the instructions here to pulldown kafka-client version 3.2.3 as a separate dependency.
My dependencies looks like this
implementation("org.springframework.kafka:spring-kafka:2.9.3") {
exclude group: "org.apache.kafka", module: "kafka-streams"
exclude group: "org.apache.kafka", module: "kafka-clients"
}
implementation("org.apache.kafka:kafka-clients:3.2.3")
testImplementation("org.springframework.kafka:spring-kafka-test:2.9.3")
When I try to kick off a test which makes use of EmbeddedKafka.
I am getting this NoClassDefFound error
Caused by: java.lang.NoClassDefFoundError: org/apache/kafka/common/requests/AlterIsrRequest$Builder
at kafka.server.KafkaServer.startup(KafkaServer.scala:313)
at kafka.utils.TestUtils$.createServer(TestUtils.scala:177)
at kafka.utils.TestUtils$.createServer(TestUtils.scala:172)
at kafka.utils.TestUtils.createServer(TestUtils.scala)
at org.springframework.kafka.test.EmbeddedKafkaBroker.afterPropertiesSet(EmbeddedKafkaBroker.java:350)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
... 87 more
Caused by: java.lang.ClassNotFoundException: org.apache.kafka.common.requests.AlterIsrRequest$Builder
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 94 more
I think I am missing a dependency?
You have a version mis-match between the kafka-clients and other kafka jars. All kafka jars must be the same version since the server uses classes from the clients jar.
I don't see AlterIsrRequest in jars since 3.1.2 - so it looks like, somehow, you have older kafka server jars on the class path.
spring-kafka-test:2.9.3 should pull in 3.2.3 transitively.
Since you are using Spring Boot, it will pull in 3.1.2 instead.
See the documentation (https://docs.spring.io/spring-kafka/docs/2.9.3/reference/html/#update-deps) for how to override the dependencies when using Spring Boot.

Can't deploy war because ClassCastException: org.hibernate.jpa.HibernatePersistenceProvider incompatible javax.persistence.spi.PersistenceProvider

I got this error even i have created a shared lib on was 9, this lib contains all the hibernate 5.4.3 dependency including javax.persistence 2.2
Do you really needs JPA 2.2 ?
I was able to deploy my EAR under WAS 9 using hibernate 5.2.17 (starting from 5.3 hibernate is JPA 2.2 compliant)
WAS 9 it seems compatible only with JPA 2.0 and JPA 2.1
I created the shared lib using following lists of jars
E:\hibernate-release-5.2.17.Final\lib\envers\hibernate-envers-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\jpa-metamodel-generator\hibernate-jpamodelgen-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\c3p0\c3p0-0.9.5.2.jar
E:\hibernate-release-5.2.17.Final\lib\optional\c3p0\hibernate-c3p0-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\c3p0\mchange-commons-java-0.2.11.jar
E:\hibernate-release-5.2.17.Final\lib\optional\ehcache\ehcache-2.10.3.jar
E:\hibernate-release-5.2.17.Final\lib\optional\ehcache\hibernate-ehcache-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\ehcache\slf4j-api-1.7.7.jar
E:\hibernate-release-5.2.17.Final\lib\optional\infinispan\hibernate-infinispan-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\infinispan\infinispan-commons-8.2.5.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\infinispan\infinispan-core-8.2.5.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\infinispan\jboss-marshalling-osgi-1.4.10.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\infinispan\jgroups-3.6.7.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\proxool\hibernate-proxool-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\proxool\proxool-0.8.3.jar
E:\hibernate-release-5.2.17.Final\lib\osgi\byte-buddy-1.6.14.jar
E:\hibernate-release-5.2.17.Final\lib\osgi\hibernate-osgi-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\osgi\javax.interceptor-api-1.2.jar
E:\hibernate-release-5.2.17.Final\lib\osgi\org.osgi.compendium-4.3.1.jar
E:\hibernate-release-5.2.17.Final\lib\osgi\org.osgi.core-4.3.1.jar
E:\hibernate-release-5.2.17.Final\lib\required\antlr-2.7.7.jar
E:\hibernate-release-5.2.17.Final\lib\required\classmate-1.3.0.jar
E:\hibernate-release-5.2.17.Final\lib\required\dom4j-1.6.1.jar
E:\hibernate-release-5.2.17.Final\lib\required\hibernate-commons-annotations-5.0.1.Final.jar
E:\hibernate-release-5.2.17.Final\lib\required\hibernate-core-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\required\jandex-2.0.3.Final.jar
E:\hibernate-release-5.2.17.Final\lib\required\javassist-3.22.0-GA.jar
E:\hibernate-release-5.2.17.Final\lib\required\jboss-logging-3.3.1.Final.jar
It is important on the Shared Lib def to check "Class Loading - Use an isolated class loader for this shared library"
and on the Applicatiion --> Class Loader --> Class Loader Order --> select Classes Loaded with Local Class Loader First (Parent Last)
I'm looking too to use up-to-date Hibernate 5.4.x (stable) and in the future the 6.x.. but having similar issue
If eventually you was able to use Hibernate 5.4.x.. can you share ?
Regards

Where to download HttpServlet.java v1.2?

We have a old system that use HttpServlet v1.2, where can I download source for debug in eclipse? I googled obky found v2.0 or v3.0...
The `(version 1.2 : 46.0, ...) indicates that this class file was compiled with java 1.2.
Java 1.2 was specified for both servlet-api 2.2 and 2.3.
As Tomcat has been the reference implementation of these specifications forever, it is possible to rummage through their archive and find (for example) Tomcat 3.3, which was the RI for the 2.2 specification.
A list of distributions can be found at http://archive.apache.org/dist/tomcat/tomcat-3/. If you dig through the binary distributions there you will find a servlet.jar which might match your needs.
If this turns out to be too old (indicated by missing methods in the Java classes it provides) then you will need to search forwards in the Tomcat archives to find the release that implements the Servlet 2.3 specification instead.
(It looks like http://archive.apache.org/dist/tomcat/tomcat-4/ and related contains the Servlet 2.3 spec jars)

Symfony 3.0.4 security.secure_random doesn't exists

I'm migrating symfony 2.6 app to the 3.0.4, I'm in a trouble with security.secure_random service, I was using it with dependency injection. Which is representing in security.xml
but I cannot see in 3.0.x I checked changelog every pixel of the project where it does go ? That I'm missing something ?
The class deprecated in 2.8 and removed in 3.0 in favour of the random_bytes function.
Essentialy the SecureRandomInterface had one nextBytes method, which behaves exactly as the PHP7 random_bytes function.
You can install https://github.com/paragonie/random_compat for forward compatibility

forEach is not working with Spring3 + Tiles 2+ Jstl 1.2 + Weblogic 9.2

whenever I use a c:foreach tag in my jspx files I'm getting below error
Caused by: java.lang.NoSuchMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;
at javax.servlet.jsp.jstl.core.LoopTagSupport.unExposeVariables(LoopTagSupport.java:587)
at javax.servlet.jsp.jstl.core.LoopTagSupport.doFinally(LoopTagSupport.java:323)
at jsp_servlet._web_45_inf._views.__matchdriverpopup_jspx._jspService(__matchdriverpopup_jspx.java:1160)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:496)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:245)
at org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:241)
How can I solve this? This is only related to c:forEach. All other tags are working fine. I have follwing jar files in APP-INF/lib folder of EAR and tiles-jsp-2.2.0.jar and jstl-1.2.jar in my WEB-INF/lib of WAR file. web.xml version - 2.4
tiles-api-2.2.0
tiles-core-2.2.0
tiles-jsp-2.2.0
tiles-servlet-2.2.0
tiles-template-2.2.0
Please help, Thanks in advance
This exception indicates that the JSTL API is of a newer version than the JSTL impl. And indeed, Weblogic already ships with JSTL bundled. It's apparently of an older version than the one in your webapp. The newer JSTL API is been loaded from your webapp, but the older JSTL impl is been loaded from Weblogic.
Remove the JSTL libraries from your webapp so that the webapp will just use Weblogic's own ones.

Resources