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

    config for using persistence.xml

    Marc Reis Novice

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

      ObjectName: jboss.jca:name=jdbc/MYDB,service=ManagedConnectionFactory
       Depends On Me:

      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).

      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/

      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.


        • 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)....

             <persistence-unit name="entwDS">
             <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
             <property name="hibernate.hbm2ddl.auto" value="create-drop"/>

            and the data source file...
            <?xml version="1.0" encoding="UTF-8"?>

            leads to
            12:34:54,515 INFO [EJB3Deployer] Deployed: file:/C:/work/_programme/jboss-4.0.4
            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:
            ObjectName: jboss.jca:name=jdbc/OLGAENTW,service=ManagedConnectionFactory
             State: NOTYETINSTALLED
             Depends On Me: