I have a problem with grailsVersion=3.3.0.M1 and gradleWrapperVersion=3.0. Whenever I run the project I get the following error.
|Resolving Dependencies. Please wait...
CONFIGURE SUCCESSFUL
Total time: 13.543 secs |Running application... 2017-05-29
22:08:46.634 ERROR --- [ main] o.s.boot.SpringApplication
: Application startup failed
java.lang.NoClassDefFoundError:
org/springframework/boot/context/embedded/FilterRegistrationBean at
asset.pipeline.AssetPipelineGrailsPlugin$_doWithSpring_closure1.doCall(AssetPipelineGrailsPlugin.groovy:105)
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.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at
org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027)
at groovy.lang.Closure.call(Closure.java:414) at
groovy.lang.Closure.call(Closure.java:408) at
grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:759)
at grails.spring.BeanBuilder.beans(BeanBuilder.java:588) at
grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:531) at
org.grails.plugins.DefaultGrailsPlugin.doWithRuntimeConfiguration(DefaultGrailsPlugin.java:559)
at
org.grails.plugins.AbstractGrailsPluginManager.doRuntimeConfiguration(AbstractGrailsPluginManager.java:167)
at
grails.boot.config.GrailsApplicationPostProcessor.postProcessBeanDefinitionRegistry(GrailsApplicationPostProcessor.groovy:171)
at
org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118)
at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)
at
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at grails.boot.GrailsApp.run(GrailsApp.groovy:83) at
grails.boot.GrailsApp.run(GrailsApp.groovy:388) at
grails.boot.GrailsApp.run(GrailsApp.groovy:375) at
grails.boot.GrailsApp$run.call(Unknown Source) at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at mjmdashboardnext.Application.main(Application.groovy:8) Caused by:
java.lang.ClassNotFoundException:
org.springframework.boot.context.embedded.FilterRegistrationBean 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) ... 33 common
frames omitted
2017-05-29 22:08:46.749 ERROR --- [ main]
o.s.b.f.s.DefaultListableBeanFactory : Destroy method on bean with
name 'grailsApplicationPostProcessor' threw an exception
java.lang.IllegalStateException: ApplicationEventMulticaster not
initialized - call 'refresh' before multicasting events via the
context:
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#64c2b546:
startup date [Mon May 29 22:08:08 NPT 2017]; root of context hierarchy
at
org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404)
at
org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97)
at
org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968)
at
org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033)
at
org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009)
at
org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961)
at
org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:794)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:325)
at grails.boot.GrailsApp.run(GrailsApp.groovy:83) at
grails.boot.GrailsApp.run(GrailsApp.groovy:388) at
grails.boot.GrailsApp.run(GrailsApp.groovy:375) at
grails.boot.GrailsApp$run.call(Unknown Source) at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at mjmdashboardnext.Application.main(Application.groovy:8)
2017-05-29 22:08:46.765 ERROR --- [ main]
o.s.b.f.s.DefaultListableBeanFactory : Destroy method on bean with
name
'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory'
threw an exception
java.lang.IllegalStateException: ApplicationEventMulticaster not
initialized - call 'refresh' before multicasting events via the
context:
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#64c2b546:
startup date [Mon May 29 22:08:08 NPT 2017]; root of context hierarchy
at
org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404)
at
org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97)
at
org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968)
at
org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033)
at
org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009)
at
org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961)
at
org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:794)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:325)
at grails.boot.GrailsApp.run(GrailsApp.groovy:83) at
grails.boot.GrailsApp.run(GrailsApp.groovy:388) at
grails.boot.GrailsApp.run(GrailsApp.groovy:375) at
grails.boot.GrailsApp$run.call(Unknown Source) at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at mjmdashboardnext.Application.main(Application.groovy:8)
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':bootRun'.
Process 'command 'C:\Program Files\Java\jdk1.8.0_121\bin\java.exe'' finished with non-zero exit value 1
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Error | Failed to start server (Use --stacktrace to see the full trace)
Process finished with exit code 1
I have tried to upgrade my plugins in build.gradle but the error remains the same.
My build.gradle is as follows
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "org.grails.plugins:hibernate5:6.0.7"
classpath "org.grails.plugins:views-gradle:1.1.5"
classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.10.1'
classpath "org.grails.plugins:views-gradle:1.2.0"
} }
version "0.5.1" group "test"
apply plugin:"eclipse" apply plugin:"idea" apply plugin:"war" apply plugin:"org.grails.grails-web" apply plugin:"org.grails.plugins.views-json"
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
maven { url 'http://dl.bintray.com/agorapulse/libs' } }
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false }
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-codecs"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-datasource"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-async"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.1.2.Final"
compile "org.hibernate:hibernate-ehcache:5.1.2.Final"
compile "org.grails.plugins:views-json:1.2.1"
compile "org.grails.plugins:views-json-templates:1.2.1"
console "org.grails:grails-console"
profile "org.grails.profiles:rest-api"
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testCompile "org.grails:grails-datastore-rest-client"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
runtime 'mysql:mysql-connector-java:5.1.36'
compile 'org.grails.plugins:aws-sdk-s3:2.1.5'
compile 'org.grails.plugins:spring-security-core:3.1.1'
compile "org.grails.plugins:spring-security-rest:2.0.0.M2"
compile 'com.nayidisha.grails.uploadr:grails3-uploadr:3.1.0'
compile 'org.grails.plugins:joda-time:2.0.0'
compile 'org.grails.plugins:quartz:2.0.9'
compile 'org.grails.plugins:wkhtmltopdf:1.0.0.RC7'
compile 'org.grails.plugins:rabbitmq:2.0.0'
compile 'org.grails.plugins:excel-import:3.0.0.RC2'
compile 'com.bertramlabs.plugins:selfie:1.1.1'
compile "org.grails.plugins:swaggydoc-grails3:0.26.0"
compile "org.grails:grails-dependencies"
}
bootRun {
jvmArgs('-Dspring.output.ansi.enabled=always') }
grails {
pathingJar = true }
Has anyone faced this issue? How do I resolve this?
compile 'org.grails.plugins:spring-security-core:3.1.1'
Is not compatible with 3.3 - use
compile 'org.grails.plugins:spring-security-core:3.2.0.M1'
Also I'd suggest using the gradle wrapper that the grails version you use ships with. 3.0 is quite old.
You can see my 3.3.0 Upgrade notes here https://gist.github.com/erichelgeson/72e1b6cb8e1b9428738799368c32133f
Also 3.3.0.M2 was just released today with a bunch of fixes.
Related
Error running in Tomcat after war generation
How to solve “Failed to instantiate WebApplicationInitializer class”
Generating jars is operational
The changes i did in my gradle build file
2-Jul-2019 16:00:10.516 严重 [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Error during ServletContainerInitializer processing
javax.servlet.ServletException: Failed to instantiate WebApplicationInitializer class
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:155)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5267)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1140)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.InstantiationException: io.j99.app.measure.Application
at java.lang.Class.newInstance(Unknown Source)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:152)
... 12 more
Caused by: java.lang.NoSuchMethodException: io.j99.app.measure.Application.<init>()
at java.lang.Class.getConstructor0(Unknown Source)
... 14 more
02-Jul-2019 16:00:10.516 严重 [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/measure-0.0.1] startup failed due to previous errors
02-Jul-2019 16:00:10.562 警告 [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [measure-0.0.1] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
02-Jul-2019 16:00:10.562 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps\measure-0.0.1] has finished in [5,484] ms
02-Jul-2019 16:00:10.562 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps\ROOT]
02-Jul-2019 16:00:10.734 信息 [36] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1364)
at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1021)
at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkContextClassLoaders(AbandonedConnectionCleanupThread.java:96)
at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:69)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
enter code here
The changes i did in my gradle build file
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
//apply plugin: 'spring-boot'
//apply plugin: 'watch'
apply plugin: 'war'
war {
baseName = 'measure'
version = '0.0.1'
}
/*apply plugin: 'idea'
idea {
module {
inheritOutputDirs = false
outputDir = file("$buildDir/classes/main/")
}
}*/
repositories {
maven { url "http://maven.aliyun.com/nexus/content/repositories/public/" }
maven { url "http://repo.spring.io/libs-snapshot" }
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
springBoot {
executable = true
}
configurations {
// providedRuntime
dev
}
/*jar {
mainClass = "io.j99.app.measure.Application"
}*/
dependencies {
compile("commons-logging:commons-logging:1.2")
compile("javax.servlet:javax.servlet-api:4.0.1")
//
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-jasper', version: '9.0.8'
compile("org.springframework.boot:spring-boot-devtools")
//
compile group: 'org.springframework.boot', name: 'spring-boot-dependencies', version: '2.2.0.M4'
compile group: 'org.springframework.boot', name: 'spring-boot-maven-plugin', version: '2.2.0.M4'
///
compile ("org.springframework.boot:spring-boot-dependencies")
compile ("org.springframework.boot:spring-boot-maven-plugin")
///
////
compile group: 'cn.org.faster', name: 'spring-boot-starter-parent', version: '1.1.1.RELEASE'
compile ("org.springframework.boot:spring-boot-starter-tomcat")
compile ("org.springframework.boot:spring-boot-starter-web")
compile ("org.springframework.boot:spring-boot-devtools")
//
compile "org.springframework.boot:spring-boot-configuration-processor"
compile("mysql:mysql-connector-java:8.0.12")
///
compile fileTree(dir: 'libs', include: ['*.jar'])
// dev("org.springframework.boot:spring-boot-devtools")
testCompile("org.springframework.boot:spring-boot-starter-test")
compile "io.springfox:springfox-swagger2:2.5.0"
compile("org.springframework.session:spring-session")
compile("org.simpleframework:simple-xml:2.7")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-data-redis")
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile 'io.jsonwebtoken:jjwt:0.6.0'
// compile("org.springframework.boot:spring-boot-starter-data-mongodb")
compile("org.springframework.boot:spring-boot-starter-jdbc")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-actuator")
// compile("mysql:mysql-connector-java")
compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.6.0")
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-jackson:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.1.2'
compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile("org.springframework.boot:spring-boot-starter-web")
compile('commons-net:commons-net:3.5')
compile('com.googlecode.log4jdbc:log4jdbc:1.2')
// https://mvnrepository.com/artifact/org.apache.poi/poi
compile group: 'org.apache.poi', name: 'poi', version: '3.15'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.15'
// https://mvnrepository.com/artifact/commons-lang/commons-lang
compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
compile 'com.qiniu:qiniu-java-sdk:7.2.2'
// https://mvnrepository.com/artifact/org.apache.ant/ant
compile group: 'org.apache.ant', name: 'ant', version: '1.10.1'
}
bootRun {
// addResources = true
classpath = sourceSets.main.runtimeClasspath + configurations.dev
}
War can be generated
Cannot run in Tomcat
Is it due to the lack of jar?
Please let me know how to resolve the same
I encountered this error when I tried to deployed war in tomcat with spring boot 2.1.2.My tomcat version is 8.5.14 and java is 1.8.0_121.I think i had done everything right and its working perfectly in my machine but its not working when i deploy it on server with below error.
08-May-2019 05:54:33.459 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.14
08-May-2019 05:54:33.462 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /opt/apache-tomcat/webappsloop/LoopServer.war
08-May-2019 05:54:33.665 WARNING [localhost-startStop-1] org.apache.tomcat.util.descriptor.web.WebXml.setVersion Unknown version string [4.0]. Default version will be used.
08-May-2019 05:54:38.037 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
08-May-2019 05:54:38.041 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 2 Spring WebApplicationInitializers detected on classpath
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/apache-tomcat/webappsloop/LoopServer/WEB-INF/lib/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/apache-tomcat/webappsloop/LoopServer/WEB-INF/lib/logback-classic-1.1.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
08-May-2019 05:54:38.231 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Loop].StandardHost[localhost].StandardContext[/LoopServer]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1823)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
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:745)
Caused by: java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.boot.SpringApplicationRunListener : org.springframework.boot.context.event.EventPublishingRunListener
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:450)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:429)
at org.springframework.boot.SpringApplication.getRunListeners(SpringApplication.java:415)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:301)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:157)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:137)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.event.EventPublishingRunListener]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:184)
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:446)
... 19 more
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
at org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:109)
at org.springframework.boot.context.event.EventPublishingRunListener.<init>(EventPublishingRunListener.java:58)
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)
... 20 more
08-May-2019 05:54:38.232 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive /opt/apache-tomcat/webappsloop/LoopServer.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Loop].StandardHost[localhost].StandardContext[/LoopServer]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:756)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1823)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
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:745)
08-May-2019 05:54:38.232 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /opt/apache-tomcat/webappsloop/LoopServer.war has finished in 4,770 ms
Below is my build.gradle config
group 'com.lss.loopserver'
version '1.0-SNAPSHOT'
buildscript {
ext {
springBootVersion = '2.1.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
war {
baseName = 'LoopServer'
version = '0.0.1'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
maven { url "http://repo.spring.io/libs-snapshot" }
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.cloud:spring-cloud-starter-oauth2')
compile 'org.springframework.boot:spring-boot-starter-aop'
compile('org.springframework.boot:spring-boot-starter-web')
compile('javax.inject:javax.inject:1')
compile ('mysql:mysql-connector-java:6.0.6')
compile ('com.google.code.gson:gson:2.8.1')
compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.3'
compile 'org.apache.commons:commons-io:1.3.2'
runtime('org.springframework.boot:spring-boot-devtools')
runtime('com.h2database:h2')
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Greenwich.RC2"
}
}
bootRun {
sourceResources sourceSets.main
}
The Application class with main function as below.
#SpringBootApplication
public class Main extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Main.class);
}
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}
NoSuchMethodError error, the most likely is the problem of the introduction of the jar package, or the jar package conflict.
You can look at the tree structure of the jar package through maven and see the dependencies after the jar package. If it is true that the jar package is missing, import the jar package, for example, Caused by: java.lang.NoSuchMethodError: org.springframework.aop.xxxxx.xxxxx. I will first look for the jar package that the project depends on. There is no such jar package exists, and then there is no such class, the method.
If not, you can add dependencies via the pom (maven configuration file) file. If this class exists, it is likely that the jar package conflicts.
For a jar package conflict, let's take a very simple example. If you reference the A.jar package and the B.jar package, both A and B depend on the C.jar package. However, A depends on the 1.1 version of the C.jar package, and B depends on the 2.1 version of the jar package. If your project is stored in version 1.1 at this time, it is very likely that an error will be reported.
Seems there is a dependency exclusion you should do ,
For Gradle (but not sure):
dependencies {
implementation('org.springframework.boot:spring-boot-starter-security:version) {
exclude group: 'org.springframework', module: 'spring-aop'
}
}
Maven way :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId></artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
</exclusions>
</dependency>
Refer the dependency sections of spring boot repos , seems to be transitive dependency issue https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-aop/2.1.2.RELEASE
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security/2.1.2.RELEASE
Also for the Tomcat part
dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
providedRuntime group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: "2.1.2.RELEASE"
}
Context
I have a situation where I do not control the main of the application nor the libraries on the class path. I am extending (via a plug-in API) an existing Swing application. The goal of my project is to make the information inside of that legacy application available through a HTTP API to then interface it via a web application.
Technical situation
The application in question has already Jackson in the class path in version 2.7. I am trying to use Spring Boot version 2, which is built against Jackson 2.8. When I start the server, Spring is unable to initialise because it is trying to configure Jackson stuff, using classes and methods that did not exist in 2.7.
What I would like to do is prevent Spring from automatically configuring anything Jackson-related and let me provide my own content negotiator.
I already tried
#SpringBootApplication(
exclude = arrayOf(JacksonAutoConfiguration::class)
)
but it does not work.
Digging into Spring code, I see places where it is hard-coded inside of AllEncompassingFormHttpMessageConverter that is Jackson is on the class path, it should create new objects (that cause the exception in question), despite the fact I am excluding the Jackson configuration in my Spring Boot application.
private static final boolean jackson2Present =
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", AllEncompassingFormHttpMessageConverter.class.getClassLoader()) &&
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", AllEncompassingFormHttpMessageConverter.class.getClassLoader());
and then later:
if (jackson2Present) {
addPartConverter(new MappingJackson2HttpMessageConverter());
}
Project as it is now
Here is a link to GitHub, to the right branch.
https://github.com/Adeynack/finances/tree/spring--jackson-init-bypass/backend
The project in this state causes the error. Run ./gradlew server-standalone:run.
Complete error log
The errors I get are the following:
2017-11-30 17:15:54,475 | ERROR | main | o.springframework.boot.SpringApplication | Application startup failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:137)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233)
at com.github.adeynack.finances.backend.serverStandalone.FinancesServerStandalone.main(FinancesServerStandalone.kt:10)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:114)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:81)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:527)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:185)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:161)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:134)
... 8 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'httpPutFormContentFilter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter]: Factory method 'httpPutFormContentFilter' threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1249)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1098)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$83/517355658.getObject(Unknown Source)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:228)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:182)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:177)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:159)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:80)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:232)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:219)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext$$Lambda$126/1009916891.onStartup(Unknown Source)
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:54)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
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:745)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter]: Factory method 'httpPutFormContentFilter' threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:186)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:575)
... 26 common frames omitted
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException
at org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.<init>(AllEncompassingFormHttpMessageConverter.java:67)
at org.springframework.web.filter.HttpPutFormContentFilter.<init>(HttpPutFormContentFilter.java:63)
at org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter.<init>(OrderedHttpPutFormContentFilter.java:29)
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.httpPutFormContentFilter(WebMvcAutoConfiguration.java:161)
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$$EnhancerBySpringCGLIB$$f9ae12ce.CGLIB$httpPutFormContentFilter$1(<generated>)
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$$EnhancerBySpringCGLIB$$f9ae12ce$$FastClassBySpringCGLIB$$60a40e61.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$$EnhancerBySpringCGLIB$$f9ae12ce.httpPutFormContentFilter(<generated>)
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:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:155)
... 27 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException
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)
... 41 common frames omitted
Gradle file
I was able to recreate the conditions of this situation with this Gradle build file.
buildscript {
ext {
kotlin_version = '1.1.51'
spring_boot_version = '2.0.0.M5'
junit_version = '5.0.1'
jackson_version = '2.7.9' // has to match Moneydance included Jackson version
}
repositories {
mavenCentral()
jcenter()
maven { url 'https://repo.spring.io/libs-milestone' } // remove when using a stable version of Spring Boot 2.x
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.1'
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_version"
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'idea'
apply plugin: 'org.junit.platform.gradle.plugin'
// apply plugin: 'org.springframework.boot' // causes problems with Spring Boot 2. Unable to compile sub-projects.
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
jcenter()
maven { url 'https://repo.spring.io/libs-milestone' }
}
dependencies {
//
// PRODUCTION
//
// Kotlin and language extensions
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
// Spring
compile("org.springframework.boot:spring-boot-starter-web:$spring_boot_version") {
// Totally excluding Jackson (version conflict between version included in Moneydance and the one used in SpringBoot
exclude group: 'com.fasterxml.jackson.core'
exclude group: 'com.fasterxml.jackson.datatype'
exclude group: 'com.fasterxml.jackson.module'
}
compile "com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version"
//
// TEST
//
// JUnit
testCompile("org.junit.jupiter:junit-jupiter-api:$junit_version")
testRuntime("org.junit.jupiter:junit-jupiter-engine:$junit_version")
}
compileKotlin {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
}
junitPlatform {
platformVersion '1.0.0'
}
}
The not-found class which causes the exception is InvalidDefinitionException
nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException
I found out that InvalidDefinitionException class exists in Jackson since 2.9 as you can see here: InvalidDefinitionException
So I changed the jackson_version value to 2.9.2 (latest) in build.gradle and tried to run the project as you described and the project started to run with no exception.
Now to exclude Jackson you can still use this:
#SpringBootApplication(
exclude = arrayOf(JacksonAutoConfiguration::class)
)
I have developed a batch processing program using Spring Boot 1.4.2, which takes a long time (about 5 hours) to execute. After about 5 hours passes since the program launches, it finishes execution with an error message below:
20:49:01.324 ERROR o.s.boot.SpringApplication - Application startup failed
java.lang.NoClassDefFoundError: org/springframework/util/StopWatch$TaskInfo
at org.springframework.util.StopWatch.stop(StopWatch.java:146)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:318)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
at com.example.Main.main(Main.java:25)
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.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58)
Caused by: java.lang.ClassNotFoundException: org.springframework.util.StopWatch$TaskInfo
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 common frames omitted
Exception in thread "main" java.lang.reflect.InvocationTargetException
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.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/SpringBootExceptionHandler
at org.springframework.boot.SpringApplication.getSpringBootExceptionHandler(SpringApplication.java:903)
at org.springframework.boot.SpringApplication.registerLoggedException(SpringApplication.java:850)
at org.springframework.boot.SpringApplication.reportFailure(SpringApplication.java:840)
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:816)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
at jp.co.cyberagent.leeds.article_batches.ArticleBatchesApplication.main(ArticleBatchesApplication.java:25)
... 8 more
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringBootExceptionHandler
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 16 more
It seems that I am missing some dependencies on Spring Framework, but I don't know what I really need.
Here's my build.gradle.
buildscript {
ext {
springBootVersion = '1.4.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'article-batches'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven {
url "https://maven.ca-tools.org/content/groups/public/"
}
}
dependencies {
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1')
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.7'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.40'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'
compile group: 'org.mybatis', name: 'mybatis-typehandlers-jsr310', version: '1.0.1'
testCompile('org.springframework.boot:spring-boot-starter-test')
}
I solved the problem by myself. My main process was written in CommandLineRunner#run method, but it is wrong way to write main process in run method as this comment says in another question.
I followed the comment and wrote my main process like below, then the problem has gone away.
#SpringBootApplication
public class Main {
public static void main(String[] args) {
final ConfigurableApplicationContext context = SpringApplication.run(Main.class, args);
final AppBean app = context.getBean(AppBean.class);
app.run(args);
}
}
I am using com.fasterxml.jackson.core:jackson-annotations:2.6.0 in my gradle project. Since adding com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.6.0 to my project build file I have been getting this exception while running my gradle project. Here is the stack trace of my error.
Caused by: org.springframework.beans.BeanInstantiationException:
Failed to instantiate
[org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]:
Constructor threw exception; nested exception is
java.lang.NoSuchMethodError:
com.fasterxml.jackson.annotation.JsonFormat$Value.empty()Lcom/fasterxml/jackson/annotation/JsonFormat$Value;
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1098)
... 117 more Caused by: java.lang.NoSuchMethodError:
com.fasterxml.jackson.annotation.JsonFormat$Value.empty()Lcom/fasterxml/jackson/annotation/JsonFormat$Value;
at
com.fasterxml.jackson.databind.cfg.MapperConfig.(MapperConfig.java:50)
at
com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:535)
at
com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:452)
at
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:553)
at
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.(MappingJackson2HttpMessageConverter.java:57)
at
org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.(AllEncompassingFormHttpMessageConverter.java:61)
at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.(RequestMappingHandlerAdapter.java:187)
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:422)
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 119 more Nested in
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter':
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate
[org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]:
Constructor threw exception; nested exception is
java.lang.NoSuchMethodError:
com.fasterxml.jackson.annotation.JsonFormat$Value.empty()Lcom/fasterxml/jackson/annotation/JsonFormat$Value;:
java.lang.NoSuchMethodError:
com.fasterxml.jackson.annotation.JsonFormat$Value.empty()Lcom/fasterxml/jackson/annotation/JsonFormat$Value;
at
com.fasterxml.jackson.databind.cfg.MapperConfig.(MapperConfig.java:50)
at
com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:535)
at
com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:452)
at
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:553)
at
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.(MappingJackson2HttpMessageConverter.java:57)
at
org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.(AllEncompassingFormHttpMessageConverter.java:61)
at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.(RequestMappingHandlerAdapter.java:187)
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:422)
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1098)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at
org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
at
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1272)
at
org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at
org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489)
at
org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext.doStart(JettyPluginWebAppContext.java:112)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at
org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224) at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at
org.gradle.api.plugins.jetty.internal.Jetty6PluginServer.start(Jetty6PluginServer.java:111)
at
org.gradle.api.plugins.jetty.AbstractJettyRunTask.startJettyInternal(AbstractJettyRunTask.java:238)
at
org.gradle.api.plugins.jetty.AbstractJettyRunTask.startJetty(AbstractJettyRunTask.java:191)
at
org.gradle.api.plugins.jetty.AbstractJettyRunTask.start(AbstractJettyRunTask.java:162)
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:497) at
org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) at
org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227)
at
org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at
org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at
org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
at
org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at
org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at
org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at
org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at
org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at
org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at
org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at
org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at
org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
at
org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
at
org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
at
org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
at
org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
at
org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
at
org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
at
org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at
org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
at
org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
at
org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at
org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at
org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
at
org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
at org.gradle.internal.Factories$1.create(Factories.java:22) at
org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
at
org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
at
org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
at
org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
at
org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
at
org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
at
org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
at
org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
at
org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:46)
at
org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at
org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58)
at
org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at
org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
at
org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at
org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
at
org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
at
org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
at
org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at
org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38) at
org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
at
org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
at
org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at
org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
at
org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at
org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
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:745)
I have used not used #JsonFormat in my class. But I do have JsonSerializer and JsonDeserializer annotations using two classes for serializing and deserializing my ZonedDateTime to and from Json in UTC. I am doing this Serialization and deserialization for first time so please give any suggestions.
Here is my gradle file code:
apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'jetty' apply plugin: 'maven' apply plugin: 'war'
ext { springVersion = "4.2.4.RELEASE" springSecurityVersion = "4.0.3.RELEASE" }
repositories { mavenLocal() mavenCentral()
/* maven {
url "http://repo.typesafe.com/typesafe/releases/"
} */ }
configurations.all { exclude group: "commons-logging", module: "commons-logging" exclude group: "log4j", module: "log4j" }
dependencies { compile 'org.slf4j:jcl-over-slf4j:1.7.12' compile 'ch.qos.logback:logback-classic:1.1.3' compile "org.springframework:spring-core:$springVersion" compile "org.springframework:spring-context:$springVersion"
compile ("org.springframework:spring-web:$springVersion"){
exclude group: "com.fasterxml.jackson.core" } compile ("org.springframework:spring-webmvc:$springVersion"){
exclude group: "com.fasterxml.jackson.core" } compile "org.springframework:spring-orm:$springVersion" compile "org.springframework.security:spring-security-web:$springSecurityVersion" compile "org.springframework.security:spring-security-config:$springSecurityVersion"
compile "org.aspectj:aspectjrt:1.7.4"
compile "org.hibernate:hibernate-core:4.3.6.Final" compile "org.hibernate:hibernate-entitymanager:4.3.6.Final" compile "javax.servlet:javax.servlet-api:3.1.0" compile "org.javassist:javassist:3.15.0-GA" compile "mysql:mysql-connector-java:5.1.31"
compile "org.hsqldb:hsqldb:2.3.2"
compile "commons-dbcp:commons-dbcp:1.2.2" compile "org.apache.commons:commons-lang3:3.4" compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.0' compile 'com.fasterxml.jackson.core:jackson-core:2.7.0' compile 'com.fasterxml.jackson.core:jackson-databind:2.7.0' compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.7.0'
compile "net.sf.ehcache:ehcache-core:2.6.9" compile "org.hibernate:hibernate-ehcache:4.3.5.Final" compile "com.h2database:h2:1.4.177" compile "com.google.code.gson:gson:2.6.2"
testCompile ("junit:junit:4.12"){
exclude group: "org.hamcrest" } testCompile "org.springframework:spring-test:$springVersion" testCompile "org.easetech:easytest-core:1.4.0" testCompile "org.mockito:mockito-core:1.9.5" testCompile "org.hamcrest:hamcrest-all:1.3" testCompile "com.jayway.jsonpath:json-path:2.2.0" testCompile "com.jayway.jsonpath:json-path-assert:2.2.0"
testRuntime "org.hsqldb:hsqldb:2.3.2" }
Check your project dependencies. You might be using incompatible library versions. The version 2.7 has the method empty() and the version 2.6 not.
http://fasterxml.github.io/jackson-annotations/javadoc/2.6/com/fasterxml/jackson/annotation/JsonFormat.Value.html
http://fasterxml.github.io/jackson-annotations/javadoc/2.7.0-rc1/com/fasterxml/jackson/annotation/JsonFormat.Value.html
Try to upgrade to version 2.7.
I cleared up my issue when I just tried running task - gradle clean. I think some old project dependencies were lingering around till now. It was just a matter of cleaning the project. The project works fine now. :)
This is an alternative solution to the ones already given by #BeñatBermejo and #AkashRaveendran above. I'm glad Akash was able to get his system to work merely by cleaning up his environment, but I found that to be insufficient in my case.
The error was coming from jackson-databind, which I had in my pom as version 2.8.1. However, since I also have Spring involved, the jackson-databind dependencies, namely jackson-core, were still at 2.6.6.
All I had to do was remove the version specifier in my jackson-databind dependency. When I did that, Maven used the version named by Spring, 2.6.6, instead, which did not include the call to the JsonFormat$Value.empty().
If you need some jackson 2.7+ functionality, you can try specifying the higher version of jackson-core and any other dependencies of the jackson artifact you are trying to use.
However, with Spring involved, I would either see if you can get by with the lower jackson version it names, or see if Spring may have released a new version that includes the newer jackson libraries. Overriding Spring's dependency structure undermines one of the biggest reasons for using Spring in the first place: You get a more fully tested set of interrelated dependencies to build on right out of the box.
delete all jackson file from .m2 directory, make sure your all jackson pom i.e data-bind, annotation etc have same versions. if required downgrade your version i.e- jackson 2.7.3 working well rather than 2.10.3