0 Replies Latest reply on Jul 30, 2012 3:45 PM by henockmamo

    arquillian-glassfish-embedded-3.1 1.0.0.CR3 configuring JDBC datasource

    henockmamo

      Hi all,

       

         I was trying to use arquillian-glassfish-embedded-3.1 container to test and EJB3 application. I was trying to figure out how to set up a simple JDBC datasource that could be injected as a resource to a Stateless ejb.

       

      Here is what I have :

       

      @Stateless

      public class HelloEJBBean implements HelloEJB {

       

       

                @Resource(name="myDataSource")

                private DataSource datasource;

       

       

       

       

                public String sayHelloEJB(String name) {

                          return "Hello " + name;

                }

      }

       

      also have arquillian.xml with the following content:

       

      <?xml version="1.0"?>

      <arquillian xmlns="http://jboss.com/arquillian"

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

         xmlns:glassfish="urn:arq:org.jboss.arquillian.container.glassfish.embedded_3">

         <glassfish:container>

            <glassfish:bindHttpPort>9090</glassfish:bindHttpPort>

            <glassfish:instanceRoot>src/test/resources</glassfish:instanceRoot>

            <glassfish:autoDelete>false</glassfish:autoDelete>

         </glassfish:container>

      </arquillian>

       

      and a domain.xml with

       

      <domain>

         <applications />

         <resources>

            <jdbc-resource pool-name="ArquillianEmbeddedOraclePool" jndi-name="myDataSource"

               object-type="user" enabled="true"/>

            

           <jdbc-connection-pool name="ArquillianEmbeddedOraclePool" res-type="javax.sql.DataSource"

              datasource-classname="oracle.jdbc.driver.OracleDriver">

              <property name="user" value="user"/>

              <property name="password" value="password"/>

              <property name="serverName" value="servername"/>

               <property name="DatabaseName" value="dbname"/>

              <property name="url" value="jdbc:oracle:thin:@servername:1521/dbname"/>

          </jdbc-connection-pool>

         </resources>

      </domain>

       

      and the simple test looks like this:

       

      @RunWith(Arquillian.class)

      public class HelloEJBTest {

       

       

       

          @Deployment

          public static JavaArchive createTestArchive() {

              return ShrinkWrap.create(JavaArchive.class, "helloEJB.jar")

                      .addClasses(HelloEJB.class, HelloEJBBean.class);

          }

         

          @EJB

          private HelloEJB helloEJB;

         

         

          @Test

          public void testHelloEJB() {

              String result = helloEJB.sayHelloEJB("Michael");

              assertEquals("Hello Michael", result);

             

          }

      }

       

       

      I get the following error:

       

      ... 108 more

      Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Res-Ref-Env-Property: myDataSource@javax.sql.DataSource@ resolved as: jndi: myDataSource@res principal: null@mail: null

      No Runtime properties

       

      ... 108 more

      Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Res-Ref-Env-Property: myDataSource@javax.sql.DataSource@ resolved as: jndi: myDataSource@res principal: null@mail: null

      No Runtime properties

       

       

      Any help is appreciated.

       

       

      Thanks