I think the point that Chris was trying to make was that the code:

        InitialContext ic = new InitialContext();
        String className = (String)ic.lookup("java:comp/env/subscriber/SubscriberDAOClass");

which works for other app servers, has to be translated into:

        InitialContext ic = new InitialContext();
        Context myCts = (Context) ic.lookup("java:comp/env/subscriber");
       String className = (String) myCts.lookup("SubscriberDAOClass");


to work on JBoss.


If I'm not mistaken, the latter is exactly what the test suite is doing as you pointed out
Scott.  So why doesn't the first work?

Robert Price




"Scott M Stark" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]

07/26/2001 01:17 PM
Please respond to jboss-user

       
        To:        <[EMAIL PROTECTED]>
        cc:        
        Subject:        Re: [JBoss-user] is JBOSS JNDI brain-dead or ...



Must be you as the jbosstest suite includes a JNDI ENC test case that does exactly
what your trying to do:

package org.jboss.test.naming.ejb;

public class TestENCBean implements SessionBean
{

   public void setSessionContext(SessionContext sessionContext) throws EJBException
   {
           // Obtain the enterprise bean's environment naming context.
           Context initCtx = new InitialContext();
           Context myEnv = (Context) initCtx.lookup("java:comp/env");
           Boolean hasFullENC = (Boolean) myEnv.lookup("hasFullENC");
           System.out.println("ThreadContext CL = "+Thread.currentThread().getContextClassLoader());
           System.out.println("hasFullENC = "+hasFullENC);
           // This bean should have the full ENC setup of the ENCBean
           testEnvEntries(initCtx, myEnv);
  }
 
   private void testEnvEntries(Context initCtx, Context myEnv) throws NamingException
   {
       // Basic env values
       Integer i = (Integer) myEnv.lookup("Ints/i0");
       System.out.println("Ints/i0 = "+i);
       i = (Integer) initCtx.lookup("java:comp/env/Ints/i1");
       System.out.println("Ints/i1 = "+i);
       Float f = (Float) myEnv.lookup("Floats/f0");
       System.out.println("Floats/f0 = "+f);
       f = (Float) initCtx.lookup("java:comp/env/Floats/f1");
       System.out.println("Floats/f1 = "+f);
       String s = (String) myEnv.lookup("Strings/s0");
       System.out.println("Strings/s0 = "+s);
       s = (String) initCtx.lookup("java:comp/env/Strings/s1");
       System.out.println("Strings/s1 = "+s);
   }

----- Original Message -----
From: "Chris Windsor" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 26, 2001 11:54 AM
Subject: [JBoss-user] is JBOSS JNDI brain-dead or ...


>
> Is JBOSS' JNDI implementation brain-dead ... or am I missing something?
>
> I took an .ear file that runs happily in the j2ee-ri and deployed it to
> jboss.  Unhappily, I've been bombarded with NamingExceptions.
>
> After many frustrated attempts to resolve them, I finally went to the
> InitialContext and NamingEnumeration api's, and System.out.println'ed my way
> to the following discovery:
>
> <code>
>
> InitialContext ic = new InitialContext();
>
> //---------------------------------------------------
> // jboss FAILS, throwing a NamingException;
> /   (but other app servers don't fail)
> //---------------------------------------------------
> String className = (String)
> ic.lookup("java:comp/env/subscriber/SubscriberDAOClass");
>
> // --------------------------------------------------
> // jboss makes me drill down to the naming context
> //   before doing the lookup, forcing me to take 2 steps,
> //  ie, THIS WAY:
> // --------------------------------------------------
> Context myCts = (Context) ic.lookup("java:comp/env/subscriber");
> String className = (String) myCts.lookup("SubscriberDAOClass");
>
> </code>
>
> Do I have to go back through my whole codebase and change the way I'm doing
> these lookups?  (sigh)
>
> Thanks for any hints that will allow me to leave my codebase as is.  Plus,
> why can't jboss' jndi handle this?
>
> Chris
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user


Reply via email to