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

孤街浪徒 提交于 2019-12-13 01:07:02

问题


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

来源:https://stackoverflow.com/questions/11728724/arquillian-glassfish-embedded-3-1-1-0-0-cr3-configuring-jdbc-datasource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!