7 Replies Latest reply on Apr 1, 2011 1:04 PM by vincent_aumont

    app/jdbc/xyz should be a valid datasource name in jndi ( Jboss AS 6.Final)

    vincent_aumont

      Hello,

       

      I have this resource defined in a *-ds.xml file:

       

       

      {code}

      <datasources>

          <local-tx-datasource>

            <jndi-name>app/jdbc/MyDS</jndi-name>

            <connection-url>xxx</connection-url>

             <driver-class>oracle.jdbc.OracleDriver</driver-class>

            <user-name>xxx</user-name>

            <password>xxx</password>

          </local-tx-datasource>

       

      </datasources>

      {code}

       

      It causes the following error:

       

      {code}

      17:27:45,220 ERROR [AbstractKernelController] Error installing to Real: name=vfs:///Users/vincent/dev/appservers/jboss-6.0.0.Final/server/default/deploy/foo-ds.xml state=PreReal mode=Manual requiredState=Real: org.jboss.deployers.spi.DeploymentException: Could not bind ConnectionFactory into jndi: java:app/jdbc/MyDS

          at org.jboss.resource.connectionmanager.ConnectionFactoryBindingService.bindConnectionFactory(ConnectionFactoryBindingService.java:164) [:6.0.0.Final]

          at org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService.startService(WrapperDataSourceService.java:108) [:6.0.0.Final]

          at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:355) [:6.0.0.Final (Build SVNTag:JBoss_6.0.0.Final date: 20101228)]

          at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:301) [:6.0.0.Final (Build SVNTag:JBoss_6.0.0.Final date: 20101228)]

      [...]

      Caused by: javax.naming.NamingException: java:app not supported by legacy component null

          at org.jboss.reloaded.naming.service.AppObjectFactory.getObjectInstance(AppObjectFactory.java:52) [:0.3.0]

          at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) [:1.6.0_24]

          at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1483) [:5.0.5.Final]

          at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1500) [:5.0.5.Final]

          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:824) [:5.0.5.Final]

          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688) [:5.0.5.Final]

          at javax.naming.InitialContext.lookup(InitialContext.java:392) [:1.6.0_24]

          at org.jboss.util.naming.Util.createSubcontext(Util.java:70) [jboss-common-core.jar:2.2.17.GA]

          at org.jboss.util.naming.NonSerializableFactory.rebind(NonSerializableFactory.java:248) [jboss-common-core.jar:2.2.17.GA]

          at org.jboss.resource.connectionmanager.ConnectionFactoryBindingService.bindConnectionFactory(ConnectionFactoryBindingService.java:159) [:6.0.0.Final]

          ... 79 more

      {code}

       

      Changing the jndi name to:

       

       

      {code}

      <jndi-name>jdbc/MyDS</jndi-name>

      {code}

       

      fixes the problem, but section EE.5.17   (DataSource Resource Definition) of the EE 6 specs clearly states that:

       

      {code}

      The DataSource resource may be defined in any of the JNDI namespaces

      described in Section EE.5.2.2, “Application Component Environment Namespaces”.

       

      For example,a DataSource resource may be defined:

      • in the java:comp namespace,for use by a singlecomponent;

      • in the java:module namespace, for use by all components in amodule;

      • in the java:app namespace,for use by all components in an application;

      • in the java:global namespace,for use by all applications.

      {code}

       

       

      So, app/jdbc/MyDS should be a valid jndi name for this data source (and it works fine on Glassfish 3.1).

       

       

      Am I missinterpreting  the spec, or is jboss AS 6 non-compliant?

       

      Thanks,

       

      -Vincent

        • 1. app/jdbc/xyz should be a valid datasource name in jndi ( Jboss AS 6.Final)
          jaikiran

          *-ds.xml isn't a Java EE spec descriptor. If you want to configure a Java EE datasource, then use the web.xml or ejb-jar.xml to do so. You can then use the app/ prefix.

          • 2. app/jdbc/xyz should be a valid datasource name in jndi ( Jboss AS 6.Final)
            vincent_aumont

            Are you saying I should  keep the datasource definition in the *-ds.xml file, but override the jndi name in web.xml/ejb-jar.xml?

            • 3. app/jdbc/xyz should be a valid datasource name in jndi ( Jboss AS 6.Final)
              genman

              All JNDI entries should be mapped from the server's context into an application's local context. You do this using jboss-web.xml or jboss.xml, depending.

              • 4. Re: app/jdbc/xyz should be a valid datasource name in jndi ( Jboss AS 6.Final)
                vincent_aumont

                Okay, that's teh part I'm struggling with. Given this entry in *-ds.xml :

                 

                {code}

                <datasources>
                    <local-tx-datasource>
                      <jndi-name>jdbc/MyDS</jndi-name>
                      <connection-url>xxx</connection-url>
                       <driver-class>oracle.jdbc.OracleDriver</driver-class>
                      <user-name>xxx</user-name>
                      <password>xxx</password>
                    </local-tx-datasource>

                </datasources>

                {code}

                 

                What would web.xml/jboss-web.xml would look like id I want to map the DS to java:app/jdbc/MyDS ?

                 

                Thanks,

                 

                Vincent

                • 5. Re: app/jdbc/xyz should be a valid datasource name in jndi ( Jboss AS 6.Final)
                  vincent_aumont

                  I thought this would do the trick:

                   

                  web.xml:

                  {code}

                  <resource-ref> 

                  <res-ref-name>jdbc/MyDS</res-ref-name> 

                  <res-type>javax.sql.DataSource</res-type> 

                  <res-auth>Container</res-auth> 

                  </resource-ref>

                  {code}

                   

                   

                  jboss-web.xml:

                  {code}

                  <resource-ref>

                          <res-ref-name>jdbc/MyDS</res-ref-name>

                          <res-type>javax.sql.DataSource</res-type>

                          <jndi-name>java:app/jdbc/myDS</jndi-name>

                  </resource-ref>

                  {code}

                   

                  But it didn't remap the DS to java:/app/jdbc/myDS.

                   

                  Am I on the wrong track here?

                  • 6. Re: app/jdbc/xyz should be a valid datasource name in jndi ( Jboss AS 6.Final)
                    vincent_aumont

                    I also tried this:

                     

                     

                    persistence.xml:

                    {code}

                    <persistence-unit name="myPU" transaction-type="JTA">

                       <jta-data-source>java:app/jdbc/MyDS</jta-data-source>

                    [...]

                    </persistence-unit>

                    {code}

                    I want the 'app' context for portability reasons (amongst other things we're using GF emebdded for some of our unit tests)

                     

                     

                    *-ds.xml:

                    {code}

                    <jndi-name>jdbc/MyDS</jndi-name>

                    {code}

                    (jboss does not support app/jdbc/MyDS in *-ds.xml)

                     

                    web.xml:

                    {code}

                    <resource-ref> 

                      <res-ref-name>app/jdbc/MyDS</res-ref-name> 

                      <res-type>javax.sql.DataSource</res-type> 

                      <res-auth>Container</res-auth> 

                      <res-sharing-scope>Shareable</res-sharing-scope>

                    </resource-ref>

                     

                    {code}

                     

                    jboss-web.xml:

                    {code}

                    <resource-ref>

                            <res-ref-name>app/jdbc/MyDS</res-ref-name>

                            <res-type>javax.sql.DataSource</res-type>

                            <jndi-name>java:jdbc/MyDS</jndi-name>

                       </resource-ref>

                    {code}

                     

                    I thought this would remap java:jdbc/MyDS to java:app/jdbc/MyDS, but it didnt work: jboss still complains that it cannot bind to app/jdbc/MyDS:

                     

                    {code}

                    Deployment "persistence.unit:unitName=my-war.war#myPU" is missing the following dependencies:

                        Dependency "jboss.jca:name=app/jdbc/MyDS,service=DataSourceBinding" (should be in state "Create", but is actually in state "** NOT FOUND Depends on 'jboss.jca:name=app/jdbc/MyDS,service=DataSourceBinding' **")

                    {code}

                     

                    Here is  the structure of my war file:

                    {code}

                    my-war

                      +-- WEB-INF

                        + web.xml

                        + jboss-web.xml

                        +-- lib

                           + pu.jar   <== contains persistence.xml

                           + ejb-jar.jar 

                    {code}

                     

                     

                    Could it be that jboss hasn't processed web.xml and jboss.xml when it processes presistence.xml (in pu.jar)?

                    • 7. Re: app/jdbc/xyz should be a valid datasource name in jndi ( Jboss AS 6.Final)
                      vincent_aumont

                      So, my reading of this is that it is not possible to put a datasource in the java:app context:

                       

                      1) Using <jndi-name>app/jdbc/MyDS</jndi-name> in a *-ds.xml file generates the  'java:app not supported by legacy component null' message

                      2) With jboss-web/xml and web.xml you can change the name of the datasource (MyDS -> TheDS), but not the context.

                       

                      Bottom line; if I have an EE-6-compliant  persistence jar that contains a persistence unit that expects a datasource in the java:/app context (<jta-data-source>java:app/jdbc/MyDS</jta-data-source>) , this jar cannot be used in AS 6.