3 Replies Latest reply on Jun 4, 2008 1:07 AM by Peter Pei Guo

    Problem using JBoss Datasource

    Juerg Borter Newbie

      Hi

      I have serious problems using a JBoss Datasource. From the documentation it seems to be easy... What I've done:

      Created file oracle-ds.xml and moved it into the directory server/default/deploy. It looks like this:

      <?xml version="1.0" encoding="UTF-8" ?>
      <datasources>
       <no-tx-datasource>
       <jndi-name>/myOracleDS</jndi-name>
       <use-java-context>
       true
       </use-java-context>
       <connection-url>
       jdbc:oracle:thin:@localhost:1521:TESTDB
       </connection-url>
       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
       <user-name>TESTER</user-name>
       <password>TESTER</password>
       <min-pool-size>1</min-pool-size>
       <max-pool-size>5</max-pool-size>
       <metadata>
       <type-mapping>Oracle9i</type-mapping>
       </metadata>
       </no-tx-datasource>
      </datasources>
      


      As JBoss starts, it displays that this succeeded:
      INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=/myOracleDS' to JNDI name 'java:/myOracleDS'
      


      I also created an EJB which has the following JAVA code:
      
      @Stateless(name="oracleConnectionPool")
      public class OracleConnectionPoolImpl implements OracleConnectionPool {
      
       @Resource(mappedName="java:/myOracleDS")
       private DataSource ds;
      
       public Connection getOracleConnection() {
       try {
       return ds.getConnection();
       } catch (SQLException ex) {
       ex.printStackTrace();
       }
      
       return null;
       }
      }
      


      As I lookup this EJB and call the method getOracleConnection() from another class, I get a really strange Exception:

      
      java.lang.IllegalArgumentException: failed to set value org.jboss.resource.adapter.jdbc.WrapperDataSource@c1c2f1 on field private javax.sql.DataSource OracleConnectionPoolImpl.ds
       at org.jboss.injection.lang.reflect.FieldBeanProperty.set(FieldBeanProperty.java:85)
       at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:89)
       at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:83)
       at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:55)
       at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:111)
       at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:61)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:214)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:184)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:81)
       at $Proxy175.getOracleConnection(Unknown Source)
       at TestOracleConnection.getStatement(...)
      ...
      


      Does anyone has an idea of how to solve this problem?

      Tnx & cheers, Jbo