5 Replies Latest reply on Dec 17, 2012 5:36 AM by nickarls

    Defining resources in deployment descriptor

    teg79

      My application is composed by a war and some ejb-jar

      The web app has its own jboss-web.xml with the datasource resource-ref definition:

      <jboss-web>

          <resource-ref>

              <res-ref-name>app/myDatasource</res-ref-name>

              <jndi-name>java:/oracle/myDatasource</jndi-name>

          </resource-ref>

      </jboss-web>

       

      I need to define the same deployment descriptor for the ejb-jars, searching the forum I found that I have to use the jboss-ejb3.xml but I cannot find the documentation or any example defining the resource-ref element in this file.

       

      Can someone point me to some example?

        • 1. Re: Defining resources in deployment descriptor
          nickarls

          Hmm, not sure, there is something in the metadata project: https://github.com/jboss/metadata/tree/master/ejb/src/main/resources/schema

          1 of 1 people found this helpful
          • 2. Re: Defining resources in deployment descriptor
            teg79

            Thanks for the link, this is my jboss-ejb3.xml:

             

            <?xml version="1.1" encoding="UTF-8"?>

            <jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee"

                           xmlns="http://java.sun.com/xml/ns/javaee"

                           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                           xmlns:c="urn:clustering:1.0"

                           xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"

                           version="3.1"

                           impl-version="2.0">

                <resource-ref>

                    <res-ref-name>app/myDatasource</res-ref-name>

                    <jndi-name>java:/oracle/myDatasource</jndi-name>

                </resource-ref>

            </jboss:ejb-jar>

             

            But this is not working... the error is

             

            org.hibernate.service.jndi.JndiException: Unable to lookup JNDI name [app/myDatasource]

                    at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:68) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:116) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:234) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:91) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                    ... 34 more

            Caused by: javax.naming.NameNotFoundException: app/myDatasource -- service jboss.naming.context.java.app.myDatasource

                    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)

                    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)

                    at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:113)

                    at javax.naming.InitialContext.lookup(InitialContext.java:396) [rt.jar:1.6.0_29]

                    at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:65) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                    ... 49 more

            • 3. Re: Defining resources in deployment descriptor
              nickarls

              How is the datasource defined in standalone.xml?

              • 4. Re: Defining resources in deployment descriptor
                teg79

                Here the standalone.xml fragment:

                 

                 

                                <datasource jta="true" jndi-name="java:/oracle/myDatasource" pool-name="MyOracleDS" enabled="true" use-java-context="true" use-ccm="true">

                                    <connection-url>jdbc:oracle:thin:@server:1521:SID</connection-url>

                                    <driver>oracle</driver>

                                    <pool>

                                        <max-pool-size>1</max-pool-size>

                                    </pool>

                                    <security>

                                        <user-name>USER</user-name>

                                        <password>PWD</password>

                                    </security>

                                </datasource>

                • 5. Re: Defining resources in deployment descriptor
                  nickarls

                  Not sure you can have a resoure-ref dangling around like that without it being in e.g. a session bean definition.

                  Here is another thread on the matter: https://community.jboss.org/message/718466