JPA 2 support in JBoss
rajan11 Dec 7, 2010 11:01 AMI am extremely frustrated with the support (or lack of) for JPA 2 in JBoss.
I just can't get my JPA 2 + Spring 3 + hibernate application to deploy in JBoss - JBoss 5.1 is just too rigid to support JPA 2 and JBoss 6.0 is not ready yet...
My application that runs perfectly fine in Jetty or Tomcat, simply fails in JBoss 6.0 (Don't get me started with my experience with JBoss 5.1).
My last error was:
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/persistence/persistence_2_0.xsd, non-jta-data-source is an optional element.
<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:
<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
<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>
Why is JBoss forcing me define non-jta-data-source ?
Am I missing something here?
RD