2 Replies Latest reply on Jun 16, 2006 6:38 AM by Marc Reis

    config for using persistence.xml

    Marc Reis Novice

      Hi,
      the Problem is that when I use the jar with persistence.xml it says:

      ObjectName: jboss.jca:name=jdbc/MYDB,service=ManagedConnectionFactory
       State: NOTYETINSTALLED
       Depends On Me:
       persistence.units:jar=EJBTest2EJB.jar,unitName=entwDS
      


      I used to use the hibernate-service.xml (ejb.har) and a hibernat.cfg.xml(ejb.jar) in my Application (App.ear). With a Utility class I build the SessionFactory and used it in my beans. The DataSource was defined in a mydata-ds.xml, which defines an oracle db as a Datasource. The entity beans are mapped via a MyEntity.hbm.xml. In that scenario all works fine concerning this matter (all ejb 3).

      Now,
      I wanted to go towards using the annotations in the Entity classes and use a persistence.xml file for the persicetence-unit to see how this works and make things easier. My setup is basicly like the one in the ejb3 trailblaizer (more or less).
      I just use a jar file, which contains all the classes and has a persistence.xml in its META-INF (and an empty ejb-jar.xml). The persistence.xml has the same properties set as in the hibernate.cfg.xml.
      As it JTA-data-source it uses the ds (java:/jdbc/MYDB) defined in the mydata-ds.xml (which is always deployed, not part of the jar).

      It seems it cant use the DataSource which works for the alternative approach. The only thing that I see is that the bound datasource has: service=DataSourceBinding and not service=ManagedConnectionFactory:
      14:23:00,250 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jb
      oss.jca:service=DataSourceBinding,name=/jdbc/OLGAENTW' to JNDI name 'java:/jdbc/
      OLGAENTW'

      So what am I missing in the config ? I read all the docu and trail blaizer and all that they say, I thing do: have your jar with its persistence.xml and a *-ds.xml for your data sources and of course use the correct names defined.

      Thanks


        • 1. Re: config for using persistence.xml
          Marc Reis Novice

          Just saw that I have a typo in the post, both ds have the same name java:/jdbc/OLGAENTW and are not different.
          By misstake I copied the first code snipit with java:/jdbc/MYDB.

          • 2. Re: config for using persistence.xml
            Marc Reis Novice

            I am still having the problem... I can configure it as an MBean (hibernate-service.xml) and it works fine, use a utility class for a static factory and the hibernate.cfg.xml and it works.
            But with the persistence.xml, it seems I am missing something. I read over the documentation again and again (JBossAS, EJB3Persistence, TrailBlaizer etc.) since I thought my question is to obvious...
            If it is, please still feel free to mention it to me ;).
            I hope my persistence.xml and the mydata-ds.xml give some hints (these are the minimalistic versions)....
            Thanks!

            <persistence>
             <persistence-unit name="entwDS">
             <provider>org.hibernate.ejb.HibernatePersistence</provider>
             <jta-data-source>jdbc/OLGAENTW</jta-data-source>
             <properties>
             <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
             <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
             </properties>
             </persistence-unit>
            </persistence>
            

            and the data source file...
            <?xml version="1.0" encoding="UTF-8"?>
            <datasources>
             <local-tx-datasource>
             <jndi-name>/jdbc/OLGAENTW</jndi-name>
             <connection-url>jdbc:oracle:thin:@somewhere.de:1234:olgaentw</connection-url>
             <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
             <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
             <metadata>
             <type-mapping>Oracle</type-mapping>
             </metadata>
             </local-tx-datasource>
            <datasources>
            

            leads to
            12:34:54,515 INFO [EJB3Deployer] Deployed: file:/C:/work/_programme/jboss-4.0.4
            .GA-ejb3/server/default/deploy/EJBTest2EJB.jar
            12:34:54,609 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
            --- MBeans waiting for other MBeans ---
            ObjectName: persistence.units:jar=EJBTest2EJB.jar,unitName=entwDS
             State: NOTYETINSTALLED
             I Depend On:
             jboss.jca:name=jdbc/OLGAENTW,service=ManagedConnectionFactory
            
            --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
            ObjectName: jboss.jca:name=jdbc/OLGAENTW,service=ManagedConnectionFactory
             State: NOTYETINSTALLED
             Depends On Me:
             persistence.units:jar=EJBTest2EJB.jar,unitName=entwDS