Community

$Proxy60 - returned by JBOSS JNDI Context

created by Anand Krishnan in JNDI and Naming - View the full discussion

Hi All,

 

          I am facing a strange ERROR, infact it is not an error thats how
the jboss returns the object. JBOSS returns $Proxy60, when i try to
retrieve object from Context. Please find the details below.

 

MBEAN DEFN:
<server>
<mbean code="org.jboss.naming.ExternalContext"

 

name="jboss.jndi:service=ExternalContext,jndiName=external/ldap/jboss">
    <attribute name="JndiName">java:external/ldap/jboss</attribute>
    <attribute name="Properties">

 

java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory
    </attribute>
    <attribute
name="InitialContext">javax.naming.ldap.InitialLdapContext</attribute>
    <attribute name="RemoteAccess">false</attribute>
</mbean>
</server>

 

The Mbean is JBOSS Class, I am testing this with JBoss standards and not
with my customClass.

 

[step A]Context envContext = (Context)ctx.lookup("java:");
[step B]Object ldapCtx = (Object)envContext.lookup("jndi/externalLDAP");

 

In step A, I could retieve the Initial Context.
But, in step B, It returns me $Proxy60 and I am unable to typecast this
object.

 

Here s my code again:

 

[1]Context ctx = new InitialContext();
[2]Context envContext = (Context)ctx.lookup("java:");
[3]Object ldapCtx = (Object)envContext.lookup("jndi/externalLDAP");
[4]System.out.println("Class name:- "+ldapCtx .getClass().getName());
[5]System.out.println("Object value:- "+ldapCtx.toString());

 

The output is as follows
[line 4: prints this value] Class name:- $Proxy60
[line 5: prints this value] Object value:-
javax.naming.InitialContext@b3826f

 

IF I type caste to InitialContext, it gives me ClassCastException.

 

Any suggestion, how to use this object?

 

Thanks,

Anand

Reply to this message by going to Community

Start a new discussion in JNDI and Naming at Community