-
1. Re: unable to invoke jndi (JBoss EAP6)call from java program
ehugonnet Oct 24, 2013 9:23 AM (in response to sri.is03)You shouldn't be using JNP as it has been replaced with jboss-remoting.
Look into this for some example : https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project
-
2. Re: unable to invoke jndi (JBoss EAP6)call from java program
wdfink Oct 24, 2013 1:41 PM (in response to sri.is03)The remote-namingproject is not recommended for ejb invocations. You should use the one of this approaches EJB invocations from a remote client using JNDIhttps://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDIor Scoped EJB client contexts.
You will find explanations here: remote-naming project
-
3. Re: unable to invoke jndi (JBoss EAP6)call from java program
sri.is03 Oct 24, 2013 2:36 PM (in response to ehugonnet)Thanks for your reply.
I have updated the code as per your suggestion. Now when I run the program I am getting below error. 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);
----------------------------