Spring Cloud's #RefreshScope causes controller mapping collision with itself - spring
I'm trying to follow the tutorial at this link to test out Spring Cloud, but whenever I wire up my controller with #RefreshScope I get an error that the RequestMapping has already been taken. If I drop #RefreshScope things work great and I see the value from the config-server.
Any help would be appreciated. Thanks!
Code:
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#SpringBootApplication
public class WebCloudPoc {
public static void main(String[] args){
SpringApplication.run(WebCloudPoc.class, args);
}
#RestController
#RefreshScope
public static class ProjectNameRestController {
#Value("${configuration.projectName}")
private String projectName;
#RequestMapping("/project-name")
public String projectName() {
return this.projectName;
}
}
}
The log output is below:
Connected to the target VM, address: '127.0.0.1:55585', transport: 'socket'
2015-04-16 12:50:26.227 INFO 9744 --- [ main] com.example.web.WebCloudPoc : Starting WebCloudPoc on MacBook-Pro with PID 9744 (/Users/dave/workspace/7oaks/example/modules/example-web/target/classes started by dave in /Users/dave/workspace/7oaks/example)
2015-04-16 12:50:26.259 INFO 9744 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#4d154ccd: startup date [Thu Apr 16 12:50:26 MDT 2015]; root of context hierarchy
2015-04-16 12:50:26.608 INFO 9744 --- [ main] com.example.web.WebCloudPoc : Started WebCloudPoc in 0.65 seconds (JVM running for 1.101)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.1.RELEASE)
2015-04-16 12:50:26.908 INFO 9744 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource [name='applicationConfig: [file:/Users/dave/workspace/7oaks/example/modules/sysops/src/main/resources/test/demo.app.properties]']]]
2015-04-16 12:50:26.919 INFO 9744 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6a1d204a: startup date [Thu Apr 16 12:50:26 MDT 2015]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#4d154ccd
2015-04-16 12:50:27.409 INFO 9744 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2015-04-16 12:50:27.471 INFO 9744 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'infoEndpoint': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration; factoryMethodName=infoEndpoint; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$InfoEndpointRebinderConfiguration; factoryMethodName=infoEndpoint; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/autoconfigure/RefreshAutoConfiguration$InfoEndpointRebinderConfiguration.class]]
2015-04-16 12:50:27.556 INFO 9744 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=dd9ead28-6b26-31d0-803c-8df18aadded5
2015-04-16 12:50:27.576 INFO 9744 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$ConfigurationPropertiesRebinderConfiguration' of type [class org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$ConfigurationPropertiesRebinderConfiguration$$EnhancerBySpringCGLIB$$de7234f0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-04-16 12:50:27.818 INFO 9744 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8081 (http)
2015-04-16 12:50:27.966 INFO 9744 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2015-04-16 12:50:27.967 INFO 9744 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.15
2015-04-16 12:50:28.033 INFO 9744 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2015-04-16 12:50:28.033 INFO 9744 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1114 ms
2015-04-16 12:50:28.323 INFO 9744 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-04-16 12:50:28.327 INFO 9744 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'metricFilter' to: [/*]
2015-04-16 12:50:28.327 INFO 9744 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-04-16 12:50:28.327 INFO 9744 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2015-04-16 12:50:28.327 INFO 9744 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-04-16 12:50:28.327 INFO 9744 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*]
2015-04-16 12:50:28.531 INFO 9744 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6a1d204a: startup date [Thu Apr 16 12:50:26 MDT 2015]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#4d154ccd
2015-04-16 12:50:28.577 INFO 9744 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/project-name],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName()
2015-04-16 12:50:28.581 WARN 9744 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'com.example.web.WebCloudPoc$ProjectNameRestController' bean method
public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName()
to {[/project-name],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'webCloudPoc.ProjectNameRestController' bean method
public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName() mapped.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at com.example.web.WebCloudPoc.main(WebCloudPoc.java:14)
Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'com.example.web.WebCloudPoc$ProjectNameRestController' bean method
public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName()
to {[/project-name],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'webCloudPoc.ProjectNameRestController' bean method
public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName() mapped.
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:215)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:187)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:147)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:126)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:126)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
... 15 common frames omitted
2015-04-16 12:50:28.583 INFO 9744 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2015-04-16 12:50:28.589 INFO 9744 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/ant-javafx.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/dt.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/javafx-mx.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/jconsole.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/sa-jdi.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/tools.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/charsets.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/deploy.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/javaws.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jce.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jfr.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jfxswt.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jsse.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/management-agent.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/plugin.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/resources.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/rt.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/ext/cldrdata.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/ext/dnsns.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/ext/jfxrt.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/ext/localedata.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/ext/nashorn.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/ext/sunec.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/ext/zipfs.jar, file:/Users/dave/workspace/7oaks/example/modules/example-web/target/classes/, file:/Users/dave/workspace/7oaks/example/modules/example-common/target/classes/, file:/Users/dave/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.2.1.RELEASE/spring-boot-starter-web-1.2.1.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/boot/spring-boot-starter/1.2.1.RELEASE/spring-boot-starter-1.2.1.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/boot/spring-boot/1.2.1.RELEASE/spring-boot-1.2.1.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.2.1.RELEASE/spring-boot-autoconfigure-1.2.1.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.2.1.RELEASE/spring-boot-starter-logging-1.2.1.RELEASE.jar, file:/Users/dave/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.8/jcl-over-slf4j-1.7.8.jar, file:/Users/dave/.m2/repository/org/slf4j/slf4j-api/1.7.8/slf4j-api-1.7.8.jar, file:/Users/dave/.m2/repository/org/slf4j/jul-to-slf4j/1.7.8/jul-to-slf4j-1.7.8.jar, file:/Users/dave/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.8/log4j-over-slf4j-1.7.8.jar, file:/Users/dave/.m2/repository/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar, file:/Users/dave/.m2/repository/org/yaml/snakeyaml/1.14/snakeyaml-1.14.jar, file:/Users/dave/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.2.1.RELEASE/spring-boot-starter-tomcat-1.2.1.RELEASE.jar, file:/Users/dave/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.0.15/tomcat-embed-core-8.0.15.jar, file:/Users/dave/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.0.15/tomcat-embed-el-8.0.15.jar, file:/Users/dave/.m2/repository/org/apache/tomcat/embed/tomcat-embed-logging-juli/8.0.15/tomcat-embed-logging-juli-8.0.15.jar, file:/Users/dave/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.0.15/tomcat-embed-websocket-8.0.15.jar, file:/Users/dave/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.4.4/jackson-databind-2.4.4.jar, file:/Users/dave/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.4.4/jackson-annotations-2.4.4.jar, file:/Users/dave/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.4.4/jackson-core-2.4.4.jar, file:/Users/dave/.m2/repository/org/hibernate/hibernate-validator/5.1.3.Final/hibernate-validator-5.1.3.Final.jar, file:/Users/dave/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/Users/dave/.m2/repository/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA.jar, file:/Users/dave/.m2/repository/com/fasterxml/classmate/1.0.0/classmate-1.0.0.jar, file:/Users/dave/.m2/repository/org/springframework/spring-core/4.1.4.RELEASE/spring-core-4.1.4.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/spring-web/4.1.4.RELEASE/spring-web-4.1.4.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/spring-aop/4.1.4.RELEASE/spring-aop-4.1.4.RELEASE.jar, file:/Users/dave/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/Users/dave/.m2/repository/org/springframework/spring-beans/4.1.4.RELEASE/spring-beans-4.1.4.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/spring-context/4.1.4.RELEASE/spring-context-4.1.4.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/spring-webmvc/4.1.4.RELEASE/spring-webmvc-4.1.4.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/spring-expression/4.1.4.RELEASE/spring-expression-4.1.4.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/1.2.1.RELEASE/spring-boot-starter-actuator-1.2.1.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/boot/spring-boot-actuator/1.2.1.RELEASE/spring-boot-actuator-1.2.1.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/cloud/spring-cloud-config-client/1.0.0.RELEASE/spring-cloud-config-client-1.0.0.RELEASE.jar, file:/Users/dave/.m2/repository/org/springframework/security/spring-security-crypto/3.2.5.RELEASE/spring-security-crypto-3.2.5.RELEASE.jar, file:/Users/dave/.m2/repository/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1.jar, file:/Applications/IntelliJ%20IDEA%2014.app/Contents/lib/idea_rt.jar]
2015-04-16 12:50:28.589 INFO 9744 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report enabled debug logging (start with --debug)
2015-04-16 12:50:28.590 ERROR 9744 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'com.example.web.WebCloudPoc$ProjectNameRestController' bean method
public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName()
to {[/project-name],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'webCloudPoc.ProjectNameRestController' bean method
public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName() mapped.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at com.example.web.WebCloudPoc.main(WebCloudPoc.java:14)
Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'com.example.web.WebCloudPoc$ProjectNameRestController' bean method
public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName()
to {[/project-name],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'webCloudPoc.ProjectNameRestController' bean method
public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName() mapped.
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:215)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:187)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:147)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:126)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:126)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
... 15 common frames omitted
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'com.example.web.WebCloudPoc$ProjectNameRestController' bean method
2015-04-16 12:50:28.591public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName()
INFO 9744to {[/project-name],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'webCloudPoc.ProjectNameRestController' bean method
public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName() mapped.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
--- at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
[ Thread-1] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#4d154ccd: startup date [Thu Apr 16 12:50:26 MDT 2015]; root of context hierarchy
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at com.example.web.WebCloudPoc.main(WebCloudPoc.java:14)
Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'com.example.web.WebCloudPoc$ProjectNameRestController' bean method
public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName()
to {[/project-name],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'webCloudPoc.ProjectNameRestController' bean method
public java.lang.String com.example.web.WebCloudPoc$ProjectNameRestController.projectName() mapped.
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:215)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:187)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:147)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:126)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:126)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
... 15 more
Disconnected from the target VM, address: '127.0.0.1:55585', transport: 'socket'
#David Welch, I think it has to do with the way #Configuration classes (which #SpringBootApplication is) handle static inner classes. I moved the controller to a top level class and it all compiled and ran fine.
Related
Kotlin (Spring boot) - Error creating bean with name
I hope you can help me solve a problem, I am starting a project with spring boot (kotlin).Java 8 I have 2 similar codes with the same base of repositories, but one of them does not work send me an error that says "Error creating bean with name 'dgis_cat_municipiosController'" code that does not work code that does work I do not understand why the one in the first image does not work , if the only thing that changed was that instead of "AGE" I would look for "CVE_ENTIDAD". for more details I attach the 2 projects and their tables. projects First of all thank you ... "C:\Program Files\Java\jdk1.8.0_171\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.5\lib\idea_rt.jar=50814:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_171\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\rt.jar;C:\Users\Sistemas\IdeaProjects\tks\out\production\classes;C:\Users\Sistemas\IdeaProjects\tks\out\production\resources;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-data-jpa\2.0.5.RELEASE\c99b58e8ada11478aa5d0c3065745b7e887f094e\spring-boot-starter-data-jpa-2.0.5.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.0.5.RELEASE\52daa1f1509bd637a737206e54c06a17aabb9504\spring-boot-starter-web-2.0.5.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-kotlin\2.9.6\12c5482762e03c19a95187fd94c3611738dee604\jackson-module-kotlin-2.9.6.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk8\1.2.51\68faa6fb7e32a7665a6849f242bc621c3ed48101\kotlin-stdlib-jdk8-1.2.51.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.2.51\36b719a7b84452dd13eeec979d8c82bfb765c57d\kotlin-reflect-1.2.51.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-aop\2.0.5.RELEASE\6bc1e8bcc849772d48cae1e8278cd2b471361698\spring-boot-starter-aop-2.0.5.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-jdbc\2.0.5.RELEASE\9a5370acc7c5e17f4a00578211fbbd212b9a8329\spring-boot-starter-jdbc-2.0.5.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.0.5.RELEASE\d0052ded4733ceb1fb7d927238f22f9a92099227\spring-boot-starter-json-2.0.5.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\mysql\mysql-connector-java\5.1.47\9de4159aaf2d08817a276610b8114a825fca6cfd\mysql-connector-java-5.1.47.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.0.5.RELEASE\1f53487a373be18d064a5815e9bac9882ef15cdc\spring-boot-starter-2.0.5.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\javax.transaction\javax.transaction-api\1.2\d81aff979d603edd90dcd8db2abc1f4ce6479e3e\javax.transaction-api-1.2.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.hibernate\hibernate-core\5.2.17.Final\f2dc36470e7a2ffcf6106bb1625ecf5b54bb5f65\hibernate-core-5.2.17.Final.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-jpa\2.0.10.RELEASE\a6e644c363d050c6c90f078f4f0ac66892f60d54\spring-data-jpa-2.0.10.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aspects\5.0.9.RELEASE\dfb2da4c573391d8e8a482f08bdf4d38398e2bb0\spring-aspects-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.0.5.RELEASE\eaac8a5d73b45400bc88cd7f6b5c99b5f0d5e9b7\spring-boot-starter-tomcat-2.0.5.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.hibernate.validator\hibernate-validator\6.0.12.Final\478003e61b056c1f97840ba3e62ff31cdc89597\hibernate-validator-6.0.12.Final.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.0.9.RELEASE\c18346caaeb8dc648c4cc01874996fd9fef76664\spring-webmvc-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-web\5.0.9.RELEASE\1ea3aab93340849313fa74ec626ddaf1fff9ed8e\spring-web-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.9.6\456895fc91bf7180b216fead220373e6278230c9\jackson-datatype-jdk8-2.9.6.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.9.6\ea54f6193d224e5e5732bbd4262327eb465397c2\jackson-datatype-jsr310-2.9.6.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.9.6\129acd77a4b6ee30d62d3a0899b1344c8ec2bff8\jackson-module-parameter-names-2.9.6.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.9.6\cfa4f316351a91bfd95cb0644c6a2c95f52db1fc\jackson-databind-2.9.6.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.9.0\7c10d545325e3a6e72e06381afe469fd40eb701\jackson-annotations-2.9.0.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk7\1.2.51\a37c0066df119c02f034bf17159089b588ccc41a\kotlin-stdlib-jdk7-1.2.51.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.2.51\fa8127e505bff50fec291d0dd619d1bda5c619e0\kotlin-stdlib-1.2.51.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.0.5.RELEASE\e5588642799e0c0c04638e255c3d3f31ba400ff4\spring-boot-autoconfigure-2.0.5.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.0.5.RELEASE\19a4624cbd89a318d10c79f289c6c816043850fb\spring-boot-2.0.5.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.0.5.RELEASE\c353e0b9591d0765c687ff0a678478cbebfd5c23\spring-boot-starter-logging-2.0.5.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\javax.annotation\javax.annotation-api\1.3.2\934c04d3cfef185a8008e7bf34331b79730a9d43\javax.annotation-api-1.3.2.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.0.9.RELEASE\2501e55acb6c2e84667cda3f845d1d00a0dc4e05\spring-context-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.0.9.RELEASE\98003b099697fe46b6bdf18c7e3f66d7a1381060\spring-aop-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-orm\5.0.9.RELEASE\bb9265effd7c903f4cc1c98d16b4188b7827a1cc\spring-orm-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jdbc\5.0.9.RELEASE\2f38726ef2f5ecb72af7e915dac43177b01a8f53\spring-jdbc-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.0.10.RELEASE\64d4e58a2b16b9446d51a2650058d821a5bce98d\spring-data-commons-2.0.10.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-tx\5.0.9.RELEASE\d3a13fc3c56bdddd8144a686ed64f0cdb3ad7305\spring-tx-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.0.9.RELEASE\65f56fdab1bb90ad059e314d2f2f4cf76f9bdbde\spring-beans-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.0.9.RELEASE\1f9db5ff3a758102c0434cc3457aa47c50c39a4a\spring-expression-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.0.9.RELEASE\9f9a828936d81afd49a603bda9cc1aed863a0d85\spring-core-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.19\2d998d3d674b172a588e54ab619854d073f555b5\snakeyaml-1.19.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.aspectj\aspectjweaver\1.8.13\ad94df2a28d658a40dc27bbaff6a1ce5fbf04e9b\aspectjweaver-1.8.13.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\com.zaxxer\HikariCP\2.7.9\a83113d2c091d0d0f853dad3217bd7df3beb6ae3\HikariCP-2.7.9.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.hibernate.common\hibernate-commons-annotations\5.0.1.Final\71e1cff3fcb20d3b3af4f3363c3ddb24d33c6879\hibernate-commons-annotations-5.0.1.Final.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.3.2.Final\3789d00e859632e6c6206adc0c71625559e6e3b0\jboss-logging-3.3.2.Final.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.hibernate.javax.persistence\hibernate-jpa-2.1-api\1.0.2.Final\52afb5762c704a6b586e27742470c08f91877fc1\hibernate-jpa-2.1-api-1.0.2.Final.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.javassist\javassist\3.22.0-GA\3e83394258ae2089be7219b971ec21a8288528ad\javassist-3.22.0-GA.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\antlr\antlr\2.7.7\83cd2cd674a217ade95a4bb83a8a14f351f48bd0\antlr-2.7.7.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.jboss\jandex\2.0.3.Final\bfc4d6257dbff7a33a357f0de116be6ff951d849\jandex-2.0.3.Final.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\com.fasterxml\classmate\1.3.4\3d5f48f10bbe4eb7bd862f10c0583be2e0053c6\classmate-1.3.4.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\dom4j\dom4j\1.6.1\5d3ccc056b6f056dbf0dddfdf43894b9065a8f94\dom4j-1.6.1.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.3\7c4f3c474fb2c041d8028740440937705ebb473a\logback-classic-1.2.3.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.10.0\f7e631ccf49cfc0aefa4a2a728da7d374c05bd3c\log4j-to-slf4j-2.10.0.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.25\af5364cd6679bfffb114f0dec8a157aaa283b76\jul-to-slf4j-1.7.25.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.25\da76ca59f6a57ee3102f8f9bd9cee742973efa8a\slf4j-api-1.7.25.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\8.5.34\5f86906367c2540b21e6aeecc277d2ce9ec939b0\tomcat-embed-websocket-8.5.34.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\8.5.34\a038040d68a90397f95dd1e11b979fe364a5000f\tomcat-embed-core-8.5.34.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\8.5.34\be71a9a5bdd001db7cf97c47429eec0bdd3b7b88\tomcat-embed-el-8.5.34.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\javax.validation\validation-api\2.0.1.Final\cb855558e6271b1b32e716d24cb85c7f583ce09e\validation-api-2.0.1.Final.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.9.6\4e393793c37c77e042ccc7be5a914ae39251b365\jackson-core-2.9.6.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-common\1.2.51\e4a9d4b13ab19ed1e6531fce6df98e8cfa7f7301\kotlin-stdlib-common-1.2.51.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.jetbrains\annotations\13.0\919f0dfe192fb4e063e7dacadee7f8bb9a2672a9\annotations-13.0.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.0.9.RELEASE\bc3b5aaae53f0bc03647e53ecbd98a05b47a4e90\spring-jcl-5.0.9.RELEASE.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.3\864344400c3d4d92dfeb0a305dc87d953677c03c\logback-core-1.2.3.jar;C:\Users\Sistemas\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.10.0\fec5797a55b786184a537abd39c3fa1449d752d6\log4j-api-2.10.0.jar" com.tksys.tks.TksApplicationKt . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.5.RELEASE) 2018-09-24 11:12:34.463 INFO 6200 --- [ main] com.tksys.tks.TksApplicationKt : Starting TksApplicationKt on DESKTOP-FJIIFGM with PID 6200 (C:\Users\Sistemas\IdeaProjects\tks\out\production\classes started by Sistemas in C:\Users\Sistemas\IdeaProjects\tks) 2018-09-24 11:12:34.463 INFO 6200 --- [ main] com.tksys.tks.TksApplicationKt : No active profile set, falling back to default profiles: default 2018-09-24 11:12:34.525 INFO 6200 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#3c153a1: startup date [Mon Sep 24 11:12:34 CDT 2018]; root of context hierarchy 2018-09-24 11:12:36.244 INFO 6200 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$cd16ab20] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-09-24 11:12:36.697 INFO 6200 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2018-09-24 11:12:36.728 INFO 6200 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-09-24 11:12:36.728 INFO 6200 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34 2018-09-24 11:12:36.728 INFO 6200 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_171\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\xampp\php;C:\composer;C:\Program Files\Java\jdk-10.0.1\bin;C:\Ruby25-x64\bin;C:\Users\Sistemas\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\Sistemas\AppData\Roaming\Composer\vendor\bin;C:\Users\Sistemas\AppData\Local\GitHubDesktop\bin;.] 2018-09-24 11:12:36.838 INFO 6200 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-09-24 11:12:36.838 INFO 6200 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2313 ms 2018-09-24 11:12:36.885 INFO 6200 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/] 2018-09-24 11:12:36.900 INFO 6200 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-09-24 11:12:36.900 INFO 6200 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-09-24 11:12:36.900 INFO 6200 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-09-24 11:12:36.900 INFO 6200 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-09-24 11:12:37.057 INFO 6200 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2018-09-24 11:12:37.275 INFO 6200 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2018-09-24 11:12:37.322 INFO 6200 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-09-24 11:12:37.353 INFO 6200 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-09-24 11:12:37.416 INFO 6200 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final} 2018-09-24 11:12:37.416 INFO 6200 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2018-09-24 11:12:37.463 INFO 6200 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 2018-09-24 11:12:37.572 INFO 6200 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect 2018-09-24 11:12:38.041 INFO 6200 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2018-09-24 11:12:38.559 WARN 6200 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dgis_cat_municipiosController' defined in file [C:\Users\Sistemas\IdeaProjects\tks\out\production\classes\com\tksys\tks\controller\Dgis_cat_municipiosController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dgis_cat_municipiosServiceImpl' defined in file [C:\Users\Sistemas\IdeaProjects\tks\out\production\classes\com\tksys\tks\services\impl\Dgis_cat_municipiosServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dgis_cat_municipiosRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.tksys.tks.repository.Dgis_cat_municipiosRepository.findAllByCve_entidad(int)! No property cve found for type Dgis_cat_municipios! 2018-09-24 11:12:38.559 INFO 6200 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2018-09-24 11:12:38.559 INFO 6200 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2018-09-24 11:12:38.559 INFO 6200 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. 2018-09-24 11:12:38.559 INFO 6200 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-09-24 11:12:38.575 INFO 6200 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2018-09-24 11:12:38.575 ERROR 6200 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dgis_cat_municipiosController' defined in file [C:\Users\Sistemas\IdeaProjects\tks\out\production\classes\com\tksys\tks\controller\Dgis_cat_municipiosController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dgis_cat_municipiosServiceImpl' defined in file [C:\Users\Sistemas\IdeaProjects\tks\out\production\classes\com\tksys\tks\services\impl\Dgis_cat_municipiosServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dgis_cat_municipiosRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.tksys.tks.repository.Dgis_cat_municipiosRepository.findAllByCve_entidad(int)! No property cve found for type Dgis_cat_municipios! at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1124) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] at com.tksys.tks.TksApplicationKt.main(TksApplication.kt:13) [classes/:na] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dgis_cat_municipiosServiceImpl' defined in file [C:\Users\Sistemas\IdeaProjects\tks\out\production\classes\com\tksys\tks\services\impl\Dgis_cat_municipiosServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dgis_cat_municipiosRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.tksys.tks.repository.Dgis_cat_municipiosRepository.findAllByCve_entidad(int)! No property cve found for type Dgis_cat_municipios! at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1124) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] ... 70 common frames omitted Process finished with exit code 1
The exception you get is pretty clear: java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.tksys.tks.repository.Dgis_cat_municipiosRepository.findAllByCve_entidad(int)! No property cve found for type Dgis_cat_municipios! It seems that JPA repository has problems with the _ sign in method signatures. So please remove all _ in you class, attribute and method names. This should solve your problem.
Spring Boot with h2 database
I currently try to follow a tutorial, but having issues at the point I add some in memory persistence with h2 to the application. I found some comments on the autoconfiguration of h2 in Spring Boot which say, that the only thing to do is to add the dependency to the pom. Is there any further configuration I have to do manually? I get the following exceptions: . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.1.RELEASE) 2017-02-26 23:53:08.854 INFO 30704 --- [ main] com.example.GuestbookBackendApplication : Starting GuestbookBackendApplication on Deniss-MacBook-Pro.local with PID 30704 (/Users/denisholdeew/Documents/workspace/eclipseneon/guestbook-backend/target/classes started by denisholdeew in /Users/denisholdeew/Documents/workspace/eclipseneon/guestbook-backend) 2017-02-26 23:53:08.860 INFO 30704 --- [ main] com.example.GuestbookBackendApplication : No active profile set, falling back to default profiles: default 2017-02-26 23:53:08.984 INFO 30704 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#2145433b: startup date [Sun Feb 26 23:53:08 CET 2017]; root of context hierarchy 2017-02-26 23:53:11.114 INFO 30704 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration' of type [class org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-02-26 23:53:11.246 INFO 30704 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'validator' of type [class org.springframework.validation.beanvalidation.LocalValidatorFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-02-26 23:53:11.327 INFO 30704 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$7dab0267] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-02-26 23:53:11.861 INFO 30704 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2017-02-26 23:53:11.890 INFO 30704 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat 2017-02-26 23:53:11.892 INFO 30704 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.11 2017-02-26 23:53:12.121 INFO 30704 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2017-02-26 23:53:12.121 INFO 30704 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3144 ms 2017-02-26 23:53:12.333 INFO 30704 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2017-02-26 23:53:12.339 INFO 30704 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2017-02-26 23:53:12.340 INFO 30704 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2017-02-26 23:53:12.340 INFO 30704 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2017-02-26 23:53:12.340 INFO 30704 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2017-02-26 23:53:12.406 WARN 30704 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active). 2017-02-26 23:53:12.420 INFO 30704 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2017-02-26 23:53:12.427 ERROR 30704 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Cannot determine embedded database driver class for database type NONE Action: If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active). pom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>guestbook-backend</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>guestbook-backend</name> <description>Second demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> Entity: #Entity public class GuestbookEntry { #Id #GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String title; private String comment; private String commenter; private Date date = new Date(); public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getComment() { return comment; } public void setComment(String comment) { this.comment = comment; } public String getCommenter() { return commenter; } public void setCommenter(String commenter) { this.commenter = commenter; } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } } Repository: package com.example; import org.springframework.data.jpa.repository.JpaRepository; public interface GuestbookRepository extends JpaRepository<GuestbookEntry, Long> { } Rest Controller: #Controller #RequestMapping("/guestbook") public class GuestbookController { #Autowired private GuestbookRepository repository; #RequestMapping(value="/", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> getEntries() { // 1. Daten laden List<GuestbookEntry> entries = repository.findAll(); // 2. Daten zurückgeben return ResponseEntity.ok(entries); } #RequestMapping(value="/", method=RequestMethod.PUT, consumes=MediaType.APPLICATION_JSON_VALUE, produces=MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> create(#RequestBody GuestbookEntry entry) { // 1. Speichern entry = repository.save(entry); // 2. Zurückgeben return ResponseEntity.ok(entry); } } +++++++++++++++++++ UPDATE: When commenting out the explicit hibernate dependencies in the pom.xml and run maven clean install, it still doesn't work. I get the following output with maven clean install (unfortunately I had to delete parts of it because it has over 90000 characters and only 30k are allowed here): . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.1.RELEASE) 2017-02-27 21:48:27.161 INFO 31629 --- [ main] c.e.GuestbookBackendApplicationTests : Starting GuestbookBackendApplicationTests on somes-MacBook-Pro.local with PID 31629 (started by somename in /Users/somename/Documents/workspace/eclipseneon/guestbook-backend) 2017-02-27 21:48:27.162 INFO 31629 --- [ main] c.e.GuestbookBackendApplicationTests : No active profile set, falling back to default profiles: default 2017-02-27 21:48:29.225 INFO 31629 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Refreshing org.springframework.web.context.support.GenericWebApplicationContext#1cbb87f3: startup date [Mon Feb 27 21:48:29 CET 2017]; root of context hierarchy 2017-02-27 21:48:51.004 INFO 31629 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration' of type [class org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-02-27 21:48:54.527 INFO 31629 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'validator' of type [class org.springframework.validation.beanvalidation.LocalValidatorFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-02-27 21:48:54.650 INFO 31629 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$a59e0480] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-02-27 21:48:55.256 WARN 31629 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active). 2017-02-27 21:48:55.280 INFO 31629 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2017-02-27 21:48:55.295 ERROR 31629 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Cannot determine embedded database driver class for database type NONE Action: If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active). 2017-02-27 21:48:55.576 ERROR 31629 --- [ main] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener#8b96fde] to prepare test instance [com.example.GuestbookBackendApplicationTests#4f8caaf3] java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12] at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283) [surefire-junit4-2.18.1.jar:2.18.1] at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173) [surefire-junit4-2.18.1.jar:2.18.1] at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) [surefire-junit4-2.18.1.jar:2.18.1] at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128) [surefire-junit4-2.18.1.jar:2.18.1] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203) [surefire-booter-2.18.1.jar:2.18.1] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155) [surefire-booter-2.18.1.jar:2.18.1] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) [surefire-booter-2.18.1.jar:2.18.1] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active). at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:372) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) ~[spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) ~[spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE] at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120) ~[spring-boot-test-1.5.1.RELEASE.jar:1.5.1.RELEASE] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE] ... 26 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is .... Results : Tests in error: GuestbookBackendApplicationTests.contextLoads » IllegalState Failed to load Ap... Tests run: 1, Failures: 0, Errors: 1, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:58 min [INFO] Finished at: 2017-02-27T21:48:56+01:00 [INFO] Final Memory: 26M/120M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project guestbook-backend: There are test failures. [ERROR] [ERROR] Please refer to /Users/somename/Documents/workspace/eclipseneon/guestbook-backend/target/surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException somes-MacBook-Pro:guestbook-backend somename$
So I finally figured out what was wrong. H2 was not within the project classpath, so I had to add it manually. You can download it here: h2-db Then add it to your classpath with right clicking on your project->Properties->Java build path->Libraries->Add external jar. But I don't know, if it's a good way to solve it or if it should be somehow handled by Spring Boot or the Maven dependency automatically.
Looks to me that you're missing the H2 dependency itself. You don't need to include the version using spring-boot as you will inherit it from the spring-boot parent pom. Just include the following in your pom.xml. <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency>
Using hibernate for an exsisting Spring batch database
I'm working on a batch project that uses the spring batch core library the library uses jdbcTemplate to persist jobs meta data and i'm trying to use hibernate in order to read the data about a specific job so far so good I've created all the domain entities and the jpa repositoris of spring batch pom.xml <properties> <hibernate.version>4.3.6.Final</hibernate.version> <HikariCP.version>2.4.5</HikariCP.version> <postgresql.version>9.3-1102-jdbc41</postgresql.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-batch</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </dependency> <dependency> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> <version>${HikariCP.version}</version> <exclusions> <exclusion> <artifactId>tools</artifactId> <groupId>com.sun</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>${postgresql.version}</version> </dependency> <!--jackson--> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-hibernate4</artifactId> <version>${jackson.version}</version> </dependency> </dependencies> DatabaseConfiguration.java import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.orm.jpa.EntityScan; import org.springframework.context.ApplicationContextException; import org.springframework.context.EnvironmentAware; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.transaction.annotation.EnableTransactionManagement; import javax.sql.DataSource; import java.util.Arrays; #Configuration #EnableJpaRepositories(basePackages = "com.ben.repository") #EntityScan(basePackages = {"com.ben.domain"}) #EnableTransactionManagement public class DatabaseConfiguration implements EnvironmentAware { private final org.slf4j.Logger log = LoggerFactory.getLogger(DatabaseConfiguration.class); #Autowired Environment env; private RelaxedPropertyResolver propertyResolver; #Override public void setEnvironment(Environment env) { this.env = env; this.propertyResolver = new RelaxedPropertyResolver(env, "spring.datasource."); } #Bean public DataSource dataSource(){ log.debug("Configuring Datasource"); if (propertyResolver.getProperty("url") == null && propertyResolver.getProperty("databaseName") == null) { log.error("Your database connection pool configuration is incorrect! The application" + "cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(propertyResolver.getProperty("dataSourceClassName")); if (propertyResolver.getProperty("url") == null || "".equals(propertyResolver.getProperty("url"))) { config.addDataSourceProperty("databaseName", propertyResolver.getProperty("databaseName")); config.addDataSourceProperty("serverName", propertyResolver.getProperty("serverName")); } else { config.addDataSourceProperty("url", propertyResolver.getProperty("url")); } config.addDataSourceProperty("user", propertyResolver.getProperty("username")); config.addDataSourceProperty("password", propertyResolver.getProperty("password")); return new HikariDataSource(config); } #Bean public Hibernate4Module hibernate4Module() { return new Hibernate4Module(); } } whenever I run the application, spring throws a strange exception, telling that a bean cration fails org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class the full output 2016-05-03 14:35:27.844 INFO 28744 --- [ main] com.ben.batch.Application : Starting Application on med with PID 28744 (/home/med/workplace/ben-batch/target/classes started by med in /home/med/workplace/ben-batch) 2016-05-03 14:35:27.875 INFO 28744 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#548ad73b: startup date [Tue May 03 14:35:27 CEST 2016]; root of context hierarchy 2016-05-03 14:35:28.403 INFO 28744 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'jobRepository': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration; factoryMethodName=jobRepository; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.ModularBatchConfiguration; factoryMethodName=jobRepository; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.class]] 2016-05-03 14:35:28.403 INFO 28744 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'jobLauncher': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration; factoryMethodName=jobLauncher; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.ModularBatchConfiguration; factoryMethodName=jobLauncher; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.class]] 2016-05-03 14:35:28.404 INFO 28744 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'transactionManager': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.ModularBatchConfiguration; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.class]] 2016-05-03 14:35:28.404 INFO 28744 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'jobExplorer': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration; factoryMethodName=jobExplorer; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.ModularBatchConfiguration; factoryMethodName=jobExplorer; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.class]] 2016-05-03 14:35:28.554 INFO 28744 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]] 2016-05-03 14:35:28.820 WARN 28744 --- [ main] o.s.c.a.ConfigurationClassEnhancer : #Bean method ScopeConfiguration.stepScope is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as #Autowired, #Resource and #PostConstruct within the method's declaring #Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see #Bean javadoc for complete details 2016-05-03 14:35:28.830 WARN 28744 --- [ main] o.s.c.a.ConfigurationClassEnhancer : #Bean method ScopeConfiguration.jobScope is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as #Autowired, #Resource and #PostConstruct within the method's declaring #Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see #Bean javadoc for complete details 2016-05-03 14:35:29.049 INFO 28744 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$77d3faef] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2016-05-03 14:35:29.065 INFO 28744 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2016-05-03 14:35:29.073 INFO 28744 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2016-05-03 14:35:29.076 INFO 28744 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2016-05-03 14:35:29.295 INFO 28744 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2016-05-03 14:35:29.421 INFO 28744 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat 2016-05-03 14:35:29.422 INFO 28744 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.15 2016-05-03 14:35:29.549 INFO 28744 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2016-05-03 14:35:29.550 INFO 28744 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1676 ms 2016-05-03 14:35:29.878 INFO 28744 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2016-05-03 14:35:29.881 INFO 28744 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2016-05-03 14:35:29.882 INFO 28744 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2016-05-03 14:35:29.922 INFO 28744 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Started. 2016-05-03 14:35:29.970 INFO 28744 --- [ main] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (Method org.postgresql.jdbc4.Jdbc4Connection.getNetworkTimeout() is not yet implemented.) 2016-05-03 14:35:30.061 INFO 28744 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2016-05-03 14:35:30.067 INFO 28744 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2016-05-03 14:35:30.073 WARN 28744 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691) at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) at com.ben.batch.Application.main(Application.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:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Caused by: java.lang.IncompatibleClassChangeError: Implementing class at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) 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) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildBootstrapServiceRegistry(EntityManagerFactoryBuilderImpl.java:484) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:206) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:186) at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider$1.<init>(SpringHibernateJpaPersistenceProvider.java:49) at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:49) at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562) ... 18 common frames omitted 2016-05-03 14:35:30.076 INFO 28744 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Close initiated... 2016-05-03 14:35:30.077 INFO 28744 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Closed. 2016-05-03 14:35:30.078 INFO 28744 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat 2016-05-03 14:35:30.083 WARN 28744 --- [ main] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'jobRegistrar' defined in class path resource [org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' is defined) 2016-05-03 14:35:30.084 ERROR 28744 --- [ main] o.s.boot.SpringApplication : Application startup failed Any idea would be much appreciated.
Spring Boot Rest App on GAE throws an exception cannot be cast to javax.persistence.EntityManagerFactory"
My Spring Boot Restservice App is running just fine in normal Spring App Context. But when I try to run it on Google App Engine the following Exception is thrown: Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.PlatformTransactionManager]: Factory method 'transactionManager' threw exception; nested exception is java.lang.ClassCastException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean$$EnhancerBySpringCGLIB$$1c05fbf5 cannot be cast to javax.persistence.EntityManagerFactory here is the stacktrace of my exception: D:\Progs\JAVA\jdk1.7.0_80\bin\java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:50742,suspend=y,server=n -javaagent:D:/Progs/appengine-java-sdk/lib/agent/appengine-agent.jar -Xbootclasspath/p:D:/Progs/appengine-java-sdk/lib/override/appengine-dev-jdk-overrides.jar -Dfile.encoding=windows-1252 -classpath "D:\Progs\appengine-java-sdk\lib\appengine-tools-api.jar;D:\Progs\JAVA\jdk1.7.0_80\lib\tools.jar;D:\Progs\IntelliJ IDEA 14.1.1\lib\idea_rt.jar" com.google.appengine.tools.development.DevAppServerMain -p 8080 --disable_update_check C:\Users\pk\Documents\ItelliJProjects\gps-trackman\target\gps-trackman-0.0.1-SNAPSHOT Connected to the target VM, address: '127.0.0.1:50742', transport: 'socket' Apr 18, 2015 11:38:05 AM java.util.prefs.WindowsPreferences <init> WARNUNG: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5. Apr 18, 2015 11:38:06 AM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml INFORMATION: Successfully processed C:\Users\pk\Documents\ItelliJProjects\gps-trackman\target\gps-trackman-0.0.1-SNAPSHOT\WEB-INF/appengine-web.xml Apr 18, 2015 11:38:06 AM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml INFORMATION: Successfully processed C:\Users\pk\Documents\ItelliJProjects\gps-trackman\target\gps-trackman-0.0.1-SNAPSHOT\WEB-INF/web.xml Apr 18, 2015 11:38:06 AM com.google.apphosting.utils.jetty.JettyLogger info INFORMATION: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger Connected to server Apr 18, 2015 11:38:07 AM com.google.apphosting.utils.jetty.JettyLogger info INFORMATION: jetty-6.1.x . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.2.3.RELEASE) Apr 18, 2015 11:38:09 AM com.google.appengine.tools.development.ApiProxyLocalImpl log INFORMATION: javax.servlet.ServletContext log: Initializing Spring embedded WebApplicationContext 2015-04-18 11:38:09.421 INFO ??? --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1429349889417 ms 2015-04-18 11:38:09.439 INFO ??? --- [ main] o.s.boot.SpringApplication : Starting application on KABUL with PID ??? (C:\Users\pk\Documents\ItelliJProjects\gps-trackman\target\gps-trackman-0.0.1-SNAPSHOT\WEB-INF\lib\spring-boot-1.2.3.RELEASE.jar started by pk in C:\Users\pk\Documents\ItelliJProjects\gps-trackman\target\gps-trackman-0.0.1-SNAPSHOT) 2015-04-18 11:38:09.529 INFO ??? --- [ main] onConfigNonEmbeddedWebApplicationContext : Refreshing org.springframework.boot.legacy.context.web.AnnotationConfigNonEmbeddedWebApplicationContext#73bad293: startup date [Sat Apr 18 11:38:09 CEST 2015]; root of context hierarchy 2015-04-18 11:38:14.349 INFO ??? --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]] 2015-04-18 11:38:14.627 INFO ??? --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'entityManagerFactory': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appConfig; factoryMethodName=entityManagerFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/pekam/AppConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=true; factoryBeanName=org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; factoryMethodName=entityManagerFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]] 2015-04-18 11:38:18.744 INFO ??? --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 2015-04-18 11:38:21.493 INFO ??? --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$563a5e93] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2015-04-18 11:38:21.629 INFO ??? --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2015-04-18 11:38:21.670 INFO ??? --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2015-04-18 11:38:21.691 INFO ??? --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2015-04-18 11:38:23.695 INFO ??? --- [ main] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: org.h2.Driver 2015-04-18 11:38:23.696 INFO ??? --- [ main] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: com.mysql.jdbc.Driver 2015-04-18 11:38:23.696 INFO ??? --- [ main] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: com.mysql.jdbc.Driver 2015-04-18 11:38:29.289 INFO ??? --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2015-04-18 11:38:29.371 INFO ??? --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2015-04-18 11:38:29.759 INFO ??? --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.8.Final} 2015-04-18 11:38:29.764 INFO ??? --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2015-04-18 11:38:29.770 INFO ??? --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2015-04-18 11:38:30.586 INFO ??? --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final} 2015-04-18 11:38:30.858 INFO ??? --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect 2015-04-18 11:38:31.435 INFO ??? --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory 2015-04-18 11:38:36.502 INFO ??? --- [ main] o.s.b.f.config.PropertiesFactoryBean : Loading properties file from class path resource [rest-default-messages.properties] 2015-04-18 11:38:37.111 WARN ??? --- [ main] onConfigNonEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [com/pekam/AppConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.PlatformTransactionManager]: Factory method 'transactionManager' threw exception; nested exception is java.lang.ClassCastException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean$$EnhancerBySpringCGLIB$$1c05fbf5 cannot be cast to javax.persistence.EntityManagerFactory at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139) at org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener.initWebApplicationContext(SpringBootContextLoaderListener.java:61) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) 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:1250) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) 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 com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:266) at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:288) at com.google.appengine.tools.development.AutomaticInstanceHolder.startUp(AutomaticInstanceHolder.java:26) at com.google.appengine.tools.development.AbstractModule.startup(AbstractModule.java:87) at com.google.appengine.tools.development.Modules.startup(Modules.java:105) at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:258) at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47) at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:213) at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:211) at java.security.AccessController.doPrivileged(Native Method) at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:211) at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:284) at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48) at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:226) at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:217) Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.PlatformTransactionManager]: Factory method 'transactionManager' threw exception; nested exception is java.lang.ClassCastException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean$$EnhancerBySpringCGLIB$$1c05fbf5 cannot be cast to javax.persistence.EntityManagerFactory at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) at org.springframework.beans.factory.support.ConstructorResolver$3.run(ConstructorResolver.java:582) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ... 42 common frames omitted Caused by: java.lang.ClassCastException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean$$EnhancerBySpringCGLIB$$1c05fbf5 cannot be cast to javax.persistence.EntityManagerFactory at com.pekam.AppConfig$$EnhancerBySpringCGLIB$$9c2ce662.entityManagerFactory(<generated>) at com.pekam.AppConfig.transactionManager(AppConfig.java:125) at com.pekam.AppConfig$$EnhancerBySpringCGLIB$$9c2ce662.CGLIB$transactionManager$2(<generated>) at com.pekam.AppConfig$$EnhancerBySpringCGLIB$$9c2ce662$$FastClassBySpringCGLIB$$97c35f17.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309) at com.pekam.AppConfig$$EnhancerBySpringCGLIB$$9c2ce662.transactionManager(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:130) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ... 45 common frames omitted 2015-04-18 11:38:37.125 INFO ??? --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2015-04-18 11:38:37.139 WARN ??? --- [ main] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' is defined) 2015-04-18 11:38:37.154 ERROR ??? --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [com/pekam/AppConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.PlatformTransactionManager]: Factory method 'transactionManager' threw exception; nested exception is java.lang.ClassCastException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean$$EnhancerBySpringCGLIB$$1c05fbf5 cannot be cast to javax.persistence.EntityManagerFactory at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139) at org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener.initWebApplicationContext(SpringBootContextLoaderListener.java:61) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) 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:1250) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) 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 com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:266) at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:288) at com.google.appengine.tools.development.AutomaticInstanceHolder.startUp(AutomaticInstanceHolder.java:26) at com.google.appengine.tools.development.AbstractModule.startup(AbstractModule.java:87) at com.google.appengine.tools.development.Modules.startup(Modules.java:105) at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:258) at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47) at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:213) at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:211) at java.security.AccessController.doPrivileged(Native Method) at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:211) at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:284) at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48) at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:226) at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:217) Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.PlatformTransactionManager]: Factory method 'transactionManager' threw exception; nested exception is java.lang.ClassCastException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean$$EnhancerBySpringCGLIB$$1c05fbf5 cannot be cast to javax.persistence.EntityManagerFactory at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) at org.springframework.beans.factory.support.ConstructorResolver$3.run(ConstructorResolver.java:582) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ... 42 common frames omitted Caused by: java.lang.ClassCastException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean$$EnhancerBySpringCGLIB$$1c05fbf5 cannot be cast to javax.persistence.EntityManagerFactory at com.pekam.AppConfig$$EnhancerBySpringCGLIB$$9c2ce662.entityManagerFactory(<generated>) at com.pekam.AppConfig.transactionManager(AppConfig.java:125) at com.pekam.AppConfig$$EnhancerBySpringCGLIB$$9c2ce662.CGLIB$transactionManager$2(<generated>) at com.pekam.AppConfig$$EnhancerBySpringCGLIB$$9c2ce662$$FastClassBySpringCGLIB$$97c35f17.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309) at com.pekam.AppConfig$$EnhancerBySpringCGLIB$$9c2ce662.transactionManager(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:130) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ... 45 common frames omitted here is my code of the package com.pekam; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaDialect; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; import javax.annotation.Resource; import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; #Configuration #ComponentScan("com.pekam") #EnableAutoConfiguration #EnableJpaRepositories public class AppConfig { #Resource Environment env; #Bean public DataSource MyDataSource() { //String str = com.pekam.Settings.this.dbUser; DriverManagerDataSource H2DataSource = new DriverManagerDataSource(); H2DataSource.setDriverClassName("org.h2.Driver"); H2DataSource.setUrl("jdbc:h2:file:h2\\db"); H2DataSource.setUsername("sa"); H2DataSource.setPassword(""); MsSqlDataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); DriverManagerDataSource MySqlDataSource = new DriverManagerDataSource(); MySqlDataSource.setDriverClassName("com.mysql.jdbc.Driver"); String url = null; MySqlDataSource.setDriverClassName("com.mysql.jdbc.Driver"); url = "jdbc:mysql://localhost:3306/test"; MySqlDataSource.setUsername("pk"); MySqlDataSource.setPassword("f7ka1"); MySqlDataSource.setUrl(url); return MySqlDataSource; } #Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); vendorAdapter.setShowSql(true); vendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQLDialect"); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setJpaDialect(new HibernateJpaDialect()); factory.setPackagesToScan("com.pekam"); factory.setDataSource(MyDataSource()); factory.afterPropertiesSet(); return factory.getObject(); } #Bean public PlatformTransactionManager transactionManager() { JpaTransactionManager txManager = new JpaTransactionManager(); txManager.setEntityManagerFactory(entityManagerFactory()); return txManager; } }
I was having the same problem today converting a part of a Spring application to a Spring Boot application. The problem was that Spring kept loading a default entityManagerFactory bean. In order to use my entityManagerFactory bean I had to return the instance of LocalContainerEntityManagerFactoryBean directly, instead of returning LocalContainerEntityManagerFactoryBean's getObject(): #Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); vendorAdapter.setShowSql(true); vendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQLDialect"); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setJpaDialect(new HibernateJpaDialect()); factory.setPackagesToScan("com.pekam"); factory.setDataSource(MyDataSource()); factory.afterPropertiesSet(); return factory; } and then in the configuration of the transactionManager bean call entityManagerFactory().getObject(): #Bean public PlatformTransactionManager transactionManager() { JpaTransactionManager txManager = new JpaTransactionManager(); txManager.setEntityManagerFactory(entityManagerFactory().getObject()); return txManager; }
spring boot mvc: failed after following the sample
I am following the link https://github.com/spring-guides/gs-serving-web-content After check out the files, import gs-serving-web-content/complete into IDEA, and run it. It runs successfully, but if I use http as following to access it then it failed. http://127.0.0.1:8080/greating The message is as below: com.intellij.rt.execution.application.AppMain hello.Application . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.1.9.RELEASE) 2014-11-24 21:07:15.891 INFO 8060 --- [ main] hello.Application : Starting Application on SomeHost with PID 8060 (/home/oracle/spring/gs-serving-web-content/complete/build/classes/main started by oracle in /home/oracle/spring/gs-serving-web-content/complete) 2014-11-24 21:07:15.933 INFO 8060 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#11c20519: startup date [Mon Nov 24 21:07:15 CST 2014]; root of context hierarchy 2014-11-24 21:07:16.864 INFO 8060 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]] 2014-11-24 21:07:17.878 INFO 8060 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8080 2014-11-24 21:07:18.132 INFO 8060 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat 2014-11-24 21:07:18.133 INFO 8060 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.56 2014-11-24 21:07:18.271 INFO 8060 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2014-11-24 21:07:18.272 INFO 8060 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2341 ms 2014-11-24 21:07:19.000 INFO 8060 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2014-11-24 21:07:19.004 INFO 8060 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2014-11-24 21:07:19.389 INFO 8060 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2014-11-24 21:07:19.596 INFO 8060 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/greeting],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String hello.GreetingController.greeting(java.lang.String,org.springframework.ui.Model) 2014-11-24 21:07:19.600 INFO 8060 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest) 2014-11-24 21:07:19.601 INFO 8060 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 2014-11-24 21:07:19.623 INFO 8060 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2014-11-24 21:07:19.624 INFO 8060 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2014-11-24 21:07:20.117 INFO 8060 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2014-11-24 21:07:20.201 INFO 8060 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080/http 2014-11-24 21:07:20.204 INFO 8060 --- [ main] hello.Application : Started Application in 4.892 seconds (JVM running for 5.351) 2014-11-24 21:07:26.582 ERROR 8060 --- [nio-8080-exec-1] o.a.coyote.http11.Http11NioProtocol : Error reading request, ignored java.lang.NoClassDefFoundError: org/apache/tomcat/util/log/UserDataHelper at org.apache.tomcat.util.http.Cookies.<clinit>(Cookies.java:42) at org.apache.coyote.Request.<init>(Request.java:131) at org.apache.coyote.AbstractProcessor.<init>(AbstractProcessor.java:61) at org.apache.coyote.http11.AbstractHttp11Processor.<init>(AbstractHttp11Processor.java:272) at org.apache.coyote.http11.Http11NioProcessor.<init>(Http11NioProcessor.java:69) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.createProcessor(Http11NioProtocol.java:260) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.createProcessor(Http11NioProtocol.java:139) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:586) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.log.UserDataHelper at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 14 common frames omitted Caused by: java.util.zip.ZipException: invalid LOC header (bad signature) at java.util.zip.ZipFile.read(Native Method) at java.util.zip.ZipFile.access$1400(ZipFile.java:61) at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:717) at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:420) at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) at sun.misc.Resource.getBytes(Resource.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:450) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:367) ... 20 common frames omitted 2014-11-24 21:07:26.583 ERROR 8060 --- [nio-8080-exec-1] org.apache.tomcat.util.net.NioEndpoint : java.lang.NullPointerException: null at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:722) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) 2014-11-24 21:07:26.585 ERROR 8060 --- [nio-8080-exec-2] o.a.coyote.http11.Http11NioProtocol : Error reading request, ignored java.lang.NoClassDefFoundError: Could not initialize class org.apache.tomcat.util.http.Cookies at org.apache.coyote.Request.<init>(Request.java:131) at org.apache.coyote.AbstractProcessor.<init>(AbstractProcessor.java:61) at org.apache.coyote.http11.AbstractHttp11Processor.<init>(AbstractHttp11Processor.java:272) at org.apache.coyote.http11.Http11NioProcessor.<init>(Http11NioProcessor.java:69) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.createProcessor(Http11NioProtocol.java:260) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.createProcessor(Http11NioProtocol.java:139) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:586) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) 2014-11-24 21:07:26.586 ERROR 8060 --- [nio-8080-exec-2] org.apache.tomcat.util.net.NioEndpoint : java.lang.NullPointerException: null at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:722) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) 2014-11-24 21:07:26.588 ERROR 8060 --- [nio-8080-exec-3] o.a.coyote.http11.Http11NioProtocol : Error reading request, ignored java.lang.NoClassDefFoundError: Could not initialize class org.apache.tomcat.util.http.Cookies at org.apache.coyote.Request.<init>(Request.java:131) at org.apache.coyote.AbstractProcessor.<init>(AbstractProcessor.java:61) at org.apache.coyote.http11.AbstractHttp11Processor.<init>(AbstractHttp11Processor.java:272) at org.apache.coyote.http11.Http11NioProcessor.<init>(Http11NioProcessor.java:69) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.createProcessor(Http11NioProtocol.java:260) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.createProcessor(Http11NioProtocol.java:139) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:586) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) 2014-11-24 21:07:26.589 ERROR 8060 --- [nio-8080-exec-3] org.apache.tomcat.util.net.NioEndpoint : java.lang.NullPointerException: null at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:722) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)
The following java.lang.NoClassDefFoundError: org/apache/tomcat/util/log/UserDataHelper means that you're lacking a tomcat-july.jar. The following, however, Caused by: java.util.zip.ZipException: invalid LOC header (bad signature) means that you have a corrupted dependency. My bet would be that the embedded tomcat dependencies did not got downloaded properly. If I were you, I would back-up and delete the .m2\repository\org\apache\tomcat\embed and run the example again, so that it downloads the dependencies again