How to fix slf4j error in WebLogic deploy - jersey

I'm trying to deploy a REST Service (JAX-RS Jersey + Swagger) in Weblogic Server (without Maven) and I'm getting this error:
weblogic.application.ModuleException: java.lang.NoClassDefFoundError: org/slf4j/spi/LocationAwareLogger
I have referenced the .jar in the project:
I've tried adding weblogic.xml and adding:
<prefer-web-inf-classes>true</prefer-web-inf-classes>
And
<prefer-application-packages>
<package-name>org.slf4j</package-name> (and org.slf4j.*)
</prefer-application-packages>
And
<resource-name>org/slf4j/spi/LocationAwareLogger.class</resource-name>
But doesn't work :(
Does anyone know what this could be?
Thanks & Regards

Finally I solved it,
I have been adding the libraries one by one as I needed and in the end I only needed these:

Related

Is there any way to disable TLD Validation in JBOSS EAP 7.2?

I am trying to migrate my project from jboss-eap-6.4 to jboss-eap-7.2.
When I try to deploy my war file, I get following error:
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYUT0027: Failed to parse XML descriptor \"/C:/jboss-eap-7.2/standalone/deployments/my.war/WEB-INF/lib/spring-modules-validation-1.0.0.jar/META-INF/valang.tld\" at [13,23]
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[13,23]
Message: Unexpected value 'body-content' encountered"}}
I tried searching about this and I got to know that this is common issue. And I got one of the solution as,
changing <body-content>None</body-content> to <body-content>empty</body-content> in valang.tld
in this redhat link: https://access.redhat.com/solutions/910833
as body-content is present at line 13 and I read the documentation for jboss eap 7.2 in which it has written that the value should be empty.
I saw another solution as making this as dependency in maven pom.xml or excluding it.
But I can't do any of this things.
I am using JBOSS EAP 7.2 with gradle, So is there any thing I can do by making changes in gradle or JBOSS's configuration files to solve this issue?
Please help me on this :)
I finally made the same change in the spring-modules-calidation.jar. My concern was to after making this change does it affect my other server, as I was running this on jboss as well as tomcat. So now I am providing the updated jar to JBOSS EAP 7 and the original one to tomcat.

Read emails on Tomcat: ClassNotFoundException: javax.mail.MessagingException

My application is running on Tomcat 7.
I'm trying to read emails from inbox, and for that I use a normal Java class.
There is also a Servlet that calls the method readMails in the mentioned class.
Now I get an exception:
java.lang.ClassNotFoundException: javax.mail.MessagingException
...
I use IntelliJ IDEA with Maven, I changed the dependency of javax.mail a lot (see http://mvnrepository.com/artifact/javax.mail), but the exception keeps coming up.
I've also changed the Version of Tomcat (7 and 8), and the version of "Project SDK" (1.7 and 1.8) and "Project language level" (7 and 8).
I've read somewhere that there is a difference between reading emails via IMAP with normal Java application and running it on Tomcat.
In a previous project I read emails successfully with a normal Java application.
Can anyone help me with this exception?
JavaMail API is not included by default among Tomcat libraries.
Make sure that JavaMail dependency (mail-X.X.jar) is either packaged together with your application (in WEB-INF/lib) or is in a folder that Tomcat class loaders read (for example $CATALINA_HOME/lib), as described here:
http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html
Thanks, it works now.
I put the jar file (javax.mail: javax.mail-api-1.5.4.jar) downloaded by maven (.m2/repository/ ...) into WEB-INF/lib (in my project).
I also needed to put another jar file into WEB-INF/lib (com.sun.mail: javax.mail-1.5.4.jar) due to this exception:
java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger
javax.mail.Session.initLogger(Session.java:226)
javax.mail.Session.<init>(Session.java:210)
javax.mail.Session.getDefaultInstance(Session.java:321)
I added
<packaging>war</packaging>
to my pom.xml. This way maven puts the dependencies in the target folder.

Jboss missing log4j jar, when deploying maven app that has dependency?

I'm in the process of maven-ising and old ant app that we have. I have added a dependency on log4j-1.2.8 in my pom (as it is required for compilation). However, when I try and deploy on jboss (stuck with version 4.0.2) I get the following:
org.jboss.deployment.DeploymentException: Failed to find module file: log4j-1.2.8.jar
at org.jboss.deployment.EARDeployer.init(EARDeployer.java:244)
at org.jboss.deployment.MainDeployer.init(MainDeployer.java:828)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:765)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy8.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:325)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:483)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
I'm not sure who setup jboss and I don't have any control over its configuration. I can however see it has the following log4j jars in various locations:
/opt/jboss-4.0.2]$ find -L . -name '*log4j*.jar'
./client/log4j.jar
./server/minimal/lib/log4j.jar
./server/all/lib/log4j.jar
./server/default/lib/log4j-1.2.16.jar
./lib/log4j-boot.jar
Does anyone have any idea what is setup wrong? I know the old ant app used to work on the same jboss server. I have tried using various versions of log4j in my pom (i.e. those found in the jboss directory), and even tried adding a dependency on jboss-logging - but i'm just guessing here.
Cheers!
Consider adding your log4j dependency as <scope>provided</scope>, as it is provided by your application server and so is not required in the artifact you deploy.

Can not deploy a project on Jboss because of a Dozer class not found

Hi I'm using Eclipse on a EJB3 project, struts2 and hibernate.Server is JBoss 7.1. Everything worked fine.
Then I've installed Dozer 5.2.2,and added that to the build path (it shows in "referenced libraries" folder, and I've checked in the "configure build path" menu as well)
It works fine in my Junit test cases.
The problem is that when I try to deploy the EJB project , I get an error :
Caused by: java.lang.ClassNotFoundException: org.dozer.DozerBeanMapper from [Module "deployment.EJBprofile.jar:main" from Service Module Loader]
What am I doing wrong?
Thanx for your help
You could install the Dozer as a module if you need it for both your EJB and your WAR. You could also package everything into an EAR and put the Dozer library in the EAR/lib directory.
Also have a look at how class loading works.

Tomcat Jersey SPI Error

I have a Jersey (1.4) app deployed on Tomcat 5.5, when Tomcat starts up I can see its loading all the resources and providers. But as soon as I access any of the web services I get this strange error
java.lang.NoClassDefFoundError: com/sun/jersey/spi/inject/Errors$Closure
I spent good long time finding out what's going on but had no luck.
I converted maven project into eclipse project using mvn eclipse:eclipse -Dwtpversion=1.5.
Any ideas?
I got this error when I also had a nuxeo related dependancy in my maven pom.xml, which itself has a dependency on jersey libraries, but at an earlier version (1.1.5 to be specific).
I changed the pom to depend on the latest version of jersey-core, jersey-server and jersey-client dependencies and ran mvn eclipse:eclipse and the problem went away!
There must have been a class clash involved.

Resources