What factory do I use?

Discussion in 'Java' started by laredotornado, Jan 4, 2010.

  1. Hi,

    I'm writing some JUnit (4.3) tests on a Java 1.5 VM. I'm trying to
    add a JNDI reference for an EJB service running locally. So far, I
    have

    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "the");
    env.put("java.naming.provider.url",
    "http://localhost:8082/apps/dor/online/interlock/hessian/");
    Context initialContext = new InitialContext(env);

    However, I'm getting a ClassNotFoundException for the class
    "com.sun.enterprise.naming.SerialInitContextFactory". My question is,
    does each JVM have a standard factory it uses for the initial context,
    and where would I find such a class? (I just cut-and-pasted the
    example from another site, so I'm not surpised it threw an exception).

    Thanks, - Dave
     
    laredotornado, Jan 4, 2010
    #1
    1. Advertising

  2. laredotornado

    Roedy Green Guest

    On Mon, 4 Jan 2010 13:24:10 -0800 (PST), laredotornado
    <> wrote, quoted or indirectly quoted someone
    who said :

    >However, I'm getting a ClassNotFoundException for the class
    >"com.sun.enterprise.naming.SerialInitContextFactory".



    see http://mindprod.com/jgloss/jndi.html
    for sample code, including the imports.
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    The question of whether Machines Can Think... is about as relevant as the question of whether Submarines Can Swim.
    ~ Edsger Wybe Dijkstra (born: 1930-05-11 died: 2002-08-06 at age: 72)
     
    Roedy Green, Jan 4, 2010
    #2
    1. Advertising

  3. laredotornado

    Arne Vajhøj Guest

    On 04-01-2010 16:24, laredotornado wrote:
    > I'm writing some JUnit (4.3) tests on a Java 1.5 VM. I'm trying to
    > add a JNDI reference for an EJB service running locally. So far, I
    > have
    >
    > Hashtable<String, String> env = new Hashtable<String, String>();
    > env.put(Context.INITIAL_CONTEXT_FACTORY,
    > "the");
    > env.put("java.naming.provider.url",
    > "http://localhost:8082/apps/dor/online/interlock/hessian/");
    > Context initialContext = new InitialContext(env);
    >
    > However, I'm getting a ClassNotFoundException for the class
    > "com.sun.enterprise.naming.SerialInitContextFactory". My question is,
    > does each JVM have a standard factory it uses for the initial context,
    > and where would I find such a class? (I just cut-and-pasted the
    > example from another site, so I'm not surpised it threw an exception).


    You always need to have the JNDI implementation classes in classpath.

    They are usually in a jar file that comes with your application server.

    Some googling indicates that for Glassfish it is appserv-rt.jar !

    Arne
     
    Arne Vajhøj, Jan 5, 2010
    #3
  4. On Jan 4, 7:04 pm, Arne Vajhøj <> wrote:
    > On 04-01-2010 16:24, laredotornado wrote:
    >
    >
    >
    > > I'm writing some JUnit (4.3) tests on a Java 1.5 VM.  I'm trying to
    > > add a JNDI reference for an EJB service running locally.  So far, I
    > > have

    >
    > >                    Hashtable<String, String>  env = new Hashtable<String, String>();
    > >                    env.put(Context.INITIAL_CONTEXT_FACTORY,
    > >                      "the");
    > >                    env.put("java.naming.provider.url",
    > >                      "http://localhost:8082/apps/dor/online/interlock/hessian/");
    > >                    Context initialContext = new InitialContext(env);

    >
    > > However, I'm getting a ClassNotFoundException for the class
    > > "com.sun.enterprise.naming.SerialInitContextFactory".  My question is,
    > > does each JVM have a standard factory it uses for the initial context,
    > > and where would I find such a class?  (I just cut-and-pasted the
    > > example from another site, so I'm not surpised it threw an exception).

    >
    > You always need to have the JNDI implementation classes in classpath.
    >
    > They are usually in a jar file that comes with your application server.
    >
    > Some googling indicates that for Glassfish it is appserv-rt.jar !
    >
    > Arne




    My application server is Resin 3.0.19. With regards to the JNDI
    implementation classes, how do I figure out what those are, and thus
    be able to search for the JAR file to include in my classpath?

    Thanks, - Dave
     
    laredotornado, Jan 5, 2010
    #4
  5. laredotornado

    Arne Vajhøj Guest

    On 05-01-2010 10:16, laredotornado wrote:
    > On Jan 4, 7:04 pm, Arne Vajhøj<> wrote:
    >> On 04-01-2010 16:24, laredotornado wrote:
    >>
    >>
    >>
    >>> I'm writing some JUnit (4.3) tests on a Java 1.5 VM. I'm trying to
    >>> add a JNDI reference for an EJB service running locally. So far, I
    >>> have

    >>
    >>> Hashtable<String, String> env = new Hashtable<String, String>();
    >>> env.put(Context.INITIAL_CONTEXT_FACTORY,
    >>> "the");
    >>> env.put("java.naming.provider.url",
    >>> "http://localhost:8082/apps/dor/online/interlock/hessian/");
    >>> Context initialContext = new InitialContext(env);

    >>
    >>> However, I'm getting a ClassNotFoundException for the class
    >>> "com.sun.enterprise.naming.SerialInitContextFactory". My question is,
    >>> does each JVM have a standard factory it uses for the initial context,
    >>> and where would I find such a class? (I just cut-and-pasted the
    >>> example from another site, so I'm not surpised it threw an exception).

    >>
    >> You always need to have the JNDI implementation classes in classpath.
    >>
    >> They are usually in a jar file that comes with your application server.
    >>
    >> Some googling indicates that for Glassfish it is appserv-rt.jar !

    >
    > My application server is Resin 3.0.19. With regards to the JNDI
    > implementation classes, how do I figure out what those are, and thus
    > be able to search for the JAR file to include in my classpath?


    I know practically nothing about Resin and EJB's.

    If I am to guess then you have not configured the JNDI lookup
    properly so it is looking for the SUN default classes instead
    of the Resin Hessian ones.

    Maybe these links can help:

    http://www.caucho.com/resin-3.0/ejb/hessian-client.xtp
    http://maillist.caucho.com/pipermail/resin-interest/2008-February/002037.html

    Arne
     
    Arne Vajhøj, Jan 6, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christer
    Replies:
    3
    Views:
    973
    Drebin
    Aug 27, 2003
  2. Medi Montaseri
    Replies:
    17
    Views:
    915
    Medi Montaseri
    Sep 3, 2003
  3. Johan Bergman
    Replies:
    6
    Views:
    428
    Johan Bergman
    Jan 20, 2004
  4. John Doe
    Replies:
    1
    Views:
    334
    Steve Holden
    Aug 31, 2004
  5. C#
    Replies:
    4
    Views:
    434
Loading...

Share This Page