Persistance in JBoss wildfly (in a spring application) - spring

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)

Related

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>

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 :)

Issue with JMS + AOP + JNDI Resources

Hi and happy new year
I'm working on a project which need to implement jms, aop and some jndi resources.
So far, the project works fine when there are only jms and jndi but when i activated aop, i had some troubles.. here is the configuration :
<!-- JMS implementation -->
<bean id="jmsRefConnectionFactory.activemq" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jms/activeMQConnectionFactory" />
<property name="lookupOnStartup" value="false" />
<property name="proxyInterface" value="javax.jms.QueueConnectionFactory" />
</bean>
<bean id="jmsRefQueue.activemq" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jms/activeMQQueue" />
<property name="lookupOnStartup" value="false" />
<property name="proxyInterface" value="javax.jms.Queue" />
</bean>
<bean id="jmsConnectionFactory.activemq" class="org.springframework.jms.connection.SingleConnectionFactory">
<constructor-arg ref="jmsRefConnectionFactory.activemq" />
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="jmsConnectionFactory.activemq" />
<property name="defaultDestination" ref="jmsRefQueue.activemq" />
<property name="destinationResolver" ref="jmsDestinationResolver.amq" />
<property name="sessionTransacted" value="true" />
<property name="sessionAcknowledgeMode" value="#{T(javax.jms.Session).CLIENT_ACKNOWLEDGE}" />
</bean>
<bean id="transactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="jmsRefConnectionFactory.activemq" />
</bean>
<bean id="jmsDestinationResolver.amq"
class="org.springframework.jms.support.destination.DynamicDestinationResolver" />
When I start the application, I get this error :
Caused by: org.springframework.aop.AopInvocationException: AOP configuration seems to be invalid: tried calling method [public abstract javax.jms.Connection javax.jms.ConnectionFactory.createConnection() throws javax.jms.JMSException] on target [org.apache.activemq.ActiveMQConnectionFactory#239f 6]; nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class
Context.xml content :
<!-- APACHE MQ -->
<Resource name="jms/activeMQConnectionFactory" auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory" HOST="localhost"
PORT="61616" CHAN="" TRAN="1" QMGR="MyQCF" />
<Resource name="jms/activeMQQueue" auth="Container"
type="org.apache.activemq.command.ActiveMQQueue" description="my Queue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="userQueue" />
Web.xml content :
<resource-ref>
<res-ref-name>jms/activeMQConnectionFactory</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/activeMQQueue</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
This configuration is OK when aop is not activated but for some reasons, it doesn't work when aop is on..
Spring version : 3.1.2
I'm using activemq (5.7)
I found out what was the problem..
Turns out the aop was not even involved (at least not the configuration that i put). I had some jar in my tomcat server that was not taken for some reasons (i think it's about lib priority/ parent first/last)...
I changed the location and directly put into my project and it works now ! :)

Jboss 7 - Spring - using Jboss TransactionManager

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){...}

spring eclipselink problem with IntegrityException

I try to use spring with eclipseLink and I've got an IntegrityException.
This is my configuration:
<?xml version="1.0" encoding="UTF-8"?>
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<import resource="data-source.xml" />
<tx:annotation-driven mode="proxy"
transaction-manager="transactionManager" />
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />
<!-- Entity manager -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitName" value="unit1" />
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver"/>
</property>
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="databasePlatform" value="org.eclipse.persistence.platform.database.DerbyPlatform" />
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />
</bean>
<!-- <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> -->
<!-- <property name="databasePlatform" value="org.hibernate.dialect.DerbyDialect"
/> -->
<!-- <property name="showSql" value="true" /> -->
<!-- <property name="generateDdl" value="true" /> -->
<!-- </bean> -->
</property>
</bean>
<bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
and exactly exception is:
[EL Config]: 2011-06-09 00:15:24.061--ServerSession(2050312009)--Connection(473155160)--Thread(Thread[main,5,main])--Connected: jdbc:derby://localhost:1527/springhib;create=true
User: app
Database: Apache Derby Version: 10.6.2.1 - (999685)
Driver: Apache Derby Network Client JDBC Driver Version: 10.7.1.1 - (1040133)
[EL Severe]: 2011-06-09 00:15:24.127--ServerSession(2050312009)--Thread(Thread[main,5,main])--Local Exception Stack:
Exception [EclipseLink-0] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions:
Exception [EclipseLink-148] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The container policy [CollectionContainerPolicy(class org.eclipse.persistence.indirection.IndirectSet)] is not compatible with transparent indirection.
Mapping: org.eclipse.persistence.mappings.ManyToManyMapping[comments]
Descriptor: RelationalDescriptor(pl.adaknet.hibspring.domain.ArtEntity --> [DatabaseTable(ARTENTITY)])
but i don't have this problem when I use another Vendor
org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
any ideas?
Try to use this loadtimeweaver implementation:
package net.palesz.util;
import org.springframework.instrument.classloading.SimpleLoadTimeWeaver;
public class JpaAwareLoadTimeWeaver extends SimpleLoadTimeWeaver {
#Override
public ClassLoader getInstrumentableClassLoader() {
ClassLoader instrumentableClassLoader = super.getInstrumentableClassLoader();
if (instrumentableClassLoader.getClass().getName().endsWith("SimpleInstrumentableClassLoader")) {
return instrumentableClassLoader.getParent();
} else {
return instrumentableClassLoader;
}
}
}
Spring context.xml config:
<bean id="loadTimeWeaver" class="net.palesz.util.JpaAwareLoadTimeWeaver" />
An odd error because IndirectSet is valid. It seems to be a class loader issue, but I have not seen this in Spring before.
It could be related to your usage of loadTimeWeaver, so you could try removing that.
In what environment are you running Spring?
you have to use agent for dynamic weaving
-javaagent:spring-agent-2.5.6.jar
i had tried eclipseLink agent, but it didn't work.
more info about weaving for JPA on Spring:
http://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch14s06.html
if you would like run your code on tomcat:
http://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch14s06.html#orm-jpa-setup-lcemfb-tomcat

Resources