[Persistence, JBoss/CMP, Hibernate, Database] - JNDI lookup for failed!
by rajeshhanu
Hi Guys,
When i run the application, i got the following error.
Exception in thread "main" com.lsyas.acs.common.exception.SystemException: JNDI lookup for FluegeManager failed!
at com.lsyas.acs.advanced.handling.db.JndiAccess.lookup(JndiAccess.java:148)
at com.lsyas.acs.advanced.handling.db.JndiAccess.lookup(JndiAccess.java:124)
at com.lsyas.acs.advanced.handling.db.RemoteLocator.getRemoteInstance(RemoteLocator.java:106)
at com.lsyas.acs.advanced.handling.db.TestMain.testdatamethod(TestMain.java:27)
at com.lsyas.acs.advanced.handling.db.TestMain.main(TestMain.java:34)
Caused by: javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:8080 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:8080 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:8080 [Root exception is java.net.ConnectException: Connection refused: connect]]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1562)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.lsyas.acs.advanced.handling.db.JndiAccess.lookup(JndiAccess.java:146)
... 4 more
Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:8080 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:8080 [Root exception is java.net.ConnectException: Connection refused: connect]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:274)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
... 8 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:8080 [Root exception is java.net.ConnectException: Connection refused: connect]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:248)
... 9 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.(Unknown Source)
at java.net.Socket.(Unknown Source)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:244)
... 9 more
I am using JBoss-4.2.3.GA
The following files are used to get the JNDI context.
TestMain.java
------------------
public class TestMain {
private FluegeManager manager = null;
/**
* @param args
*/
public void testdatamethod() {
RemoteLocator remoteLocator = new RemoteLocator("org.jnp.interfaces.NamingContextFactory",
"jnp://localhost:8080",
"org.jboss.naming:org.jnp.interfaces");
manager = remoteLocator.getRemoteInstance(FluegeManager.class);
List fluegedata = manager.getAll();
System.out.println("Data Size is "+ fluegedata.size());
}
public static void main(String[] args) {
TestMain testMain = new TestMain();
testMain.testdatamethod();
}
}
RemoteLocater.java
---------------------------
public class RemoteLocator {
private JndiAccess jndiAccess;
public RemoteLocator() {
jndiAccess = new JndiAccess();
}
public RemoteLocator(String initialContextFactory, String providerUrl, String urlPkgPrefixes) {
jndiAccess = new JndiAccess(initialContextFactory, providerUrl, urlPkgPrefixes);
}
@SuppressWarnings({"MissingClassJavaDoc"})
public T getRemoteInstance(Class remoteInterface) {
return jndiAccess.lookup(remoteInterface.getSimpleName(), remoteInterface);
}
}
JndiAccess.java
---------------------
public class JndiAccess {
private String initialContextFactory;
private String providerUrl;
private String urlPkgPrefixes;
private InitialContext initialContext = null;
public JndiAccess() {
initialContextFactory = null;
providerUrl = null;
urlPkgPrefixes = null;
}
public JndiAccess(String initialContextFactory, String providerUrl, String urlPkgPrefixes) {
this.initialContextFactory = initialContextFactory;
this.providerUrl = providerUrl;
this.urlPkgPrefixes = urlPkgPrefixes;
}
private Object lookup(String dataJndiName) {
try {
if (initialContext == null) {
if (initialContextFactory != null || providerUrl != null || urlPkgPrefixes != null) {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
env.put(Context.PROVIDER_URL, providerUrl);
env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes);
initialContext = new InitialContext(env);
} else {
initialContext = new InitialContext();
}
}
return initialContext.lookup(dataJndiName);
} catch (NamingException e) {
throw new SystemException("JNDI lookup for " + dataJndiName + " failed!", e);
}
}
}
Please help me.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4228425#4228425
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4228425
16 years, 11 months
[Security & JAAS/JBoss] - Status Of JndiLoginInitialContextFactory In JBoss 5 [kaput]?
by shawn@shawnkerstetter.com
I have a number of unit tests that connect to secure ejbs. All of these unit tests passed in 4.2.1.GA, using the JndiLoginInitialContextFactory for propagating the credentials. This no longer appears to work on JBoss 5.0.1.GA.
I've read through a great deal of documentation and I cannot find anything that says JndiLoginInitialContextFactory is no longer supported. What I have found is a number of posts that recommend using JAAS. After several days of trying to get my previous implementation to work with JBoss 5.0.1.GA, I finally gave up and used JAAS (which seems to be working).
This seems to me to be a pretty serious regression that should have been documented, if it indeed no longers works or is no longer supported. I'd like to get a definitive answer on the status?
I'd also like to note that I too had problems with the new location of the SecurityDomain annotation and that fact that there remains 2 of these.
This is the one you need: import org.jboss.ejb3.annotation.SecurityDomain;
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4228409#4228409
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4228409
16 years, 11 months