7 Replies Latest reply on Apr 7, 2008 8:15 AM by Jeroen Wenting

    *-ds.xml not being bound to JNDI Name

    Jamie Johnson Newbie

      What is required to have a *-ds.xml file deploy under JBoss? I am going through http://www.eclipse.org/webtools/dali/docs/tutorial_1.0/dali_jsf_tutorial.htm and trying to modify it to use Hibernate provided by JBoss. Currently my persistence.xml file species all the JDBC connection information but I would like to replace this information with something like

      <persistence...>
       <persistence-unit name="default">
       <class>...</class>
       <jta-data-source>java:jdbc/DaliDS</jta-data_source>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
       <property name="hiernate.hbm2dll.auto" value="update"/>
       </properties>
       </persistence-unit>
      </persistence>

      But this doesn't seem to work, which I am assuming is because the datasource is not being bound.

      here is my dali-ds.xml file
      <datasources>
       <local-tx-datasource>
       <jndi-name>DaliDS</jndi-name>
       <connection-url>jdbc:derby://localhost:1527/sample;create=true</connection-url>
       <driver-class>org.apache.derby.jdbc.ClientDriver</driver-class>
       <user-name>dali</user-name>
       <password>dali</password>
       </local-tx-datasource>
      </datasources>
      


      What could be causing this ds.xml file not to be read?

        • 1. Re: *-ds.xml not being bound to JNDI Name
          jaikiran pai Master

          In your dali-ds.xml, you have specified the jndi-name as DaliDS. JBoss by default, binds the datasource to the java: namespace. This means that the datasource will be available at java:DaliDS. So your, persistence.xml should contain the following:

          <jta-data-source>java:DaliDS</jta-data_source>


          • 2. Re: *-ds.xml not being bound to JNDI Name
            Jamie Johnson Newbie

            Great, only problem is I don't see that being bound either. I see it get bound if I place my -ds.xml file in the deploy directory, but not if I put it under my ear directory. Am I missing something? Is there something else that I need to do to get this to work?

            Also, when I deploy my application I am getting an error complaining about the tag <jta-data-source> (don't have the exact error, the code is at work), is there something I did wrong with my persistence.xml that I listed below?

            • 3. Re: *-ds.xml not being bound to JNDI Name
              Jamie Johnson Newbie

              I see that in the persistence-unit tag there is an attribute named transaction-type, does this have ot be set to JTA in order to use jta-data-source tag?

              • 4. Re: *-ds.xml not being bound to JNDI Name
                jaikiran pai Master

                 

                "jej2003" wrote:
                I see it get bound if I place my -ds.xml file in the deploy directory, but not if I put it under my ear directory. Am I missing something? Is there something else that I need to do to get this to work?


                If you want to deploy the -ds.xml file as part of your EAR, then you will have to create a jboss-app.xml and place the jboss-app.xml in the META-INF folder of your EAR. The -ds.xml can then be placed at the root of the EAR. Your jboss-app.xml should contain something like this:
                
                <?xml version="1.0" encoding="ISO-8859-1"?>
                <!DOCTYPE jboss-app
                 PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN"
                 "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
                <jboss-app>
                 <module>
                 <service>dali-ds.xml</service>
                 </module>
                
                
                
                </jboss-app>


                "jej2003" wrote:

                Also, when I deploy my application I am getting an error complaining about the tag <jta-data-source> (don't have the exact error, the code is at work), is there something I did wrong with my persistence.xml that I listed below?


                Can't say, without looking at the exception stacktrace. Post it, once you have access to it.


                • 5. Re: *-ds.xml not being bound to JNDI Name
                  Jamie Johnson Newbie

                  ah, ok, so it is not the j2ee standard to place these at the root of your app, is there somewhere I can read about thigns like tihs?

                  I will post the full stack trace when I get back to work, thanks again!

                  • 6. Re: *-ds.xml not being bound to JNDI Name
                    jaikiran pai Master

                     

                    "jej2003" wrote:
                    ah, ok, so it is not the j2ee standard to place these at the root of your app, is there somewhere I can read about thigns like tihs?



                    I usually read the wiki http://wiki.jboss.org/wiki
                    and the documentation http://www.jboss.org/jbossas/docs/index.html


                    • 7. Re: *-ds.xml not being bound to JNDI Name
                      Jeroen Wenting Newbie

                      There is no standardised way to create and maintain datasources, that's left to the appserver implementors.
                      JBoss does it through these xml configuration files, others might store the data in an internal database accessible only through a frontend of some sort, others again might use properties files or a custom file format, etc. etc.