Jboss 7 - Spring - using Jboss TransactionManager - spring

Using: Jboss 7.1.1, Hibernate 3.6.9, Spring 3.0.1.
I tried out to switch from Spring Transaction Manager:
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="dataSource" ref="dataSource" />
</bean>
to Jboss Transaction Manager:
<!-- search for transaction managers -->
<tx:jta-transaction-manager/>
Using org.springframework.orm.jpa.JpaTransactionManager all works fine but if I remove "transactionManager" bean and added "" I get following error:
javax.persistence.TransactionRequiredException: no transaction is in progress
I found following in the server log:
08:40:58,382 INFO [org.hibernate.transaction.TransactionFactoryFactory] (MSC service
thread 1-1) Using default transaction strategy (direct JDBC transactions)
08:40:58,383 INFO [org.hibernate.transaction.TransactionManagerLookupFactory] (MSC
service thread 1-1) No TransactionManagerLookup configured (in JTA
environment, use of read-write or transactional second-level cache is not
recommended)
What that means? Does my application using java:jboss/TransactionManager now or not? Do I have to configure something on Jboss?
applicationContext.xml snippet:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="xxx" />
<property name="dataSource" ref="dataSource" />
<property name="persistenceXmlLocation" value="classpath*:META-
INF/persistence.xml" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform"
value="org.hibernate.dialect.SQLServerDialect" />
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
</bean>
</property>
</bean>
<tx:jta-transaction-manager/>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${database.jndi.path}" />
persistence.xml snippet:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="xxx" transaction-type="RESOURCE_LOCAL">
<!-- a lot of <class>com.MyClass</class> -->
<properties>
<property name="jboss.as.jpa.managed" value="false"/>
<property name="hibernate.dialect"
value="org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect"/>
</properties>
</persistence-unit>
Maybe "RESOURCE_LOCAL" is wrong in persitence.xml?
domain.xml:
<datasource jta="true" jndi-name="java:jboss/datasources/myName" pool-name="myName" use-ccm="true">
<connection-url>jdbc:sqlserver://10.100.0.91:1433;databaseName=db;user=myUser;password=myPassword</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<driver>mssql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>20</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>myName</user-name>
<password>myPassword</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
--EDIT--
Now I changed my applicationContext.xml and persistence.xml!
applicationContext.xml snippet:
<jee:jndi-lookup id="my_unit" jndi-name="java:jboss/my_unit" />
<tx:jta-transaction-manager/>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${database.jndi.path}" />
</bean>
persistence.xml snippet:
?xml version="1.0" encoding="UTF-8" standalone="no"?>
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<jta-data-source>java:jboss/datasources/wtb</jta-data-source>
<properties>
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
<property name="hibernate.dialect"
value="org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect" />
</properties>
</persistence-unit>
Now I get following exception while deploying:
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: my_unit] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
... 3 more
Caused by: org.hibernate.HibernateException: Dialect class not found: org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:76)
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:64)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:176)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
... 9 more
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect]
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73)
... 20 more
Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306) [rt.jar:1.6.0_32]
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) [rt.jar:1.6.0_32]
at
org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
... 21 more

Are you using this in your applicationContext:
<tx:annotation-driven />
And in your Method:
#Transaction
public void store(Message message){...}

Related

Spring data + JTA transactions + JBoss7

