JobScope and overriding beans - spring-boot

I am attempting to upgrade a spring batch job to spring boot 2.1.x.
I have beans that use the "Job" scope. After upgrading I'm getting an error
The bean ..., could not be registered. A bean with that name has already been defined ... and overriding is disabled.
I can set the property
spring.main.allow-bean-definition-overriding=true
and make it past the error.
My question is do I always need set this property if I use Job or Step scope?
Full Error Message:
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'reportWriterListener' defined in BeanDefinition defined in class path resource [jobs/base_config.xml]: Cannot register bean definition [Root bean: class [org.springframework.aop.scope.ScopedProxyFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in BeanDefinition defined in class path resource [jobs/base_config.xml]] for bean 'reportWriterListener': There is already [Generic bean: class [com.zionsbancorp.spring.batch.batch.ReportWriterJobListener]; scope=job; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=false; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [jobs/base_config.xml]] bound.
Stack Trace:
org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'reportWriterListener' defined in BeanDefinition defined in class path resource [jobs/base_config.xml]: Cannot register bean definition [Root bean: class [org.springframework.aop.scope.ScopedProxyFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in BeanDefinition defined in class path resource [jobs/base_config.xml]] for bean 'reportWriterListener': There is already [Generic bean: class [com.zionsbancorp.spring.batch.batch.ReportWriterJobListener]; scope=job; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=false; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [jobs/base_config.xml]] bound.
at org.springframework.beans.factory.support.DefaultListableBeanFactory.registerBeanDefinition(DefaultListableBeanFactory.java:897) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.batch.core.scope.BatchScopeSupport.createScopedProxy(BatchScopeSupport.java:159) ~[spring-batch-core-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.batch.core.scope.BatchScopeSupport.postProcessBeanFactory(BatchScopeSupport.java:130) ~[spring-batch-core-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:286) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at com.zbc.zci.aspirercif.Application.main(Application.java:48) [classes/:na]
Config Snippet
<bean id="reportWriterListener" class="com.zbc.spring.batch.batch.ReportWriterJobListener" scope="job">
<constructor-arg value="${report.file}"/>
</bean>

Related

Spring Boot 2.3.1 Duplicate Bean Definitions

I am upgrading from Spring Boot 1.5.x to 2.3.1.
Encountered the following Bug which fixed in Spring boot earlier.
https://jira.spring.io/browse/DATAJPA-1448
Tried the following property workaround ,this is not helping as well.
spring.main.allow-bean-definition-overriding=true
Anyone facing the same issue or any workaround?
Error Below
org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'org.springframework.context.config.internalBeanConfigurerAspect' defined in org.springframework.context.annotation.aspectj.SpringConfiguredConfiguration: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.context.annotation.aspectj.SpringConfiguredConfiguration; factoryMethodName=beanConfigurerAspect; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.context.annotation.aspectj.SpringConfiguredConfiguration] for bean 'org.springframework.context.config.internalBeanConfigurerAspect': There is already [Root bean: class [org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=aspectOf; initMethodName=null; destroyMethodName=null] bound.
at org.springframework.beans.factory.support.DefaultListableBeanFactory.registerBeanDefinition(DefaultListableBeanFactory.java:941) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:286) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at XXXXXXXXXXXXXXXXXXXXX.main(XXXXXXXXXXXXXXXXXX.java:38) [classes/:
**
UPDATE
**
Setting the AllowBeanDefinitionOverriding programmatically help to resolve this part (earlier was trying to inject via property file),
But keeping the this thread open as the original rootcause is in spring-jpa,spring-beans is not obvious yet.
SpringApplication sa = new SpringApplication(xxxxxxx.class);
sa.setAllowBeanDefinitionOverriding(true);
We were facing similar issue as OP - once upgraded from spring boot 2.2.8 to 2.3.1 the junit tests around auto configuration started failing with BeanDefinitionOverrideException error and the solution mentioned by OP did not work. Setting the property spring.main.allow-bean-definition-overriding=true via properties file or via environment post processor didn't work as well.
Fix:
We were using ApplicationContextRunner to test loading multiple beans in the context. Calling the method withAllowBeanDefinitionOverriding(true) from instance of ApplicationContextRunner fixed it.
According to Spring Boot 2.3.0 release notes here
"For consistency with SpringApplication, ApplicationContextRunner now
disables bean overriding by default. If you need to use bean
overriding for a test, withAllowBeanDefinitionOverriding can be used
to enable it."

Unable to start Apache Kylin in HDP 3.0.1

I'm trying to run Apache Kylin on a cluster with HDP 3.0.1. When I run ./kylin.sh start I get the following output:
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Retrieving hive dependency...
Retrieving hbase dependency...
Retrieving hadoop conf dir...
Retrieving kafka dependency...
Retrieving Spark dependency...
Start to check whether we need to migrate acl tables
Retrieving hive dependency...
Retrieving hbase dependency...
Retrieving hadoop conf dir...
Retrieving kafka dependency...
Retrieving Spark dependency..
.
.
.
.
.
A new Kylin instance is started by hduser. To stop it, run 'kylin.sh stop'
Check the log at /usr/local/apache-kylin-2.6.2-bin-hadoop3/logs/kylin.log
Web UI is at http://iservices:7070/kylin
So it seems that Kylin starts correctly.
Then, when I try to access the web UI I get not found error and, in the log file I get this errors:
2019-05-22 11:44:26,105 WARN [localhost-startStop-1] scan.StandardJarScanner:146 : Failed to scan [file:/usr/hdp/3.0.1.0-187/spark2/jars/derbyLocale_cs.jar] from classloader hierarchy
scan.StandardJarScanner:146 : Failed to scan [file:/usr/hdp/3.0.1.0-187/spark2/jars/derbyLocale_ja_JP.jar] from classloader hierarchy
java.io.FileNotFoundException: /usr/hdp/3.0.1.0-187/spark2/jars/derbyLocale_ja_JP.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:130)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:196)
at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:65)
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49)
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:374)
at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:309)
at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:266)
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:229)
at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262)
at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104)
at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:101)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5245)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
2019-05-22 11:44:29,073 WARN [localhost-startStop-1] scan.StandardJarScanner:146 : Failed to scan [file:/usr/hdp/3.0.1.0-187/spark2/jars/derbyLocale_zh_TW.jar] from classloader hierarchy
java.io.FileNotFoundException: /usr/hdp/3.0.1.0-187/spark2/jars/derbyLocale_zh_TW.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:130)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:196)
at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:65)
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49)
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:374)
at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:309)
at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:266)
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:229)
at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262)
at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104)
at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:101)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5245)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
2019-05-22 11:44:29,073 INFO [localhost-startStop-1] servlet.TldScanner:119 : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2019-05-22 11:44:29,359 INFO [localhost-startStop-1] [localhost].[/kylin]:119 : No Spring WebApplicationInitializer types detected on classpath
2019-05-22 11:44:29,474 INFO [localhost-startStop-1] common.KylinConfig:101 : Loading kylin-defaults.properties from file:/usr/local/apache-kylin-2.6.2-bin-hadoop3/tomcat/webapps/kylin/WEB-INF/lib/kylin-core-common-2.6.2.jar!/kylin-defaults.properties
2019-05-22 11:44:29,492 DEBUG [localhost-startStop-1] common.KylinConfig:328 : KYLIN_CONF property was not set, will seek KYLIN_HOME env variable
2019-05-22 11:44:29,492 INFO [localhost-startStop-1] common.KylinConfig:334 : Use KYLIN_HOME=/usr/local/apache-kylin-2.6.2-bin-hadoop3
2019-05-22 11:44:29,504 INFO [localhost-startStop-1] common.KylinConfig:136 : Initialized a new KylinConfig from getInstanceFromEnv : 232884412
2019-05-22 11:44:29,577 INFO [localhost-startStop-1] [localhost].[/kylin]:119 : Set web app root system property: 'webapp.root' = [/usr/local/apache-kylin-2.6.2-bin-hadoop3/tomcat/webapps/kylin/]
2019-05-22 11:44:29,611 INFO [localhost-startStop-1] [localhost].[/kylin]:119 : Initializing log4j from [classpath:kylin-server-log4j.properties]
2019-05-22 11:44:29,655 INFO [localhost-startStop-1] [localhost].[/kylin]:119 : Initializing Spring root WebApplicationContext
2019-05-22 11:44:30,588 INFO [localhost-startStop-1] core.SpringSecurityCoreVersion:75 : You are running with Spring Security Core 4.2.3.RELEASE
2019-05-22 11:44:30,592 INFO [localhost-startStop-1] config.SecurityNamespaceHandler:78 : Spring Security 'config' module version is 4.2.3.RELEASE
2019-05-22 11:44:30,631 INFO [localhost-startStop-1] method.GlobalMethodSecurityBeanDefinitionParser:176 : Using bean 'expressionHandler' as method ExpressionHandler implementation
2019-05-22 11:44:30,690 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'permitAll' for /api/user/authentication*/**
2019-05-22 11:44:30,691 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'hasRole('ROLE_ADMIN')' for /api/query/runningQueries
2019-05-22 11:44:30,691 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'hasRole('ROLE_ADMIN')' for /api/query/*/stop
2019-05-22 11:44:30,691 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'isAuthenticated()' for /api/query*/**
2019-05-22 11:44:30,692 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'isAuthenticated()' for /api/metadata*/**
2019-05-22 11:44:30,692 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'permitAll' for /api/**/metrics
2019-05-22 11:44:30,692 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'permitAll' for /api/cache*/**
2019-05-22 11:44:30,692 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'hasAnyRole('ROLE_ANALYST')' for /api/cubes/src/tables
2019-05-22 11:44:30,692 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'isAuthenticated()' for /api/cubes*/**
2019-05-22 11:44:30,693 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'isAuthenticated()' for /api/models*/**
2019-05-22 11:44:30,693 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'isAuthenticated()' for /api/streaming*/**
2019-05-22 11:44:30,693 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'isAuthenticated()' for /api/job*/**
2019-05-22 11:44:30,693 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'permitAll' for /api/admin/public_config
2019-05-22 11:44:30,693 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'permitAll' for /api/projects
2019-05-22 11:44:30,693 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'hasRole('ROLE_ADMIN')' for /api/admin*/**
2019-05-22 11:44:30,694 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'permitAll' for /api/tables/**/snapshotLocalCache/**
2019-05-22 11:44:30,694 INFO [localhost-startStop-1] http.FilterInvocationSecurityMetadataSourceParser:194 : Creating access control expression attribute 'isAuthenticated()' for /api/**
2019-05-22 11:44:30,713 INFO [localhost-startStop-1] http.HttpSecurityBeanDefinitionParser:306 : Checking sorted filter chain: [Root bean: class [org.springframework.security.web.context.SecurityContextPersistenceFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 200, Root bean: class [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 400, Root bean: class [org.springframework.security.web.header.HeaderWriterFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 500, Root bean: class [org.springframework.security.web.authentication.logout.LogoutFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 800, <org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0>, order = 1200, Root bean: class [org.springframework.security.web.authentication.www.BasicAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1600, Root bean: class [org.springframework.security.web.savedrequest.RequestCacheAwareFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1700, Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.security.config.http.HttpConfigurationBuilder$SecurityContextHolderAwareRequestFilterBeanFactory#0; factoryMethodName=getBean; initMethodName=null; destroyMethodName=null, order = 1800, Root bean: class [org.springframework.security.web.authentication.AnonymousAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2100, Root bean: class [org.springframework.security.web.session.SessionManagementFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2200, Root bean: class [org.springframework.security.web.access.ExceptionTranslationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2300, <org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0>, order = 2400]
2019-05-22 11:44:32,771 DEBUG [localhost-startStop-1] security.PasswordPlaceholderConfigurer:174 : Loading properties file from InputStream resource [resource loaded through InputStream]
2019-05-22 11:44:33,286 INFO [localhost-startStop-1] filter.AnnotationSizeOfFilter:53 : Using regular expression provided through VM argument net.sf.ehcache.pool.sizeof.ignore.pattern for IgnoreSizeOf annotation : ^.*cache\..*IgnoreSizeOf$
2019-05-22 11:44:33,332 INFO [localhost-startStop-1] sizeof.JvmInformation:446 : Detected JVM data model settings of: 64-Bit OpenJDK JVM with Compressed OOPs
2019-05-22 11:44:33,625 INFO [localhost-startStop-1] sizeof.AgentLoader:198 : Extracted agent jar to temporary file /usr/local/apache-kylin-2.6.2-bin-hadoop3/bin/../tomcat/temp/ehcache-sizeof-agent1279407813938909413.jar
2019-05-22 11:44:33,626 INFO [localhost-startStop-1] sizeof.AgentLoader:138 : Trying to load agent # /usr/local/apache-kylin-2.6.2-bin-hadoop3/bin/../tomcat/temp/ehcache-sizeof-agent1279407813938909413.jar
2019-05-22 11:44:33,671 INFO [localhost-startStop-1] impl.DefaultSizeOfEngine:111 : using Agent sizeof engine
2019-05-22 11:44:34,563 INFO [localhost-startStop-1] metrics.MetricsManager:136 : Kylin metrics monitor is not enabled
2019-05-22 11:44:34,745 WARN [localhost-startStop-1] support.XmlWebApplicationContext:551 : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/configuration/ConfigurationException
2019-05-22 11:44:34,751 ERROR [localhost-startStop-1] context.ContextLoader:350 : Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/configuration/ConfigurationException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4792)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/configuration/ConfigurationException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
at org.springframework.core.MethodIntrospector.selectMethods(MethodIntrospector.java:68)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:230)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:214)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:184)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:127)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 25 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.configuration.ConfigurationException
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1309)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1137)
... 37 more
2019-05-22 11:44:34,751 WARN [localhost-startStop-1] [localhost].[/kylin]:164 : Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/configuration/ConfigurationException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4792)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/configuration/ConfigurationException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
at org.springframework.core.MethodIntrospector.selectMethods(MethodIntrospector.java:68)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:230)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:214)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:184)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:127)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 25 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.configuration.ConfigurationException
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1309)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1137)
... 37 more
2019-05-22 11:44:34,752 WARN [localhost-startStop-1] core.StandardContext:155 : One or more listeners failed to start. Full details will be found in the appropriate container log file
2019-05-22 11:44:34,806 WARN [localhost-startStop-1] core.StandardContext:155 : Context [/kylin] startup failed due to previous errors
2019-05-22 11:44:34,808 INFO [localhost-startStop-1] [localhost].[/kylin]:119 : Closing Spring root WebApplicationContext
2019-05-22 11:44:34,818 INFO [localhost-startStop-1] [localhost].[/kylin]:119 : Shutting down log4j
Short Answer
Append derbyLocale_*.jar to the list of tomcat.util.scan.StandardJarScanFilter.jarsToSkip of {$KYLIN_HOME}/tomcat/conf/catalina.properties and you are good to go.
As to the ClassNotFoundException, just put commons-configuration-1.x.jar under tomcat/webapps/kylin/WEB-INF/lib.
Long Answer
Missing locale jar is due to jarScanning of tomcat which is used to to find configuration files (in this case, log4j.xml) for the project. It read MANIFEST of jars to find their classpath dependencies and try to load them. Unfortunately spark2 removed all locale jar of derby but forget to modify the MANIFEST of derby-10.12.1.1.jar to remove them. And the ClassNotFoundException is simply a compatible problem, caused by pacakgePath change of org.apache.commons.configuration.ConfigurationException to org.apache.commons.configuration2.ex.ConfigurationException
You can set $KYLIN_HOME/spark as the SPARK_HOME, if there is no directory named spark, you need to run $KYLIN_HOME/bin/download-spark.sh to download Spark.

Spring Boot 1.4.0 never starts successfully

Same application works fine with spring boot 1.3.5.RELEASE but when upgraded to 1.4.0.RELEASE, getting the error below -
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.0.RELEASE)
2016-09-18 23:01:20.816 INFO 18220 --- [ main] com.example.SocialApplication : Starting SocialApplication on badalb-mac.local with PID 18220 (/Users/badalb/codebase/Spring/github/target/classes started by badalb in /Users/badalb/codebase/Spring/github)
2016-09-18 23:01:20.823 INFO 18220 --- [ main] com.example.SocialApplication : No active profile set, falling back to default profiles: default
2016-09-18 23:01:20.925 INFO 18220 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#27eedb64: startup date [Sun Sep 18 23:01:20 IST 2016]; root of context hierarchy
2016-09-18 23:01:21.719 INFO 18220 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'scopedTarget.oauth2ClientContext' with a different definition: replacing [Root bean: class [null]; scope=session; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=false; primary=false; factoryBeanName=org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration$OAuth2ClientContextConfiguration; factoryMethodName=oauth2ClientContext; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration$OAuth2ClientContextConfiguration] with [Root bean: class [null]; scope=session; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=false; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2RestOperationsConfiguration$SessionScopedConfiguration$ClientContextConfiguration; factoryMethodName=oauth2ClientContext; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2RestOperationsConfiguration$SessionScopedConfiguration$ClientContextConfiguration.class]]
2016-09-18 23:01:21.728 INFO 18220 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'oauth2ClientFilterRegistration' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=beanConfig; factoryMethodName=oauth2ClientFilterRegistration; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/example/config/BeanConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2RestOperationsConfiguration$SessionScopedConfiguration; factoryMethodName=oauth2ClientFilterRegistration; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2RestOperationsConfiguration$SessionScopedConfiguration.class]]
2016-09-18 23:01:21.863 WARN 18220 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance #Configuration bean definition 'org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration$TokenKeyEndpointRegistrar' since its singleton instance has been created too early. The typical cause is a non-static #Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2016-09-18 23:01:22.190 WARN 18220 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
2016-09-18 23:01:22.201 ERROR 18220 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at com.example.SocialApplication.main(SocialApplication.java:14) [classes/:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:189) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
... 8 common frames omitted
Any Idea??

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;
}

Resources