3 Replies Latest reply on Jun 4, 2008 1:07 AM by peiguo

    Problem using JBoss Datasource

    jborter

      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

        • 1. Re: Problem using JBoss Datasource
          zxm0412

          i've the same question too,does everyone can help me ...or a little tip

          • 2. Re: Problem using JBoss Datasource
            jaikiran

             

            "zxm0412" wrote:
            i've the same question too,does everyone can help me ...or a little tip


            Which version of JBoss and Java do you use? Post the entire exception stacktrace, the code where the injection is happening and the -ds.xml file.

            While posting the logs or xml content or code, remember to wrap it in a code block using the Code button in the message editor window and please hit the Preview button to make sure your post is correctly formatted

            • 3. Re: Problem using JBoss Datasource
              peiguo

              I used resource injection with JBoss 4.2.2 and Oracle 10g, and there was no probem.