3 Replies Latest reply on Jun 26, 2005 4:59 PM by Shane Bryzak

    Beta: Can't use non-default datasource

    Shane Bryzak Master

      Maybe its just me, but with the new Beta I can't seem to get my application to work with a datasource other than DefaultDS. The structure of my .ear file look like this:

      my-app.ear
       |-my-app.par
       |-my-app.ejb3
       |-my-app.war
       |-application.xml
      


      application.xml contains something like:
      <application>
       <display-name>My Project</display-name>
       <description>My Project Description</description>
       <module>
       <ejb>my-app.par</ejb>
       </module>
       <module>
       <ejb>my-app.ejb3</ejb>
       </module>
       <module>
       <web>
       <web-uri>my-app.war</web-uri>
       <context-root>/my-app</context-root>
       </web>
       </module>
      </application>
      


      my-app.par contains the following meta-inf/persistence.xml:

      <entity-manager>
       <name>manager1</name>
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/MyDS</jta-data-source>
       <class>com.myapp.data.MyDataClass</class>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
       <property name="hibernate.hbm2ddl.auto" value="update"/>
       </properties>
      </entity-manager>
      


      I've also tried using a hibernate.properties (which was working with Preview 5), but no luck with this either. Has anyone had any luck using a datasource other then DefaultDS with the Beta?

      Shane Bryzak

        • 1. Re: Beta: Can't use non-default datasource
          Leos Urban Newbie

           

          "sbryzak2" wrote:


          my-app.ear
           |-my-app.par
           |-my-app.ejb3
           |-my-app.war
           |-application.xml
          



          I mean that application.xml must be in META-INF folder.

          # jar tvf tutorial.ear
          META-INF/
          META-INF/application.xml
          tutorial.ejb3
          em1.par
          em2.par
          


          Leonell

          • 2. Re: Beta: Can't use non-default datasource
            Leos Urban Newbie

            Hello,
            I tested it and new EAR package worked (with non-default datasource).
            You need move application.xml to META-INF and modify your session bean to map Entity manager to persist.xml in par package.
            See packaging example in tutorial.

            Also note: you right, in ejb3 archives (and Beta) is used default dataset regardless of META-INF/hibernate.properties setting.

            Leonell

            • 3. Re: Beta: Can't use non-default datasource
              Shane Bryzak Master

               

              "leonell" wrote:
              I tested it and new EAR package worked (with non-default datasource).
              You need move application.xml to META-INF and modify your session bean to map Entity manager to persist.xml in par package.
              See packaging example in tutorial.

              Also note: you right, in ejb3 archives (and Beta) is used default dataset regardless of META-INF/hibernate.properties setting.


              My application.xml is actually in the meta-inf directory (sorry about the mixup there). I think the problem is my session bean, as you pointed out. I found the new @PersistenceContext annotations in the tutorial source code (though no mention of it in tutorial/packaging/packaging.html, maybe there should be something here? :) and will try them today (I imagine they will solve my problem). Thanks for pointing me in the right direction.

              Shane