2 Replies Latest reply on Nov 15, 2009 10:31 AM by jaikiran pai

    Could not locate datasource in JBOSS 4.23 GA jndi.

    Digvijay Kumar Newbie

      i have created datasource in jboss jndi and bound it to EJB3DS.

      <datasources>
       <local-tx-datasource>
       <jndi-name>EJB3DS</jndi-name>
       <connection-url>jdbc:oracle:thin:@comp1:1521:Ora9i</connection-url>
      
       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
       <user-name>ws</user-name>
       <password>ws</password>
      
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
       <!-- sql to call when connection is created
       <new-connection-sql>some arbitrary sql</new-connection-sql>
       -->
       <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered
       <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
       -->
       <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
       <metadata>
       <type-mapping>Oracle9i</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>
      


      i can see this datasource in jndiView.

      java: Namespace


      +- jaas (class: javax.naming.Context)
      | +- other (class: org.jboss.security.plugins.SecurityDomainContext)
      | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
      | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
      | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
      +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
      +- comp.ejb3 (class: javax.naming.Context)
      | NonContext: null
      +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
      +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
      +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
      +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)
      +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
      +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
      +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
      +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
      +- Mail (class: javax.mail.Session)
      +- comp.original (class: javax.namingMain.Context)
      +- timedCacheFactory (class: javax.naming.Context)
      Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy cannot be cast to javax.naming.NamingEnumeration
      +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
      +- comp (class: javax.naming.Context)
      +- EJB3DS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)


      But when I try to locate it through code, I get this exception.
      javax.naming.NameNotFoundException: EJB3DS not bound


      code is

      try {
       Properties p = new Properties();
       p.put(Context.INITIAL_CONTEXT_FACTORY, org.jnp.interfaces.NamingContextFactory.class.getName());
      
       p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
       p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      
       Context context = new InitialContext(p);
       Object obj = context.lookup("java:/PBDS");
      }
       catch(Exception e) {
       System.out.println(e);
       }