Spring Boot JSP - java

Is there any simple way to generate Spring Boot Mvc project for .jsp views?
I've tried to create project in similar way like Spring Boot Rest project, but it's not soo easy for me. I've tried to use official Spring Boot Mvc jsp sample, but when I try to run this I get exception like this:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [sample.jsp.SampleWebJspApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.context.web.SpringBootServletInitializer
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:187) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:765) [spring-boot-1.4.0.BUILD-20160427.203128-289.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.4.0.BUILD-20160427.203128-289.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.4.0.BUILD-20160427.203128-289.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1182) [spring-boot-1.4.0.BUILD-20160427.203128-289.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1171) [spring-boot-1.4.0.BUILD-20160427.203128-289.jar:1.4.0.BUILD-SNAPSHOT]
at sample.jsp.SampleWebJspApplication.main(SampleWebJspApplication.java:33) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.context.web.SpringBootServletInitializer
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:163) ~[spring-core-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:300) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:237) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:204) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:173) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
... 17 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_65]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_65]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_65]
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152) ~[spring-core-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_65]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_65]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_65]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_65]
... 25 common frames omitted

This blog post explains what steps you should take and why. Its fairly easy and I've fixed it myself.
TD:LR
Add Maven Dependencies
In order to enable JSP support, we need to add a few dependencies to our new project in pom.xml.
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
Place the JSP templates under src/main/resources/META-INF/resources/WEB-INF/jsp/

As I know, the spring boot default page technology is thymeleaf and the official recommends us to use it.
If you want to use jsp, you could do some configuration.
The following steps may be useful.
1. Creating src/main/webapp/WEB-INF/jsp folder.
2. Modify application.properties file.
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
3.Add jar support for jsp. You could add the followings maven repository to your project pom.xml file.
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
Hope it helps. Any concerns, please feel free to let me know.

Add below dependencies to your POM file:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
Create below structure
/src/main/resources/META-INF/resources
Now the above folder is equivalent to your WebContent folder. Inside this you can put your static contents. Add WEB-INF folder here and now you can place your JSP files like any other web project.
In your application.properties file add below:
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

Any chance you're running in IntelliJ? I've noticed this issue as well and the solution is to remove the <scope>provided</scope> from the spring-boot-starter-tomcat dependency, like this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!-- <scope>provided</scope> -->
</dependency>
There's a bug in IntelliJ, causing it not to add provided dependencies to the classpath when running locally.
EDIT: Removing the provided scope might cause issues when you're going to run it within a servlet container, so be cautious about that, an explanation about how to fix that could be found in Run Spring-boot's main using IDE.

I have had similar problems, see the link to github.
jsf-spring-boot-2.1.6 parent use spring boot 1.4.0
everything has worked and there is no problems, believe it or not!
https://github.com/joinfaces/joinfaces-example-war

Adding dependency in POM file below
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
Full code avaliable on github link click here
Download the code and import the eclipse/STS using exiting maven project
Next to run the project.
Go to the package on com.chandrakumar.test.demo.
it has "DemoApplication.java" and right click the mouse and select run as
choose the java application.
The browser address bar type "http://localhost:8080/".

Following johnny's reply, I actually wasn't aware that JSP files could be ran while deploying the application as a JAR. Though apparently there are some extensions that I haven't heard of... Typically, a JSP application is deployed as a WAR, and all JSP-related files are located in the webapp/WEB-INF/ folder. You may need to add <packaging>war</packaging> to your POM if if you are comfortable packaging your application as a WAR. This doesn't sound like a bad idea if your application is not a microservice or does not utilize cloud-based technologies. But the majority of cloud-based technologies (excluding cloud-foundry and maybe some others) only support JAR packaging. In that case, you may want to use alternative templates such as Thymeleaf or FreeMarker, over JSP, if you decide to go the JAR route.

Use a maven run configuration with spring-boot:run as the "Command line" value.

Related

Thymeleaf unable to find template folder with error : class path resource [templates/error] cannot be opened because it does not exist

While trying to load the swagger ui im getting the following error from the application:
Caused by: java.io.FileNotFoundException: class path resource [templates/error] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:199) ~[spring-core-5.3.20.jar:5.3.20]
at org.thymeleaf.spring5.templateresource.SpringResourceTemplateResource.reader(SpringResourceTemplateResource.java:103) ~[thymeleaf-spring5-3.0.15.RELEASE.jar:3.0.15.RELEASE]
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:223) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE]
... 90 common frames omitted
the dependency im using :
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
<version>3.0.15.RELEASE</version>
</dependency>
this is happening after the spring boot version was updated, the previous version didnt show this issue.
Also my
src/main/resources/templates
folder did not have any error folder before the upgrade as well.
Would appreciate if anyone knows why is this happening?
Make sure to put html/thymeleaf files inside
src->main->resources->templates-> YOUR_HTML files
also check in your pom.xml, that thymleaf has been added
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

Spring-boot War on Weblogic 12c