I use JBoss7 and EclipseLink over MS SQL db. I'm trying to add Spring Data to my project, but everything fails when repository method implementation is generated.
It tries to join current transaction and fails with "ARJUNA016083: Can't register synchronization because the transaction is in aborted state".
My Spring config:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" destroy-method="destroy">
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
<property name="persistenceUnitName" value="${module.persistence-unit-name}" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" />
<bean id="PROPAGATION_REQUIRED" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="transactionManager" />
<property name="propagationBehaviorName" value="PROPAGATION_REQUIRED" />
</bean>
<bean id="PROPAGATION_REQUIRES_NEW" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="transactionManager" />
<property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW" />
</bean>
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="myUnit" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/mixx</jta-data-source>
<class>package.MyEntity</class>
<shared-cache-mode>NONE</shared-cache-mode>
<validation-mode>NONE</validation-mode>
<properties>
<property name="eclipselink.target-server" value="JBoss" />
<property name="eclipselink.deploy-on-startup" value="true" />
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.exception-handler" value="package.persistence.EclipseLinkExceptionHandler" />
<property name="eclipselink.session.customizer" value="package.persistence.EclipseLinkSessionCustomizer" />
</properties>
</persistence-unit>
</persistence>
It fails exactly in JTATransactionWrapper.registerIfRequired(UnitOfWorkImpl uow) when it tries to call (line 136):
((Transaction)txn).registerSynchronization(new Synchronization() {
public void beforeCompletion() {}
public void afterCompletion(int status) {
//let the wrapper know the listener is no longer registered to an active transaction
isJoined = false;
}
});
Does Spring Data work fine with EclipseLink and JTA? Is there a chance to use it in my project?

Spring Context initialization failed while bootstrapping with Websphere 7.x server

