Hello,

Change

InitialContext ic2 = (InitialContext)ic1.lookup("java:comp/env");

to

Context context = (Context) ic1.lookup("java:comp/env");

and you shouldn't get the error.

InitialContext is the starting context, not all contexts are InitialContexts, that's
why you get a ClassCastException.

Regards,
Karl Avedal

[EMAIL PROTECTED] wrote:

> I am trying to get the EntityContext's environment .  Since Sun deprecated the
> getEnvironment() method.  I have to use the JNDI interface.
>
> My code looks like this:
>
> try {
>      InitialContext ic1 = new InitialContext();
>      InitialContext ic2 = (InitialContext)ic1.lookup("java:comp/env");
>      Hashtable env = ic2.getEnvironment();
>      Enumeration keys = env.keys();
>
>      while(keys.hasMoreElements()) {
>           Object key = keys.nextElement();
>           Object value = env.get(key);
>           System.err.println(key.toString() + " = " + value.toString());
>      }
>
> } catch (Exception e) {
> }
>
> My problem is that I am getting an Exception
>
> java.lang.ClassCastException: com.evermind.util.r
>      at
> com.tsis.utils.net.JNDIEnvironment.showEnvironment(JNDIEvironment.java:32)
>      ....
>      ....
>      ....
>
> on the line:
>
> InitialContext ic2 = (InitialContext)ic1.lookup("java:comp/env");
>
> I looked in the orion.jar file and that file is there.  Not sure what to make of
> this.  Does anybody have any idea what is going on??


Reply via email to