Tomcat : java.lang.ClassNotFoundException: org.slf4j.LoggerFactory - gradle

I am trying to deploy a WAR file on an external tomcat.
every time I try to add slf4j dependency but with no luck.
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1412
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1220)
I am including these dependencies :
"org.slf4j:slf4j-api:1.7.32"
"org.slf4j:jul-to-slf4j:1.7.32",
"org.slf4j:jcl-over-slf4j:1.7.32",
"org.slf4j:log4j-over-slf4j:1.7.32"
the weird thing is that the application works fine with gradle run and with the embedded eclipse's tomcat.

Related

ClassnoutfoundException into wavemaker studio but if I export the war file and deploy it into a local tomcat everything is ok

Did somebody face a similar issue?
When deployed into wavemaker , the error is
Caused by: java.lang.ClassNotFoundException: org.reactivestreams.Publisher
The war contains reactive-streams-1.0.4.jar
Thanks

Missing dependency FreeTypeFontGenerator in fat jar packaged with gradlew

I am packaging a jar file with
gradlew desktop:dist
when running it with java 1.8 (openjdk)
java -jar desktop-1-0.jar
a ClassNotFoundException for the FreeTypeFontGenerator class is thrown. The whole Stacktrace is the following
java -jar desktop-1.0.jar
Picked up _JAVA_OPTIONS: -Xmx512M
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException:
java.lang.NoClassDefFoundError: com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:135)
Caused by: java.lang.NoClassDefFoundError: com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator
at com.mygdx.tools.FontLoader.loadFont(FontLoader.java:13)
at com.mygdx.stages.hud.ClientHud.(ClientHud.java:42)
at com.mygdx.stages.hud.StartmenuHud.joinButtonClicked(StartmenuHud.java:67)
at com.mygdx.stages.hud.StartmenuHud.access$100(StartmenuHud.java:16)
at com.mygdx.stages.hud.StartmenuHud$2.touchDown(StartmenuHud.java:47)
at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:57)
at com.badlogic.gdx.scenes.scene2d.Actor.notify(Actor.java:188)
at com.badlogic.gdx.scenes.scene2d.Actor.fire(Actor.java:158)
at com.badlogic.gdx.scenes.scene2d.Stage.touchDown(Stage.java:281)
at com.badlogic.gdx.backends.lwjgl.LwjglInput.processEvents(LwjglInput.java:357)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:221)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:128)
Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 12 more
I already included the necessary dependencies in the build.gradle file within the root directory of my project for FreeTypeFont as described in the libgdx wiki.
I also refreshed the project dependencies (right-click project -> Gradle -> Refresh Gradle Dependencies)
and rebuild the project.
The solution for me was to add
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
under the desktop section of my build.gradle file.
I tried this out since the import for the controler module looked a bit alike.
I have no idea why this is not documented, but after a refresh of all gradle dependencies (right-click the project -> Gradle -> Refresh Gradle Dependencies) and a rebuild of the project i was able to run the packaged jar without any problems.

Websphere 8.5.5 - spring boot error: SpringServletContainerInitializer not a subtype

I have a spring boot application that works fine on Tomcat 8. When I try to deploy it on Websphere 8.5.5 with "Class loader order" set to "Classes loaded with local class loader first (parent last)" the application fails to start with the following exception:
... 73 more
Caused by: java.util.ServiceConfigurationError: javax.servlet.ServletContainerInitializer: Provider org.springframework.web.SpringServletContainerInitializer not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:242)
at java.util.ServiceLoader.access$300(ServiceLoader.java:192)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:380)
at java.util.ServiceLoader$1.next(ServiceLoader.java:456)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initializeServletContainerInitializers(WebAppImpl.java:537)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:410)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:171)
... 74 more
Just adding my experience with this problem, looking around on the various answers to similar problems I found out that the problem could be caused by some javax-servlet related jar in the classpath. After some trial and error I noticed that the spring-boot-starter-web dependency has an inherited spring-boot-starter-tomcat dependency. Excludung this jar from the application classpath when deploying on Websphere 8.5.5 solved the problem.

Issue in Jboss 7.2.2 migration

I am deploying a WAR file to JBoss EAP 7.2.2. During deployment, I am getting
"Caused by: java.lang.IllegalArgumentException: Unable to load generated mapper class com.amadeus.jcp.services.ttr.display.structured.builder.response.selma.mapper.offer.DisplayTripCartResponseOfferQuotationMapperSelmaGeneratedClass"
which is caused by "Caused by: java.lang.ClassNotFoundException: com.amadeus.jcp.services.ttr.display.structured.builder.response.selma.mapper.offer.DisplayTripCartResponseOfferQuotationMapperSelmaGeneratedClass"
It is a selma generated class and available in a jar inside WEB-INF/lib.
Same WAR file is deploying successfully in JBoss EAP 7.1.
As per class loader hierarchy, it should be identified but not happening.
Anybody have any idea of this issue, please help.
Verified standalone.xml and jboss-deployment-structure.xml. Using same version before and after migration except for name space version upgrade to subsystems.
Using Java 1.8.0_191

JAVA Classpath and jersey client

I had this problem for last few weeks and whenever i run a java application the following exception :
java.lang.NoClassDefFoundError: com/sun/jersey/core/util/FeaturesAndProperties
Caused by: java.lang.ClassNotFoundException:
com.sun.jersey.core.util.FeaturesAndProperties
The problem was jerseyclient.jar, jersey.jar and javax.ws.rs.jar was there in JDK classpath and also there a dependency shich had these files so the that caused this exception. Hope it helps someone !!!

Resources