I am working on a migration task where we are migrating the project from Websphere 6.1 to Websphere 7.0.0.39. Also upgraded JDK version from 1.5 to 1.6.
Actually one of the web project, uses spring and hibernate combination. The version of spring is 2.5.3. The spring context is initialized while bootstrapping i.e. # server startup.
So i am getting org.springframework.web.context.ContextLoader initWebApplicationContext Context initialization failed error while server startup.
I also did a google search on the below issue and found the jira SPR-4788 which says spring2.5 && ibm jdk6 will produce a NPE as below.
Stack Trace from the server startup log :
org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext#27822782]: org.springframework.beans.factory.support.DefaultListableBeanFactory#39ed39ed
[5/9/16 16:29:03:417 IST] 0000000c DefaultListab I org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#39ed39ed: defining beans [applicationContextHolder,dataSource,entityManagerFactory,transactionManager,jndiEPTemplate,sequenceProxy,transferActionItemDao,transferTemplateActionItemDao,achActionItemDao,achTemplateActionItemDao,wireActionItemDao,wireTemplateActionItemDao,posPayActionItemDao,cdBalancesDao,bankIRReportsDao,favoriteDao,stateDao,secureMsgActionItemDao,specialReportItemDao,alertsActionItemDao,shortcutMenuDao,userActionItemDao,achAuthActionItemDao,corporateWireBannerDao,wireBannerDao,corporateTransferBannerDao,transferBannerDao,corporateAchBannerDao,achBannerDao,corporatePosPayBannerDao,posPayBannerDao,issuesBannerDao,stopPayBannerDao,uploadBannerDao,corporateIssuesBannerDao,corporateStopPayBannerDao,corporateUploadBannerDao,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.config.internalTransactionAdvisor,CDBalancesDao,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor]; root of factory hierarchy
[5/9/16 16:29:03:417 IST] 0000000c ContextLoader E org.springframework.web.context.ContextLoader initWebApplicationContext Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalPersistenceAnnotationProcessor': Initialization of bean failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(AccessController.java:224)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:579)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:366)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1721)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:388)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:299)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:166)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:732)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:617)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:376)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:668)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1146)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1320)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:611)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:945)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:759)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$3.run(ApplicationMgrImpl.java:2082)
at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5398)
at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5486)
at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2087)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:434)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:377)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$300(CompositionUnitMgrImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:944)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:496)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1662)
Caused by: java.lang.NullPointerException
at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:144)
at org.springframework.core.GenericTypeResolver.resolveReturnType(GenericTypeResolver.java:93)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:58)
at java.beans.PropertyDescriptor.setWriteMethod(PropertyDescriptor.java:111)
at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:77)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:47)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:250)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:252)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:380)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1248)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
... 39 more
[5/9/16 16:29:03:433 IST] 0000000c webapp E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E: Exception caught while initializing context: {0}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalPersistenceAnnotationProcessor': Initialization of bean failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(AccessController.java:224)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:579)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:366)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1721)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:388)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:299)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:166)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:732)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:617)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:376)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:668)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1146)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1320)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:611)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:945)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:759)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$3.run(ApplicationMgrImpl.java:2082)
at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5398)
at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5486)
at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2087)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:434)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:377)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$300(CompositionUnitMgrImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:944)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:496)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1662)
Caused by: java.lang.NullPointerException
at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:144)
at org.springframework.core.GenericTypeResolver.resolveReturnType(GenericTypeResolver.java:93)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:58)
at java.beans.PropertyDescriptor.setWriteMethod(PropertyDescriptor.java:111)
at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:77)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:47)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:250)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:252)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:380)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1248)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
... 39 more
Spring jars in Class-Path of the web project:
3rdparty/spring-2.5.3.jar
3rdparty/spring-aop.jar
3rdparty/spring-beans.jar
3rdparty/spring-binding.jar
3rdparty/spring-context-support.jar
3rdparty/spring-context.jar
3rdparty/spring-core.jar
3rdparty/spring-dao.jar
3rdparty/spring-faces.jar
3rdparty/spring-jdbc.jar
3rdparty/spring-js.jar
3rdparty/spring-mock.jar
3rdparty/spring-security-acl.jar
3rdparty/spring-security-core-tiger.jar
3rdparty/spring-security-core.jar
3rdparty/spring-security-taglibs.jar
3rdparty/spring-support.jar
3rdparty/spring-test.jar
3rdparty/spring-tx.jar
3rdparty/spring-web.jar
3rdparty/spring-webflow.jar
3rdparty/spring-webmvc.jar
Spring Configuration File
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<!-- http://static.springframework.org/spring/docs/2.5.x/reference/xsd-config.html -->
<!-- see Spring in Action pg 143 -->
<bean id="applicationContextHolder" class="com.s1.core.WebApplicationContextHolder" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.WebSphereDataSourceAdapter">
<property name="targetDataSource">
<bean class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/EPDatabase" />
</bean>
</property>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceUnitName" value="bankingEjbPersistenceUnit"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="DB2"/>
<property name="showSql" value="false"/>
</bean>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="jndiEPTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.ibm.websphere.naming.WsnInitialContextFactory</prop>
<prop key="java.naming.provider.url">iiop://localhost:#BOOT_STRAP_PORT#</prop>
</props>
</property>
</bean>
<bean id="sequenceProxy" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean" scope="prototype">
<property name="jndiName" value="ejb/com/s1/arch/sequence/SequenceServiceHome"/>
<property name="businessInterface" value="com.s1.arch.persistence.sequence.SequenceService"/>
<property name="jndiTemplate">
<ref local="jndiEPTemplate"/>
</property>
<property name="cacheHome" value="false"/>
<property name="lookupHomeOnStartup" value="false"/>
<property name="resourceRef" value="false"/>
<property name="homeInterface" value="com.s1.arch.persistence.sequence.SequenceServiceHome"/>
</bean>
<bean id="transferActionItemDao" class="com.s1.core.dashboard.dao.TransferActionItemDao" autowire="byName" />
<bean id="transferTemplateActionItemDao" class="com.s1.core.dashboard.dao.TransferTemplateActionItemDao" autowire="byName" />
<bean id="achActionItemDao" class="com.s1.core.dashboard.dao.AchActionItemDao" autowire="byName" />
<bean id="achTemplateActionItemDao" class="com.s1.core.dashboard.dao.AchTemplateActionItemDao" autowire="byName" />
<bean id="wireActionItemDao" class="com.s1.core.dashboard.dao.WireActionItemDao" autowire="byName" />
<bean id="wireTemplateActionItemDao" class="com.s1.core.dashboard.dao.WireTemplateActionItemDao" autowire="byName" />
<bean id="posPayActionItemDao" class="com.s1.core.dashboard.dao.PosPayActionItemDao" autowire="byName" />
<bean id="cdBalancesDao" class="com.s1.core.dashboard.dao.CDBalancesDao" autowire="byName" />
<bean id="bankIRReportsDao" class="com.s1.core.dashboard.dao.BankIRReportsDao" autowire="byName" />
<bean id="favoriteDao" class="com.s1.core.dashboard.dao.FavoriteDao" autowire="byName" />
<bean id="stateDao" class="com.s1.core.dashboard.dao.StateDao" autowire="byName" />
<bean id="secureMsgActionItemDao" class="com.s1.core.dashboard.dao.SecureMsgActionItemDao" />
<bean id="specialReportItemDao" class="com.s1.core.dashboard.dao.SpecialReportItemDao" autowire="byName" />
<bean id="alertsActionItemDao" class="com.s1.core.dashboard.dao.AlertsActionItemDao" autowire="byName" />
<bean id="shortcutMenuDao" class="com.s1.core.dashboard.dao.ShortcutMenuDao" autowire="byName" />
<bean id="userActionItemDao" class="com.s1.core.dashboard.dao.UserActionItemDao" autowire="byName" />
<bean id="achAuthActionItemDao" class="com.s1.core.dashboard.dao.AchAuthActionItemDao" autowire="byName" />
<bean id="corporateWireBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateWireBannerDao" autowire="byName" />
<bean id="wireBannerDao" class="com.s1.pso.core.banner.dao.PSOWireBannerDao" autowire="byName" />
<bean id="corporateTransferBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateTransferBannerDao" autowire="byName" />
<bean id="transferBannerDao" class="com.s1.pso.core.banner.dao.PSOTransferBannerDao" autowire="byName" />
<bean id="corporateAchBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateAchBannerDao" autowire="byName" />
<bean id="achBannerDao" class="com.s1.pso.core.banner.dao.PSOAchBannerDao" autowire="byName" />
<bean id="corporatePosPayBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporatePosPayBannerDao" autowire="byName" />
<bean id="posPayBannerDao" class="com.s1.pso.core.banner.dao.PSOPosPayBannerDao" autowire="byName" />
<bean id="issuesBannerDao" class="com.s1.pso.core.banner.dao.PSOIssuesBannerDao" autowire="byName" />
<bean id="stopPayBannerDao" class="com.s1.pso.core.banner.dao.PSOStopPayBannerDao" autowire="byName" />
<bean id="uploadBannerDao" class="com.s1.pso.core.banner.dao.PSOUploadBannerDao" autowire="byName" />
<bean id="corporateIssuesBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateIssuesBannerDao" autowire="byName" />
<bean id="corporateStopPayBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateStopPayBannerDao" autowire="byName" />
<bean id="corporateUploadBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateUploadBannerDao" autowire="byName" />
<tx:annotation-driven transaction-manager="transactionManager" />
<context:annotation-config /> </beans>
Persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="bankingEjbPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<!-- The provider only needs to be set if you use several JPA providers
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<provider>org.unitils.orm.jpa.util.provider.hibernate.UnitilsHibernatePersistenceProvider</provider>
-->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.s1.core.dashboard.bean.AchActionItem</class>
<class>com.s1.core.dashboard.bean.AlertsActionItem</class>
<class>com.s1.core.dashboard.bean.BankIRReports</class>
<class>com.s1.core.dashboard.bean.BankTransactionActionItem</class>
<class>com.s1.core.dashboard.bean.CDBalancesEntity</class>
<class>com.s1.core.dashboard.bean.FavoriteItem</class>
<class>com.s1.core.dashboard.bean.PosPayActionItem</class>
<class>com.s1.core.dashboard.bean.SecureMsgActionItem</class>
<class>com.s1.core.dashboard.bean.ShortcutMenuEntity</class>
<class>com.s1.core.dashboard.bean.SpecialReportItem</class>
<class>com.s1.core.dashboard.bean.StateItem</class>
<class>com.s1.core.dashboard.bean.TransferActionItem</class>
<class>com.s1.core.dashboard.bean.WireActionItem</class>
<properties>
<!-- SQL stdout logging -->
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="true"/>
<property name="use_sql_comments" value="true"/>
<property name="hibernate.connection.release_mode" value="after_transaction"/>
<property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="20"/>
<property name="hibernate.c3p0.timeout" value="300"/>
<property name="hibernate.c3p0.max_statements" value="50"/>
<property name="hibernate.c3p0.idle_test_period" value="3000"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect" />
<property name="hibernate.connection.datasource" value="jdbc/EPDatabase" />
<property name="hibernate.connection.driver_class" value="com.ibm.db2.jcc.DB2Driver" />
</properties>
</persistence-unit>
<persistence-unit name="parserPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.s1.core.parser.ParsedPDStatement</class>
<class>com.s1.core.parser.ParsedPDStatementDetail</class>
<class>com.s1.core.parser.ParsedPDTransaction</class>
<class>com.s1.core.parser.ParsedPDTransactionMemo</class>
<class>com.s1.core.parser.ParsedCDStatement</class>
<class>com.s1.core.parser.ParsedCDStatementDetail</class>
<class>com.s1.core.parser.ParsedCDTransaction</class>
<class>com.s1.core.parser.ParsedCDTransactionMemo</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.DB2Dialect" />
<!--<property name="hibernate.hbm2ddl.auto" value="update" /> -->
<!-- Enable pooling of connections for efficiency. Can be disabled in development -->
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="300" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="3000" />
<property name="hibernate.connection.datasource" value="jdbc/EPDatabase" />
<property name="hibernate.connection.driver_class" value="com.ibm.db2.jcc.DB2Driver" />
</properties>
</persistence-unit>
</persistence>
Listener configuration in web.xml
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

