dcsimg
Getting wrong object type returned from lookup.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ronald_Cohen
Posted On:   Monday, September 5, 2005 08:59 PM

I am getting a ClassCastException when I try to cast the object returned from my lookup to a QueueConnectionFactory. Here is the code: return (QueueConnectionFactory) this.lookup(aJndiName); Here is the exception: Exception in thread "main" java.lang.ClassCastException: com.sun.jndi.fscontext.RefFSContext Here is the lookup: objectReference = context.lookup(aJndiName); Now the problem is not that I am casting incorrectly but instead appears to be due to the fact that the object returned is the same class that I set as my Initial Context Factory when I build the Hashtable used to create the InitialContext: Hashtable con   More>>


I am getting a ClassCastException when I try to cast the object returned from my lookup to a QueueConnectionFactory.


Here is the code:
return (QueueConnectionFactory) this.lookup(aJndiName);


Here is the exception:
Exception in thread "main" java.lang.ClassCastException: com.sun.jndi.fscontext.RefFSContext


Here is the lookup:
objectReference = context.lookup(aJndiName);


Now the problem is not that I am casting incorrectly but instead appears to be due to the fact that the object returned is the same class that I set as my Initial Context Factory when I build the Hashtable used to create the InitialContext:


Hashtable contextEnv = new Hashtable();


contextEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");


contextEnv.put(Context.PROVIDER_URL, "file:/opt/websphere5/cpa/jndi-directory/clusters/S1CPcluster_dit");


this.context = new InitialContext(contextEnv);


Note that the web admin had to set up local file access. I think my code is ok and the problem lies with how jndi is configured to send back an instance of the object I expect, but can someone tell me what the problem is so I can explain to my web admin?


Thanks!

   <<Less
About | Sitemap | Contact