0 Replies Latest reply on Nov 21, 2009 5:15 PM by Walt Corey

    moving JPA application using Hibernate to JBOSS 5.01

    Walt Corey Newbie

      Hi,
      I apologize for this as I am sure it is a frequent question but I have not found an answer. I have a JPA servlet that was running fine under Tomcat 6 with the persistence.xml under WEB-INF/classes/META-INF.

      This file pointed to the db, specified the dialect, etc etc

      When I moved the war file over to JBoss 5.0.1 I first discovered I needed to add the non-jta-provider element. Originally I pointed to defaultDS as the examples I did find depicted. I then received an error that indicating I could not have the hibernate jars under the web-inf/lib for the web service webapp (javax.persistence class casting). I removed all the hibernate jars from the local web-inf/lib. I next received an error indicating the dialect (MySQLDialect) could not be cast to Dialect. As it happens I also have a Seam application that uses the same logical database So I thought perhaps it was related to the datasource specification. I next changed that specification <non-jta-data-source> to point to the same ds that the seam app uses. I still have the same error about the dialect. Below is the specified persistence.xml. Would someone be kind enough to either paste a reference to a quick how-to move a j2se based jpa web app to jboss 5.0.1 or explain what it is that is wrong with the below file.

      Thanks,

      Walt

      Here is the error:

      DEPLOYMENTS MISSING DEPENDENCIES:
      Deployment "persistence.unit:unitName=#CU3JPAPU" is missing the following dependencies:
      Dependency "jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding" (should be in state "Create", but is actually in state "** NOT FOUND Depends on 'jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding' **")

      DEPLOYMENTS IN ERROR:
      Deployment "jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding" is in error due to the following reason(s): ** NOT FOUND Depends on 'jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding' **

      Here is the persistence.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="1.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/ ... ce_1_0.xsd">
      <persistence-unit name="CU3JPAPU" transaction-type="RESOURCE_LOCAL">
      org.hibernate.ejb.HibernatePersistence
      <non-jta-data-source>java:/UpdaterDatasource transaction-type="RESOURCE_LOCAL"</non-jta-data-source>

      <!--property name="jboss.entity.manager.factory.jndi.name" value="java:/UpdaterEntityManagerFactory"/-->




      <!--property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/-->


      <!--property name="hibernate.c3p0.min_size" value="5"/>





      <property name="hibernate.format_sql" value="false"/-->


      </persistence-unit>


      This works fine in tomcat using effectively the same persistence.xml.
      The non-jta-data-source element was added as I worked through all sorts of deployment issues ending here. Isn't there a simple way to do this. The application is resource-local as it bootstraps its own EntityManagerFactory from the static under Persistence. I did find a jira indicating it should work and was fixed but it doesn't appear to be to me.

      Thanks,

      Walt