1 Reply Latest reply on Sep 30, 2013 9:41 AM by sfcoy

    How to configure resource reference ?

    yan.langlois

      I have an application which works fine on JBoss AS7.1.1. I would like to deploy it on wildfly-8.0.0.Alpha4. I use wildfly-8.0.0.Alpha4 in domain mode. I have this data source deployed :

       

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

      <datasources xmlns="http://www.jboss.org/ironjacamar/schema"

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

          xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">

           <datasource jndi-name="java:/datasources/standardDS" pool-name="kpi" enabled="true" use-java-context="true">

                <connection-url>jdbc:h2:mem:xxx;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1;MODE=Oracle;MVCC=true</connection-url>

                <driver>h2</driver>

                <security>

                     <user-name>sa</user-name>

                     <password>sa</password>

                </security>

           </datasource>

      </datasources>

       

       

      Then I deploy my webapp (war) which contains these two files :

      web.xml :

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"

           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
        <resource-ref>
          <res-ref-name>java:app/datasources/applicationDS</res-ref-name>
          <lookup-name>java:/datasources/standardDS</lookup-name>
        </resource-ref>
      </web-app>

       

      persistence.xml :

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="2.0"

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

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

           xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

           <persistence-unit name="xxx-pu">
              <jta-data-source>java:app/datasources/applicationDS</jta-data-source>

                ...
          </persistence-unit>
      </persistence>

       

      And I get this error :

      JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"myWar-1.0.0-SNAPSHOT.war#xxx-pu\".__FIRST_PHASE__ is missing [jboss.naming.context.java.app.\"myWar-1.0.0-SNAPSHOT\".datasources.applicationDS]"]

       

      It is like the jndi reference in web.xml does not work and wildfly is looking for the jta-data-source. Is there a problem with my configuration ?

        • 1. Re: How to configure resource reference ?
          sfcoy

          I'm not sure if it will help, but I think that strictly speaking your res-ref-name should be:

          <res-ref-name>java:app/env/jdbc/applicationDS</res-ref-name>
          

           

          The "env" I think is compulsory, whereas the "jdbc" is just a spec recommendation.

           

          Have a look at §EE5.5.2 of the "Java™ Platform, Enterprise Edition (Java EE) Specification, v7" document.