Spring 3 + JPA 2 + Hibernate application deployment fails on JBoss 5.1 and 6.0
I just can't get my JPA 2 + Spring 3 + hibernate application to deploy in JBoss - neither on JBoss 5.1 nor on JBoss 6.0. The same application works fine in Jetty and Tomcat
I have read that JBoss 5.1 supports only JPA1. JBoss 6 is suppose to support 6.0.
My last error (in JBoss 6.0) was:
Code:
09:49:32,062 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=gateway-2.2.4-SNAPSHOT.war#ApplicationEntityManager state=Create: java.lang.RuntimeException: Specification violation [EJB3 JPA 6.2.1.2] - You have not defined a non-jta-data-source for a RESOURCE_LOCAL enabled persistence context named: ApplicationEntityManager
at org.jboss.jpa.impl.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:133) [:2.0.0]
When I look at the Persistence XSD @ http://java.sun.com/xml/ns/persisten...stence_2_0.xsd, non-jta-data-source is an optional element.
Code:
<xsd:element name="non-jta-data-source" type="xsd:string"
minOccurs="0">
<xsd:annotation>
<xsd:documentation>
The container-specific name of a non-JTA datasource to use.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
What I have is a Spring based application and I use the following beans to configure my EntityManager:
Code:
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
p:driverClassName="${db.driver}"
p:url="${db.url}"
p:username="${db.username}"
p:password="${db.password}" />
and
Code:
<bean id="jpaDialect"
class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource"
p:persistenceUnitName="${persistence.unitname}"
p:jpaDialect-ref="jpaDialect"
p:jpaPropertyMap-ref="jpaPropertyMap"
p:jpaVendorAdapter-ref="jpaAdapter">
</bean>
My persistence.xml look like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<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="ApplicationEntityManager" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<!-- Validation modes: AUTO, CALLBACK, NONE -->
<validation-mode>CALLBACK</validation-mode>
<properties>
<property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.SingletonEhCacheProvider" />
<property name="hibernate.cache.provider_configuration" value="/ehcache.xml" />
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="hibernate.cache.use_query_cache" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<!--
If enabled, the session will be automatically flushed during
the before completion phase of the transaction.
-->
<property name="hibernate.transaction.flush_before_completion" value="false"/>
</properties>
</persistence-unit>
</persistence>
Why is JBoss forcing me define non-jta-data-source even though it is optional in the XSD? I am providing the datasource through Spring Binding, am I not?
Am I missing something here?
JPA2 application deployment possible on JBoss51