0 Replies Latest reply on Oct 24, 2013 3:14 PM by Srini S

    unable to find jndi object from standalone java program(Jboss 6.1EAP)

    Srini S Newbie

      Hello All,

       

      I am getting the below error when I try to run the jndi program as a standalone app. Below the console logs confirms (in red) jndi is available.

      User details supplied in code(myadmin/myadmin123!) are part of ApplicationRealm.


      Pls advice.

       

      Server Console log

      -----------------------------------

      00:00:19,710 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on 127.0.0.1:4447

      00:00:19,710 INFO  [org.jboss.as.remoting] (MSC service thread 1-7) JBAS017100: Listening on 127.0.0.1:9999

      00:00:19,723 INFO  [org.apache.coyote.http11] (MSC service thread 1-5) JBWEB003001: Coyote HTTP/1.1 initializing on : http-/127.0.0.1:8080

      00:00:19,726 INFO  [org.apache.coyote.http11] (MSC service thread 1-5) JBWEB003000: Coyote HTTP/1.1 starting on: http-/127.0.0.1:8080

      00:00:19,907 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:jboss/datasources/OracleDS]

      00:00:19,907 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:/srini/oracle]

      00:00:19,907 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]

      00:00:20,159 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management

      -----------------------------------------------------

      Log

      -------------------------------

      Oct 25, 2013 12:01:59 AM org.xnio.Xnio <clinit>

      INFO: XNIO Version 3.0.7.GA-redhat-1

      Oct 25, 2013 12:01:59 AM org.xnio.nio.NioXnio <clinit>

      INFO: XNIO NIO Implementation Version 3.0.7.GA-redhat-1

      Oct 25, 2013 12:01:59 AM org.jboss.remoting3.EndpointImpl <clinit>

      INFO: JBoss Remoting version 3.2.16.GA-redhat-1

      before look up...

      javax.naming.NameNotFoundException: jboss/datasources/OracleDS -- service jboss.naming.context.java.jboss.exported.jboss.datasources.OracleDS

        at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:103)

        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197)

        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:174)

        at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)

        at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)

        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

        at java.lang.Thread.run(Thread.java:619)

      --------------------------------

       

      Updated code snippet

      ----------------------------

      Properties props = new Properties();

        props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.remote.client.InitialContextFactory");

        props.put(Context.PROVIDER_URL, "remote://localhost:4447");

        props.put(Context.SECURITY_PRINCIPAL, "myadmin");

        props.put(Context.SECURITY_CREDENTIALS, "myadmin123!");

        Context initialContext = new InitialContext(props);

        System.out.println("before look up...");

        Connection con = null;

        try{

        DataSource ds = (javax.sql.DataSource)initialContext.lookup("java:jboss/datasources/OracleDS");

        con = ds.getConnection();

        }catch(Exception e){

        e.printStackTrace();

        }

        System.out.println("con:"+con);