-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Migrating Tomcat servlet (JPA) to JBoss
PostPosted: Sat Nov 21, 2009 3:38 pm 
Newbie

Joined: Thu Nov 05, 2009 11:31 am
Posts: 8
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">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>java:/UpdaterDatasource transaction-type="RESOURCE_LOCAL"</non-jta-data-source>
<properties>
<!--property name="jboss.entity.manager.factory.jndi.name" value="java:/UpdaterEntityManagerFactory"/-->
<property name="hibernate.connection.username" value="me"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.password" value="mypass"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/upd"/>
<!--property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/-->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>

<!--property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="50"/>
<property name="hibernate.c3p0.max_statements" value="100"/>
<property name="hibernate.c3p0.idle_test_period" value="3000"/>
<property name="hibernate.c3p0.max_timeout" value="300"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/-->

</properties>
</persistence-unit>
</persistence>


Top
 Profile  
 
 Post subject: Re: Migrating Tomcat servlet (JPA) to JBoss
PostPosted: Sun Nov 22, 2009 12:12 am 
Newbie

Joined: Thu Nov 05, 2009 11:31 am
Posts: 8
After much trial and error and false starts I discovered my problem.

It is important that the web-inf/lib contain NO hibernate jar files or javassist.jar. The original error, which was, the MySQLDialect could not be cast to Dialect was due to the mismatched hibernate jars. So be careful here.



The final persistence.xml is:

I believe I could live better without the class elements as this version of hibernate will discover them.
The c3p0 properties, even though commented out, I left in as the non-jta-data-source should have connection and statement pooling in it not here.


Code:
<?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/persistence_1_0.xsd">
  <persistence-unit name="CU3JPAPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <non-jta-data-source>java:/LuceneResumeDatasource</non-jta-data-source>
    <properties>
      <!--property name="jboss.entity.manager.factory.jndi.name" value="java:/UpdaterEntityManagerFactory"/-->
      <!--property name="hibernate.connection.username" value="root"/>
      <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
      <property name="hibernate.connection.password" value=""/>
      <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/upd"/-->
      <!--property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/-->
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
     
      <!--property name="hibernate.c3p0.min_size" value="5"/>
      <property name="hibernate.c3p0.max_size" value="50"/>
      <property name="hibernate.c3p0.max_statements" value="100"/>
      <property name="hibernate.c3p0.idle_test_period" value="3000"/>
      <property name="hibernate.c3p0.max_timeout" value="300"/>
      <property name="hibernate.show_sql" value="false"/>
      <property name="hibernate.format_sql" value="false"/-->

    </properties>
  </persistence-unit>
</persistence>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.