[jboss-user] [Management, JMX/JBoss] - NotContextException in ldap context created by MBean

RedQ do-not-reply at jboss.com
Mon Apr 2 12:24:34 EDT 2007


Hi,

I have an mbean which creates ldap-contexts. Definition of the mbean is:

	<mbean code="org.jboss.naming.ExternalContext"
  | 		name=":service=ExternalContext,jndiName=ldap/main" >
  | 		<attribute name="JndiName">ldap/main</attribute>
  | 		<attribute name="Properties">ldap.properties</attribute>
  | 		<attribute name="InitialContext">
  | javax.naming.ldap.InitialLdapContext</attribute>
  | 		<attribute name="RemoteAccess">true</attribute>
  | 	</mbean>

When looking at the binding (using JNDIView), I see that the proxy created by jboss implements 

In the code, I request a context like this:LdapContext ctx = (LdapContext)new InitialContext().lookup( "ldap/main" );

A check of the context by calling instanceof DirContext return true after the lookup. 

The problem is, that everytime any operation must actually be performed using the context (like ctx.search()), an exception is thrown:

javax.naming.NotContextException: Not an instance of DirContext
  |  	at javax.naming.directory.InitialDirContext.getURLOrDefaultInitDirCtx(Unknown Source)
  | 	at javax.naming.directory.InitialDirContext.search(Unknown Source)
  |  	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  | 	at java.lang.reflect.Method.invoke(Unknown Source)
  | 	at org.jboss.naming.ExternalContext$CachedContext.invoke(ExternalContext.java:538)
  | 	at $Proxy39.search(Unknown Source)

I don't know if I'm misunderstanding the way that jboss is making the proxies.. The InitialDirContext.getURLOrDefaultInitDirCtx is also using instanceof to check the instance of the parameter.

Could anyone advice how to overcome this problem, or maybe point me "in the right direction" ?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033752#4033752

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033752



More information about the jboss-user mailing list