I've developed some code that executes a quartz job.At first the code was outside the tomcat and it executes very well, but when I tried to embed the same code inside a web application I get java.lang.NoClassDefFoundError: org/quartz/DisallowConcurrentExecution.
I'm using quartz 2.1.5 and it's already in the class path.
Here is the stack trace:
Exception in thread "DefaultQuartzScheduler_QuartzSchedulerThread" java.lang.NoClassDefFoundError: org/quartz/DisallowConcurrentExecution
INFO: Illegal access: this web application instance has been stopped already. Could not load org.quartz.DisallowConcurrentExecution. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
at org.quartz.impl.JobDetailImpl.isConcurrentExectionDisallowed(JobDetailImpl.java:390)
java.lang.IllegalStateException
at org.quartz.simpl.RAMJobStore.acquireNextTriggers(RAMJobStore.java:1447)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1273)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
Caused by: java.lang.ClassNotFoundException: org.quartz.DisallowConcurrentExecution
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.quartz.impl.JobDetailImpl.isConcurrentExectionDisallowed(JobDetailImpl.java:390)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at org.quartz.simpl.RAMJobStore.acquireNextTriggers(RAMJobStore.java:1447)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264)
make sure you have only 1 quartz-all-.jar in your classpath (maybe you have 2 : 1 in Tomcat lib folder + 1 in your war)
NoClassDefFoundErrors point to a missing JAR or class on the classpath. In this case the problem is likely that in Tomcat you have quartz-<ver>.jar on your classpath when you actually need quartz-all-<ver>.jar.
for them who use maven can use the new version by add
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.1.7</version>
</dependency>
It should be keep the .jar file inside of the project location. Import .jar file from the outside from the location which the project have is the reason for getting this error. also verified that if the project is a maven project, then it should include the maven dependency in the pom.xml to add the dependency to the project
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org</groupId>
<artifactId>quartz_job</artifactId>
<version>2.2.1</version>
</dependency>
Related
I was trying out Log4j2 so I created a Java project in eclipse. My code is same as Log4j2 Manual Automatic Configuration part. I have added log4j-api-2.17.2.jar and log4j-core-2.17.2.jar in the classpath. When I run the application I get following error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager
at demo.one.MainClass.<clinit>(MainClass.java:8)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
I have checked some related questions but didn't find those useful.
In case you use maven, make sure to include Log4j core to the project:
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.18.0</version>
</dependency>
Since, it's a NoClassDefFoundError, that means your JRE is not able to find out the necessary jar(class) artifact holding definition for org.apache.logging.log4j.LogManager.
Look for differences between build and runtime classpaths.
Below is my stack trace.
Caused by: java.lang.NoClassDefFoundError: org/apache/axiom/om/util/StAXParserConfiguration
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:64)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:197)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
After a bit searching found that, the dependencies in my project for org.apache.axis2 were been upgraded from 1.5.1 to 1.5.3.
After 1.5.1 version had a transitive dependency on the library having the StAXParserConfiguration class.
But the later(newer) one does not have it. As such, I have to add the artifact explicitly in my pom.
You probably need to bundle the missing library with your deployed artifact,
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.14</version>
</dependency>
I have a maven based project. This is how the project looks like in eclipse:
So I have separate front and back end that are packed into one EAR. The application were deployed on Weblogic 12c server but now I have to move it to Glassfish. I can deploy to Glassfish and my application is running. But, i got an error message when I invoke a method which use Primefaces UploadFile class. This is the error message:
java.lang.NoClassDefFoundError: org/primefaces/model/UploadedFile
javax.ejb.EJBException: java.rmi.ServerError: Error occurred in server thread; nested exception is:
java.lang.NoClassDefFoundError: org/primefaces/model/UploadedFile
This two dependency:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.0</version>
</dependency>
Are in both POM.xml (front and back end) And the maven dependency is in my classpath as you can see in this picture:
My question is, where should I put the Primefaces jar, to make visible for Glassfish in runtime?
You'll either need to add the dependencies to the /lib folder of Glassfish as this is where the container will check for them, or bundle them up with the deployable artifact - in your case the .ear file. As you are using maven there are a couple of plugins available that may help you e.g. the Maven Assembly or Maven Ear plugins.
-Answer based on my comment above.
While trying to marshal the java object to xml i am getting below exception .
java.lang.ClassNotFoundException: org.apache.oro.text.regex.MalformedPatternException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at org.castor.xml.AbstractInternalContext.getRegExpEvaluator(AbstractInternalContext.java:325)
at org.exolab.castor.xml.validators.PatternValidator.initEvaluator(PatternValidator.java:262)
at org.exolab.castor.xml.validators.PatternValidator.validate(PatternValidator.java:200)
at org.exolab.castor.xml.validators.StringValidator.validate(StringValidator.java:302)
at org.exolab.castor.xml.validators.StringValidator.validate(StringValidator.java:340)
at org.exolab.castor.xml.FieldValidator.validateInstance(FieldValidator.java:324)
at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:271)
at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:1072)
at org.exolab.castor.xml.Validator.validate(Validator.java:135)
at org.exolab.castor.xml.Marshaller.validate(Marshaller.java:2594)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:826)
at in.mywebapp.util.XMLUnmarshaller.getStatusRequestParam(XMLUnmarshaller.java:266)
Not sure which jar is missing .
you are probably missing oro.jar. You can add maven dependency
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
</dependency>
or download the jar from maven repository
Please make sure oro jar file is in classpath. It is not there. So, class loading is failing
I am using maven in eclipse and tomcat server.
I have to make small program which sends an email if required every one hour using java mail.
I have modified my web.xml in webapp.
I added mail in POM.xml like this.
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>activation</artifactId>
<groupId>javax.activation</groupId>
</exclusion>
</exclusions>
</dependency>
as I don't require activation because using the jdk 1.6.
I also modified the context.xml
Then copied the mail.jar into tomcat/lib folder.
But i am getting the weird error.
java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
at fr.project.batch.jobs.SendEmail.execute(SendEmail.java:53)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
2014-04-07 10:01:47,539 ERROR duler_Worker-1 Job (DEFAULT.SendMail threw an exception. [ErrorLogger]
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session]
at org.quartz.core.JobRunShell.run(JobRunShell.java:227)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
at fr.project.batch.jobs.SendEmail.execute(SendEmail.java:53)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
... 1 more
I have read many times in tomcat 6.0 JavaMail ressources and gone through many answers of stackoverflow.
This problem occurs in the server because the lib of Tomcat and you application both have their own copy of mail.jar (in WEB-INF/lib), so the classloaders can load two different Session.If you delete the mail.jarfrom your application, this problem will be solved.