Multiple persistence unit throwing error no persistence found error Spring+JPA

xml as follows , Its having multiple persistence units , seems only one is like getting recognised.
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="webApp-integration">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.foo.webapp.integration.model.test.ItemMaster</class>
<class>com.foo.webapp.integration.model.test.SupplierMaster</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<!-- These options seem intended to be developers tools and not to facilitate
any production level databases -->
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.connection.charSet" value="UTF-8" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/webapp" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password" value="password" />
</properties>
</persistence-unit>
<persistence-unit name="M3tables">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.foo.webapp.integration.model.m3.Mitmas</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.DB2400Dialect" />
<!-- These options seem intended to be developers tools and not to facilitate
any production level databases -->
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.connection.charSet" value="UTF-8" />
<property name="hibernate.connection.driver_class" value="com.ibm.as400.access.AS400JDBCDriver" />
<property name="hibernate.connection.url" value="jdbc:as400://xx.xx.x.xxx/schema" />
<property name="hibernate.connection.username" value="username" />
<property name="hibernate.connection.password" value="password" />
</properties>
</persistence-unit>
</persistence>
Also I have configured application-context.xml as follows
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:util="http://www.springframework.org/schema/util"
xmlns:task="http://www.springframework.org/schema/task" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- JPA Repositories -->
<!-- Default Persistence Unit Manager -->
<bean id="webapp-persistence"
class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
<property name="persistenceXmlLocations">
<list>
<value>classpath*:META-INF/persistence.xml</value>
</list>
</property>
</bean>
<!-- Entity Manager for Persistance Unit -->
<bean
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
id="entityManagerFactory2">
<property name="persistenceUnitManager" ref="webapp-persistence" />
<property name="persistenceUnitName" value="M3tables" />
<property name="packagesToScan" value="com.foo.webapp.integration.model.m3" />
</bean>
<bean
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
id="entityManagerFactory1">
<property name="persistenceUnitManager" ref="webapp-persistence" />
<property name="persistenceUnitName" value="webApp-integration" />
<property name="packagesToScan" value="com.foo.webapp.integration.model.test" />
</bean>
<!-- ##################################### -->
<bean class="org.springframework.orm.jpa.JpaTransactionManager"
id="transactionManager1">
<property name="entityManagerFactory" ref="entityManagerFactory1" />
</bean>
<bean class="org.springframework.orm.jpa.JpaTransactionManager"
id="transactionManager2">
<property name="entityManagerFactory" ref="entityManagerFactory2" />
</bean>
<tx:annotation-driven mode="aspectj"
transaction-manager="transactionManager1" />
<tx:annotation-driven mode="aspectj"
transaction-manager="transactionManager2" />
<jpa:repositories base-package="com.foo.webapp.test.repository"
entity-manager-factory-ref="entityManagerFactory1" />
<jpa:repositories base-package="com.foo.webapp.repository"
entity-manager-factory-ref="entityManagerFactory2" />
<!-- JPA -end -->
</beans>
But its throwing exception as follows
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory2' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name 'M3tables' found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956) ~[spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747) ~[spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) [spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) [spring-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016) [catalina.jar:7.0.61]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528) [catalina.jar:7.0.61]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.61]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) [catalina.jar:7.0.61]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) [catalina.jar:7.0.61]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]
Caused by: java.lang.IllegalArgumentException: No persistence unit with name 'M3tables' found
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.obtainPersistenceUnitInfo(DefaultPersistenceUnitManager.java:685) ~[spring-orm-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.determinePersistenceUnitInfo(LocalContainerEntityManagerFactoryBean.java:362) ~[spring-orm-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:314) ~[spring-orm-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318) ~[spring-orm-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
... 21 more
Can anyone help on this
Comment to setPersistenceUnitName(String persistenceUnitName) method says
NOTE: Only applied if no external PersistenceUnitManager specified.
Try to specify 'persistenceXmlLocation' property instead of 'persistenceUnitManager'

Setting up Spring JTA transaction in Jboss 7.1.1

Hello I am trying to setup spring JTA in myEclipse for Spring.Below are my configuration files:
applicationContent.xml where i have added two imports(note it do include schema locations)
<import resource="infrastructure.xml"/>
<import resource="classpath:**/persistence.xml"/>
infrastrutre.xml(unable to add schema due to input validations)
<bean
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jtaDataSource" ref="masterDataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
</bean>
<!-- <bean id="masterDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/test_JTA"></property>
</bean> -->
<jee:jndi-lookup id="masterDataSource" jndi-name="java:/Test_JTA" />
<bean id="jpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<!-- <property name="databasePlatform"
value="org.hibernate.dialect.MySQL5InnoDBDialect" /> -->
<property name="database" value="MYSQL" />
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" />
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="mainPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.abc.PaymentCard</class>
<jar-file>mysql-connector-java-5.1.23-bin.jar</jar-file>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform"/>
<property key="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
</properties>
</persistence-unit>
</persistence>
I am getting error
JBAS010402: Unable to instantiate driver class "com.mysql.jdbc.Driver": org.jboss.msc.service.DuplicateServiceException: Service jboss.jdbc-driver.JTA_Test_war is already registered
I goggled this error but still haven't got any satisfactory answers.Kindly help
I am not sure about JBoss but for Glassfish there is an Ext directory for the Jars you want in the Classpath. So try to figure out how to deploy mysql-connector-java*.jar to your domain.
i know its late but, i believe i fixed this error by using a different factory class.
<property name="hibernate.transaction.factory_class" value="org.hibernate.ejb.transaction.JoinableCMTTransactionFactory"/>
hope it helps :)

Persistance in JBoss wildfly (in a spring application)

I have a spring 3.2 application which has defined persisence with the following configuration:
<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="MYSQL"/>
<property name="showSql" value="false"/>
<property name="generateDdl" value="false"/>
<property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect"/>
</bean>
<util:map id="jpaPropertyMap">
<entry key="hibernate.hbm2ddl.auto" value="update"/>
<entry key="hibernate.cache.use_query_cache" value="true" />
<entry key="hibernate.max_fetch_depth" value="4" />
<entry key="hibernate.show_sql" value="false" />
<entry key="hibernate.format_sql" value="false" />
<entry key="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
<entry key="hibernate.transaction.factory_class" value="org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory" />
<entry key="hibernate.connection.autocommit" value="false" />
</util:map>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
<property name="jtaDataSource" ref="dataSource" />
<property name="jpaPropertyMap" ref="jpaPropertyMap" />
<property name="persistenceUnitManager" ref="persistenceUnitManager" />
</bean>
<bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager" >
<property name="packagesToScan" value="gr.hcg.nautologhsh.domain" />
<property name="defaultJtaDataSource" ref="dataSource" />
</bean>
My entity classes exist under the gr.hcg.nautologhsh.domain package. I am not using any persistance.xml files.
Now, this configuration is working fine in JBoss 8 wildfly. However when I see the Administration console of JBoss, in the tag JPA, I don't see any persistance units.
From some googling I think that the persistence units have to be configured through JBoss and not through Spring in order to be visible there - is that true ? I can't really understand why there could be different PUs in JBoss - how can they be used ? The documentation of JBoss is very spartian in that subject and I couldn't understand many things :(
Can somebody explain to me how can I define JBoss persistence units and show these in the JPA tag of wildfly's administration console ?
Update
I created a persistence.xml with the following contents:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="nautologhshPU" transaction-type="JTA">
<jta-data-source>java:jboss/datasources/nautologhsh</jta-data-source>
</persistence-unit>
</persistence>
changed my datasource-config.xml beans like ths:
<jee:jndi-lookup id="dataSource" jndi-name="java:jboss/datasources/nautologhsh" resource-ref="false" />
<tx:jta-transaction-manager />
<jee:jndi-lookup jndi-name="java:comp/env/jpa/EntityManager" id="entityManager" expected-type="javax.persistence.EntityManager" />
and added the following to web.xml
<persistence-context-ref>
<persistence-context-ref-name>jpa/EntityManager</persistence-context-ref-name>
<persistence-unit-name>nautologhshPU</persistence-unit-name>
</persistence-context-ref>
And now get the following error:
20:24:41,839 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 52) MSC000001: Failed to start service jboss.persistenceunit."Nautologhsh.war#nautologhshPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."Nautologhsh.war#nautologhshPU": org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.service.classloading.spi.ClassLoaderService]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:169) [wildfly-jpa-8.0.0.Beta1.jar:8.0.0.Beta1]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.0.0.Beta1.jar:8.0.0.Beta1]
at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_45]
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:463) [wildfly-security-manager-1.0.0.Beta3.jar:1.0.0.Beta3]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:178) [wildfly-jpa-8.0.0.Beta1.jar:8.0.0.Beta1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final.jar:2.1.1.Final]
Caused by: org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.service.classloading.spi.ClassLoaderService]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:127)
at org.hibernate.envers.event.EnversIntegrator.integrate(EnversIntegrator.java:65)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1837)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:854)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:847)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:396)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:846)
at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:151) [wildfly-jpa-8.0.0.Beta1.jar:8.0.0.Beta1]
... 8 more
20:24:41,861 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "Nautologhsh.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"Nautologhsh.war#nautologhshPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"Nautologhsh.war#nautologhshPU\": org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.service.classloading.spi.ClassLoaderService]
Caused by: org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.service.classloading.spi.ClassLoaderService]"}}
Does any body know what is this org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.service.classloading.spi.ClassLoaderService] ??
You can take a look at this quickstart example: https://github.com/sgilda/wildfly-quickstart/blob/master/greeter-spring which uses a META-INF/persistence.xml file an in which Spring configuration uses lookups to retrieve the EntityManager and the Datasource from Wildfly:
<!-- Look up the database in JNDI -->
<jee:jndi-lookup jndi-name="java:jboss/datasources/ExampleDS" id="dataSource"
expected-type="javax.sql.DataSource" />
<!-- Look up the container deployed EntityManager -->
<jee:jndi-lookup jndi-name="java:comp/env/hello/EntityManager"
id="entityManager" expected-type="javax.persistence.EntityManager" />
(https://github.com/sgilda/wildfly-quickstart/blob/master/greeter-spring/src/main/webapp/WEB-INF/spring-business-context.xml)

Resources