what could be possible reasons for integrationMBeanExporter ... javax.management.InstanceAlreadyExistsException - spring

I have chose to implement my jobs using Spring Batch Admin and, unfortunately, it works perfectly in all environment except the production. I guess there is another application from another team causing some indirect effect but I can't stop them in order to check which one is affecting and if there is really some application affect.
I am desparetely looking for possible causes and I can't find. Any imagine reason would be a start point appreciatted.
The entire error is:
Trace: 2016/09/09 22:49:17.049 02 t=9BDE88 c=UNK key=P8 tag= (13007004)
SourceId: com.ibm.ws.webcontainer.webapp.WebApp.logServletError
ExtendedMessage: BBOO0220E: SRVE0293E: ÝServlet Error¨-ÝBatch Servlet¨: org.springframework.beans.factory.BeanCreationException: E
rror creating bean with name 'mbeanExporter': Invocation of init method failed; nested exception is org.springframework.jmx.export.U
nableToRegisterMBeanException: Unable to register MBean Ýorg.springframework.integration.monitor.IntegrationMBeanExporter#4ed60bcf¨
with key 'integrationMBeanExporter'; nested exception is javax.management.InstanceAlreadyExistsException: spring.application:cell=dt
l85cel,name=integrationMBeanExporter,type=IntegrationMBeanExporter,node=wlemyAppa,process=WLEmyApp
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.j
ava:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.jav
a:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:
475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:70
3)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:7
60)
...
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanSe
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:814)
at com.ibm.ws390.management.connector.corba.CorbaConnectorImpl.invoke(CorbaCon
at com.ibm.ws390.management.connector.corba._CorbaConnectorImplBase._invoke(_C
at com.ibm.ws390.orb.CommonBridge.invoke(CommonBridge.java:1898)
at com.ibm.ws390.orb.CommonBridge.getAndProcessWork(CommonBridge.java:725)
at com.ibm.ws390.orb.CommonBridge.runApplicationThread(CommonBridge.java:614)
at com.ibm.ws390.management.connector.corba.CorbaConnectorImpl.invoke(CorbaCon
at com.ibm.ws390.management.connector.corba._CorbaConnectorImplBase._invoke(_C
at com.ibm.ws390.orb.CommonBridge.invoke(CommonBridge.java:1898)
at com.ibm.ws390.orb.CommonBridge.getAndProcessWork(CommonBridge.java:725)
at com.ibm.ws390.orb.CommonBridge.runApplicationThread(CommonBridge.java:614)
at com.ibm.ws.util.ThreadPool$ZOSWorker.run(ThreadPool.java:2116)
Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean Ýorg.springframework.integration.
monitor.IntegrationMBeanExporter#4ed60bcf¨ with key 'integrationMBeanExporter';nested exception is javax.management.InstanceAlready
ExistsException: spring.application:cell=mycel,name=integrationMBeanExporter,type=IntegrationMBeanExporter,node=wlemyAppa,process
Is there any way to turn off in Spring Batch Admin such duplicated Bean? How can I try IGNORE_EXISTING or REPLACE_EXISTING just to see if it fix my problem?

Related

javax.naming.NameNotFoundException: While trying to lookup 'jdbc.teradata' didn't find subcontext 'jdbc'. Resolved ''; remaining name 'jdbc/teradata'

However I could open up the required remote port for Teradata, I am getting this error, is it because the required jdbc driver library is missing in the Weblogic in which I am deploying my Application.
Please advise, you can find complete error below. Because of this failure consecutive Spring Autowired Components are also failing.
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'teradataDataSource' defined in ServletContext resource [/WEB-INF/async-db-config.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: While trying to lookup 'jdbc.teradata' didn't find subcontext 'jdbc'. Resolved ''; remaining name 'jdbc/teradata'
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
Truncated. see log file for complete stacktrace

java.lang.ClassNotFoundException: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection

I am trying to use WAS liberty rutime profile with eclipse Luna.
My environment:
Window 7
Eclipse luna
Websphere application server tools V8.5 plugin
Websphere liberty profile
My application using spring framework 2.5, and configuration file as below.
<!-- For Oracle and Websphere; you need to use this lob handler definition instead of defaultLobHandler. Because of differences in Oracle's Blob objects. -->
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" >
<property name="nativeJdbcExtractor" >
<bean class="org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor"/>
</property>
</bean>
however when I deploy my application into Liberty Profile (LP). for some reason the class can not be loaded properly.
I can find this class in com.ibm.ws.jdbc_1.0.8.jar file, and this jar file located under {server.home}/lib folder. As I understand this library should be loaded automatically.
The detail of error log:
[ERROR ] SRVE0283E: Exception caught while initializing context: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oracleLobHandler' defined in ServletContext resource [/WEB-INF/dataAccessContext.xml]: Cannot create inner bean 'org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor#fff379a3' of type [org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor] while setting bean property 'nativeJdbcExtractor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor#fff379a3' defined in ServletContext resource [/WEB-INF/dataAccessContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor]: Constructor threw exception; nested exception is java.lang.IllegalStateException: Could not initialize WebSphereNativeJdbcExtractor because WebSphere API classes are not available: java.lang.ClassNotFoundException: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1132)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:2388)
at [internal classes]
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor]: Constructor threw exception; nested exception is java.lang.IllegalStateException: Could not initialize WebSphereNativeJdbcExtractor because WebSphere API classes are not available: java.lang.ClassNotFoundException: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1004)
... 21 more
Caused by: java.lang.IllegalStateException: Could not initialize WebSphereNativeJdbcExtractor because WebSphere API classes are not available: java.lang.ClassNotFoundException: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection
at org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor.<init>(WebSphereNativeJdbcExtractor.java:65)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
at java.lang.reflect.Constructor.newInstance(Constructor.java:527)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
Any ideas on this issue really appreciate. I really got pain with this one.
Many thanks in advance.
com.ibm.ws.jdbc_1.0.8.jar is OSGi bundle, and package you are referring is not exported, so it is not available for application classes.
I assume that you need that to get to the native connection, for that you have two options:
use the JDBC API unwrap() method, like for example connection.unwrap(). See some examples for connection and prepareStatement here
Update to Spring 3.0.5 or higher and use OracleJdbc4NativeJdbcExtractor instead of WebSphereNativeJdbcExtractor (I didn't test that, but should work in theory).
Do you have the jdbc feature enabled in your server.xml? If you have a recent Liberty installation, I would recommend enabling the webProfile-6.0 feature, which is a combination of many commonly used features.
change:
class="org.springframework.jdbc.support.nativejdbc.WebSphereNativeJdbcExtractor" />
to:
class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" />

Need help debugging Tomcat 7 application error

UPDATE: This appears to be caused by the order in which spring beans are discovered and initialized. It's still unknown why the servers are detecting the beans in different orders, but gives me path to fix this.
I've run into a puzzling problem trying to deploy a WAR to Tomcat 7 (AWS OpsWorks, Ubuntu 12.04, Tomcat 7.0.26, OpenJDK 1.7.0_65):
After deploying the WAR, Tomcat immediately reports an error initializing the context due to a spring autowire exception in the application I'm deploying. "org.springframework.beans.factory.BeanCreationException: Could not autowire field...".
The issue is that this WAR works just fine on every other server I've loaded it on. I've even copied the unpacked webapps app directory (from the impacted server) onto another server with the same java and tomcat version with no issues.
Restarting the server, redeploying, and restarting tomcat doesn't seem to have any effect. Keeps giving me the same spring application error.
Any recommendations on how to debug this? The standard Tomcat log file with FINE output settings doesn't provide much detail besides the application's spring error.
ERROR [pool-2-thread-1] (ContextLoader.java:331) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emailTemplateService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private eco.domain.delivery.TemplateRepository eco.service.delivery.EmailTemplateService.emailtemplateRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [eco.domain.delivery.TemplateRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true), #org.springframework.beans.factory.annotation.Qualifier(value=EmailTemplateCrudMemRepository)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:326)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1204)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1581)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private eco.domain.delivery.TemplateRepository eco.service.delivery.EmailTemplateService.emailtemplateRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [eco.domain.delivery.TemplateRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true), #org.springframework.beans.factory.annotation.Qualifier(value=EmailTemplateCrudMemRepository)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:542)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:323)
... 26 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [eco.domain.delivery.TemplateRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true), #org.springframework.beans.factory.annotation.Qualifier(value=EmailTemplateCrudMemRepository)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1261)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1009)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:904)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514)
... 28 more
Nov 12, 2014 12:19:00 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Issue seems to be with your emailTemplateService.
Key message:
No qualifying bean of type [eco.domain.delivery.TemplateRepository]
Make sure your auto scan is picking up the relevant annotations.
Check out your whole email service line to ensure you have right annotations, let me know if this doesn't help.
Try to compare the server.xml environment configuration of your server and some working instance, if everything else is 'the same' you should find something missing there ...

Spring 4 LTW not compatible with 64 bit JVM and Tomcat

As part of moving to Java 8 and in honor of Spring 4, I thought I'd upgrade to all 64 bit code. This application runs perfectly on 32 bit but load time weaving does not work (in fact doesn't even load) on 64 bit.
Specifics of the architecture:
Java 8.0.5 (32 or 64 bit as appropriate)
Tomcat 7.0.54 (32 or 64 bit as appropriate)
Spring 4.0.5
Eclipselink 2.5.1
Testing under Spring Tool Suite 3.5.1 on windows.
Deployment Target RHEL
JVM startup:
-javaagent:C:\Users\...\.m2\repository\org\springframework\spring-instrument\4.0.5.RELEASE\spring-instrument-4.0.5.RELEASE.jar
The offending Bean:
#Bean()
public LoadTimeWeaver loadTimeWeaver() {
return new org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver();
}
The error is pretty straightforward:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'entityManagerFactory' defined in class path resource com/xxxx/config/DataContextConfig.class]:
Invocation of init method failed; nested exception is java.lang.IllegalStateException:
Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
All I did was change to 64 bit JVM and use the 64 bit Tomcat container. Very many hours of Googling and trying different versions and agents have completely failed to turn up any solution. Any thoughts appreciated.
UPDATE:
It is a standard Eclipse Server config so I assume that basically means startup.sh start. The addional JVM properteries are below. Note that we are not deploying any AspectJ aspects at this time, that's the next release. The results are identical with or without the AspectJ weaver specified.
-javaagent:C:\Users\XXXXXX\.m2\repository\org\springframework\spring-instrument\4.0.5.RELEASE\spring-instrument-4.0.5.RELEASE.jar
-javaagent:C:\Users\XXXXXX\.m2\repository\org\aspectj\aspectjweaver\1.8.0\aspectjweaver-1.8.0.jar
-Dcatalina.base="C:\Users\XXXXXX\apache-tomcat-7.0.54-64bit"
-Dcatalina.home="C:\Users\XXXXXX\apache-tomcat-7.0.54-64bit"
-Dwtp.deploy="C:\Users\XXXXXX\apache-tomcat-7.0.54-64bit\webapps"
-Djava.endorsed.dirs="C:\Users\XXXXXX\apache-tomcat-7.0.54-64bit\endorsed"
Stacktrace:
20140529 13:25:48,873 localhost-startStop-1 ERROR Context initialization failed
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'ieexbContextConfig': Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: com.xxx.yyyy.domain.FlowController com.xxx.yyyy.config.IeexbContextConfig.flowController;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'FlowController': Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: com.xxx.yyyy.repository.PendingQueueRepository com.xxx.yyyy.domain.FlowController.pendingQueueRepository;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'pend ingQueueRepository': Cannot create inner bean '(inner bean)#63244fdb' of type [org.springframework.orm.jpa.SharedEntityM anagerCreator] while setting bean property 'entityManager';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#63244fdb': Cannot resolve reference to bean 'entityManagerF actory' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'entityManagerFactory' defined in class path resource [com/xxx/yyyy/config/IeexbDataCont extConfig.class]: Invocation of init method failed;
nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.xxx.yyyy.domain.FlowController com.xxx.yyyy.config.IeexbContextConfig.flowController; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'FlowController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.xxx.yyyy.repository.PendingQueueRepository com.xxx.yyyy.domain.FlowController.pendingQueueRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pendingQueueRepository': Cannot create inner bean '(inner bean)#63244fdb' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#63244fdb': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/xxx/yyyy/config/IeexbDataContextConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
... 26 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'FlowController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.xxx.yyyy.repository.PendingQueueRepository com.xxx.yyyy.domain.FlowController.pendingQueueRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pendingQueueRepository': Cannot create inner bean '(inner bean)#63244fdb' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#63244fdb': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/xxx/yyyy/config/IeexbDataContextConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
... 28 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.xxx.yyyy.repository.PendingQueueRepository com.xxx.yyyy.domain.FlowController.pendingQueueRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pendingQueueRepository': Cannot create inner bean '(inner bean)#63244fdb' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#63244fdb': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/xxx/yyyy/config/IeexbDataContextConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
... 39 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pendingQueueRepository': Cannot create inner bean '(inner bean)#63244fdb' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#63244fdb': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/xxx/yyyy/config/IeexbDataContextConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:290)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:129)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
... 41 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#63244fdb': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/xxx/yyyy/config/IeexbDataContextConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:336)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:632)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:442)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:276)
... 54 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/xxx/yyyy/config/IeexbDataContextConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
... 62 more
Caused by: java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
at org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver.addTransformer(InstrumentationLoadTimeWeaver.java:88)
at org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.addTransformer(SpringPersistenceUnitInfo.java:82)
at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:348)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:336)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
... 69 more
I ran into the same problem. But eventually the issue was not coming from spring-data-jpa but rather on Tomcat changes from 7.0.47 version (where everything is working) to 7.0.5x and tomcat 8.
Try removing spring-instrument.jar agent from your application WEB-INF/lib (and put a provided scope to this dependency if you're using Maven), this should resolve the issue.
I'm running a Spring 4.0.6 application with Eclipselink 2.5.2 and dynamic weaving with spring-data-jpa 1.6.2 on a Tomcat 8.0.9 server on Java 8, everything in 64 bits.
The 2 methods for weaving (agent at startup or spring-instrument.jar in Tomcat lib directory) are working.
Note: Make sure you are using aspectj 1.8.1 (comes with Spring 4.0.6)
The problem was that the current RELEASE of spring-data-jpa is 1.5.1. That version is obviously not compatible with 64 bit - although it works fine with Spring 4 in 32 bit Java 8 and Tomcat.
The solution was to pull in the SNAPSHOT build of 1.7.0 which does work with Spring 4 and 64 bit. See
spring-data-jpa project site for dependency and official Repository POM elements. I'm not sure if I'll try to get SNAPSHOT code released to our production or not. Hopefully they'll build a RELEASE soon.
It is worth noting that Eclipselink 2.5.1 is fully 64 bit ready.

BeanCreationException with Spring and Jackson API

I am getting following exception while trying to use Jackson API with Spring 3.0.6. I have jackson jars of v1.8.9 (core-asl, mapper-asl) into the classpath but still due to some conflicting jars I am facing the error ::
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#8': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.converter.json.MappingJacksonHttpMessageConverter]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.codehaus.jackson.type.JavaType.<init>(Ljava/lang/Class;I)V
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270) [org.springframework.beans-3.0.6.RELEASE.jar:]
... 30 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.converter.json.MappingJacksonHttpMessageConverter]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.codehaus.jackson.type.JavaType.<init>(Ljava/lang/Class;I)V
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958) [org.springframework.beans-3.0.6.RELEASE.jar:]
... 34 more
Caused by: java.lang.NoSuchMethodError: org.codehaus.jackson.type.JavaType.<init>(Ljava/lang/Class;I)V
at org.codehaus.jackson.map.type.TypeBase.<init>(TypeBase.java:13) [jackson-mapper-asl-1.8.9.jar:]
at org.codehaus.jackson.map.type.SimpleType.<init>(SimpleType.java:39) [jackson-mapper-asl-1.8.9.jar:]
at org.codehaus.jackson.map.type.SimpleType.constructUnsafe(SimpleType.java:56) [jackson-mapper-asl-1.8.9.jar:]
at org.codehaus.jackson.map.ObjectMapper.<clinit>(ObjectMapper.java:188) [jackson-mapper-asl-1.8.9.jar:]
at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.<init>(MappingJacksonHttpMessageConverter.java:56) [org.springframework.web-3.0.6.RELEASE.jar:]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [:1.6.0_24]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [:1.6.0_24]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [:1.6.0_24]
at java.lang.reflect.Constructor.newInstance(Constructor.java:532) [:1.6.0_24]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) [org.springframework.beans-3.0.6.RELEASE.jar:]
... 36 more
The correct version dependency of Jackson for Spring 3.0.6 is 1.4.2(per Spring's pom), try replacing 1.8.9 with this version, it should work correctly.
Thanks for your reply. However, I could solve out the issue doing some R&D... I need not go down to Jackson v1.4.2, instead I used the same version with slight modification in JBoss configuration itself.
In JBoss, go to modules/org/codehaus/jackson/jackson-core-asl/main/
Here JBoss is using its own version of Jackson API (though we had different version in classpath). So I copied the v1.8.9 and made changes accordingly in module.xml (in same directory). Similar thing was repeated for mapper jars v1.8.9.
With this I could fix the issue and run things again.... :)

Resources