[jboss-user] [JNDI and Naming] - ClassNotFoundException on Context.lookup() after login with custom Principal
Ozan Ayyüce
do-not-reply at jboss.com
Thu Jan 19 12:17:46 EST 2012
Ozan Ayyüce [https://community.jboss.org/people/ozay] created the discussion
"ClassNotFoundException on Context.lookup() after login with custom Principal"
To view the discussion, visit: https://community.jboss.org/message/647666#647666
--------------------------------------------------------------
Hi,
we have a client-server-setup and are migrating to AS 6.1.0. Unfortunately, a JNDI lookup fails with a ClassNotFoundException as root cause.
Previously, we had extended SimplePrincipal to add some fields. In our client, we use the LoginContext with a custom password handler to authenticate at the AS.
handler = new CustomUserPasswordHandler(user, pwd, mandatorID);
final LoginContext loginContext = new LoginContext(LOGIN_CONFIGURATION, handler);
try
{
loginContext.login();
}
catch (final LoginException ex)
{
throw new IllegalStateException("Could not initialize clients login module: " + ex);
}
the client auth.conf specifies a custom login module:
client-login {
de.xxx.xxx.secure.CustomClientLoginModule required
;
org.jboss.security.ClientLoginModule required
password-stacking="useFirstPass"
;
};
Our custom login module creates our custom Principal:
@Override
public boolean login() throws LoginException
{
loginFailed = true;
getUserInfo();
loginPrincipal = new CustomPrincipal(mandator, customAttr, username);
sharedState.put("javax.security.auth.login.name", loginPrincipal);
sharedState.put("javax.security.auth.login.password", loginCredential);
loginFailed = false;
return true;
}
After login, any call to Context.lookup() results in a ServiceUnavailableException:
theNewsTopic = (Topic) ctx.lookup(Names.JMS_TOPIC_UPDATE_USER)
javax.naming.ServiceUnavailableException: Unexpected failure [Root exception is java.lang.ClassNotFoundException: de.xxx.xxx.secure.CustomPrincipal]
17:52:58,299 ERROR [STDERR] at org.jboss.naming.interceptors.ExceptionInterceptor.invoke(ExceptionInterceptor.java:71)
17:52:58,299 ERROR [STDERR] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:68)
17:52:58,299 ERROR [STDERR] at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)
17:52:58,299 ERROR [STDERR] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:101)
17:52:58,299 ERROR [STDERR] at $Proxy0.lookup(Unknown Source)
17:52:58,299 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728)
17:52:58,299 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
17:52:58,299 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:392)
17:52:58,299 ERROR [STDERR] at de.xxx.xxx.client.jms.JMSConsumer.getTopic(JMSConsumer.java:143)
17:52:58,299 ERROR [STDERR] at de.xxx.xxx.client.jms.JMSConsumer.initTopic(JMSConsumer.java:193)
17:52:58,299 ERROR [STDERR] at de.xxx.xxx.client.jms.JMSConsumer.<init>(JMSConsumer.java:120)
17:52:58,299 ERROR [STDERR] at de.xxx.xxx.client.jms.UpdateConsumer.<init>(UpdateConsumer.java:97)
17:52:58,299 ERROR [STDERR] at de.xxx.xxx.client.RemoteClient$Consumer.initRemoteMessageConsumers(RemoteClient.java:266)
17:52:58,299 ERROR [STDERR] at de.xxx.xxx.client.InitThread.initUpdateFramework(InitThread.java:165)
17:52:58,299 ERROR [STDERR] at de.xxx.xxx.client.InitThread.loadData(InitThread.java:178)
17:52:58,299 ERROR [STDERR] at de.xxx.xxx.client.InitThread.run(InitThread.java:296)
17:52:58,299 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: de.xxx.xxx.secure.CustomPrincipal
17:52:58,299 ERROR [STDERR] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
17:52:58,299 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
17:52:58,299 ERROR [STDERR] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
17:52:58,299 ERROR [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
17:52:58,299 ERROR [STDERR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
17:52:58,299 ERROR [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
17:52:58,299 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
17:52:58,299 ERROR [STDERR] at java.lang.Class.forName(Class.java:247)
17:52:58,299 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:304)
17:52:58,299 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1172)
17:52:58,299 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:886)
17:52:58,299 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoader.doLoadClass(BaseClassLoader.java:505)
17:52:58,299 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:450)
17:52:58,299 ERROR [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
17:52:58,299 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
17:52:58,299 ERROR [STDERR] at java.lang.Class.forName(Class.java:247)
17:52:58,299 ERROR [STDERR] at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603)
17:52:58,299 ERROR [STDERR] at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
17:52:58,299 ERROR [STDERR] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
17:52:58,299 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
17:52:58,299 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
17:52:58,299 ERROR [STDERR] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
17:52:58,299 ERROR [STDERR] at org.jboss.invocation.MarshalledInvocation.readExternal(MarshalledInvocation.java:665)
17:52:58,299 ERROR [STDERR] at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791)
17:52:58,299 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
17:52:58,299 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
17:52:58,299 ERROR [STDERR] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
17:52:58,299 ERROR [STDERR] at org.jboss.invocation.http.servlet.InvokerServlet.processRequest(InvokerServlet.java:137)
17:52:58,299 ERROR [STDERR] at org.jboss.invocation.http.servlet.InvokerServlet.doPost(InvokerServlet.java:232)
17:52:58,299 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
17:52:58,299 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
17:52:58,299 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324)
17:52:58,299 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
17:52:58,299 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
17:52:58,299 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
17:52:58,299 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)
17:52:58,299 ERROR [STDERR] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
17:52:58,299 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)
17:52:58,299 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100)
17:52:58,299 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)
17:52:58,299 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
17:52:58,299 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
17:52:58,299 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
17:52:58,299 ERROR [STDERR] at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)
17:52:58,299 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
17:52:58,299 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
17:52:58,299 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654)
17:52:58,299 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
17:52:58,299 ERROR [STDERR] at java.lang.Thread.run(Thread.java:662)
When the lookup() call is made before LoginContext.login() was run, the queried JNDI entry is returned like expected:
try
{
Topic theNewsTopic = (Topic) ClientLookup.getInitialContext().lookup(Names.JMS_TOPIC_UPDATE_USER);
String string = theNewsTopic.toString();
}
catch (NamingException e)
{
// no error happens here
LOG.error("Your log-message: ", e);
}
final LoginContext loginContext = new LoginContext(LOGIN_CONFIGURATION, handler);
loginContext.login();
try
{
Topic theNewsTopic = (Topic) ClientLookup.getInitialContext().lookup(Names.JMS_TOPIC_UPDATE_USER);
String string = theNewsTopic.toString();
}
catch (NamingException e)
{
// fails with ServiceUnavailableException: Unexpected failure [Root exception is java.lang.ClassNotFoundException de.xxx.xxx.secure.CustomPrincipal]
LOG.error("Your log-message: ", e);
}
Needless to say, CustomPrincipal is in the classpath, and is created once when the login call is made.
Any advice would be very helpful as we are out of ideas on how to narrow the error down.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/647666#647666]
Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120119/298cc344/attachment-0001.html
More information about the jboss-user
mailing list