I'm having errors during deployment with Spring-boot 2.1.2.RELEASE on
WebLogic 12.2.1.2.0.
This is the stack trace:
Caused By: java.lang.IllegalAccessError: tried to access method com.fasterxml.jackson.databind.ser.std.StdSerializer.<init>(Ljava/lang/Class;)V from class com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
at com.fasterxml.jackson.datatype.jsr310.JavaTimeModule.<init>(JavaTimeModule.java:168)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:122)
at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.registerWellKnownModulesIfAvailable(Jackson2ObjectMapperBuilder.java:760)
at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.configure(Jackson2ObjectMapperBuilder.java:639)
at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:623)
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.<init>(MappingJackson2HttpMessageConverter.java:59)
at org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.<init>(AllEncompassingFormHttpMessageConverter.java:76)
at org.springframework.web.filter.FormContentFilter.<init>(FormContentFilter.java:60)
at org.springframework.boot.web.servlet.filter.OrderedFormContentFilter.<init>(OrderedFormContentFilter.java:29)
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.formContentFilter(WebMvcAutoConfiguration.java:166)
I've tried adding this to the weblogic.xml:
<wls:package-name>com.fasterxml.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.databind.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.datatype.jsr310.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.datatype.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.module.*</wls:package-name>
I've also tried using prefer-web-inf classes. The StdSerializer class is in the jackson-datatype-jsr310:2.9.8 jar, which theoretically shouldn't be an issue because welogic doesn't have Jackson included. Any help would be appreciated.
1) Keep only these packages in your weblogic.xml file, the others are unnecessary:
<wls:prefer-application-packages>
<wls:package-name>org.slf4j.*</wls:package-name>
<wls:package-name>org.springframeworks.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.*</wls:package-name>
</wls:prefer-application-packages>
2) Include this in your pom.xml as per Spring Docs, section 92.1:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
This error happens because Spring Boot is trying to start a Tomcat container, causing classpath conflicts. Setting the dependency as provided will remove most of those, and including com.fasterxml.jackson.* in your weblogic.xml will take care of the remaining conflict.

ClassNotFoundException oracle.i18n.util.LocaleMapper on tomcat TLD scanning. ojdbc7 maven dep (xmlparserv2-12.1.0.2.jar transitive) causes this error

I am receiving an error when running my spring-boot application with embedded-tomcat (haven't tried with server tomcat yet).
java.lang.IllegalStateException: Tomcat 7 reflection failed
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.scan(SkipPatternJarScanner.java:77)
at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:271)
at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:590)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5522)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.scan(SkipPatternJarScanner.java:73)
... 12 common frames omitted
Caused by: java.lang.NoClassDefFoundError: oracle/i18n/util/LocaleMapper
at oracle.xml.parser.v2.XMLReader.setEncoding(XMLReader.java:980)
at oracle.xml.parser.v2.XMLReader.checkXMLDecl(XMLReader.java:3284)
at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:570)
at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:274)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:232)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1576)
at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:565)
at org.apache.catalina.startup.TldConfig.tldScanJar(TldConfig.java:513)
at org.apache.catalina.startup.TldConfig.access$200(TldConfig.java:61)
at org.apache.catalina.startup.TldConfig$TldJarScannerCallback.scan(TldConfig.java:300)
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:259)
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:221)
... 17 common frames omitted
Caused by: java.lang.ClassNotFoundException: oracle.i18n.util.LocaleMapper
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 29 common frames omitted
On further inspection, It appears as though the previous version of the orai18n.jar depended on by the ojdbc7 maven dep contained this class in vesion 11.2.0.3 but the newer (12.1.0.2) file does not contain it.
After much hassle, I've found the root cause (Edit: Actually the better answer provided has a more appropriate cause/solution, see Serri's answer):
according to this bug comment in spring-boot The Oracle SaxParserFactory impl and the (later run into after solving the first) DocumentBuilderFactory implementations are picked up instead of the default xerces impls. Changing the implementation using the META-INF/services/<class-name> files solved the issue:
in my.jar:
and each file:
// javax.xml.parsers.DocumentBuilderFactory
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
// javax.xml.parsers.SAXParserFactory
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
This causes each service finder to resolve the default xerces implementation in the standard java library.
It's a conflict with xmlparserv2.
Try this :
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
<exclusions>
<exclusion>
<groupId>com.oracle.jdbc</groupId>
<artifactId>xmlparserv2</artifactId>
</exclusion>
</exclusions>
</dependency>
In my case I had the Oracle Jars installed under $CATALINA_HOME/lib to be able to set up a JNDI DB connection in Tomcat, simply removing xmlparserv2.jar from the $CATALINA_HOME/lib directory resolved the problem.
New change for xdb instead com.oracle.jdbc use: com.oracle.ojdbc.
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>xdb</artifactId>
<version>19.3.0.0</version>
<exclusions>
<exclusion>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>xmlparserv2</artifactId>
</exclusion>
</exclusions>
</dependency>
The cause of the problem is as Serri said, except for the solution given by Serri I think if you use IntelliJ IDEA as a coding tool, please check Project Structure Artifacts to remove the dependency on xmlparserv2, this worked for me
Remove conflicting dependencies

Getting java.lang.ClassNotFoundException:MalformedPatternException

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

java.lang.ClassNotFoundException: org.quartz.DisallowConcurrentExecution

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>

Categories