(macosX,netbeans) jndi : can't find serialContextProvider

Discussion in 'Java' started by lolveley, Dec 31, 2008.

  1. lolveley

    lolveley Guest

    hi there!

    I created a test project : a "enterprise application" containing an "EJB
    module".In this module, there is a bean, and an interface ("remote"),
    and a JUnit test class. this test class tries to access to the bean
    method using JNDI, and this call fails.

    here are the main files :

    *****************************
    plus_2bBean.java:

    package moi.un;

    import javax.ejb.Stateless;

    /**
    *
    * @author oliviersaint-eve
    */
    @Stateless
    public class plus_2bBean implements plus_2bRemote {

    public int plus(int x, int y) {
    return x+y;
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method" or "Web Service > Add
    Operation")

    }

    *************************
    plus_2bBeanTest.java:


    package moi.un;


    import java.util.Properties;


    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.rmi.PortableRemoteObject;
    import org.junit.AfterClass;
    import org.junit.BeforeClass;
    import org.junit.Test;
    import static org.junit.Assert.*;

    /**
    *
    * @author oliviersaint-eve
    */
    public class plus_2bBeanTest {

    public plus_2bBeanTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    /**
    * Test of plus method, of class plus_2bBean.
    */
    @Test
    public void testPlus() {
    System.out.println("plus");
    int x = 1;
    int y = 2;
    plus_2bBean instance = new plus_2bBean();
    int expResult = 3;
    int result = instance.plus(x, y);
    assertEquals(expResult, result);
    // TODO review the generated test code and remove the default
    call to fail.
    try {


    Properties props = new Properties();
    props.setProperty("java.naming.factory.initial",
    "com.sun.enterprise.naming.SerialInitContextFactory");
    props.setProperty("java.naming.factory.url.pkgs",
    "com.sun.enterprise.naming");
    props.setProperty("java.naming.factory.state",

    "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");

    // optional. Defaults to 3700. Only needed if target orb port is not 3700.
    props.setProperty("org.omg.CORBA.ORBInitialPort", "3721");
    props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");

    InitialContext ctx = new InitialContext(props);
    Object ref = ctx.lookup("moi.un.plus_2bRemote");
    moi.un.plus_2bRemote calc = (moi.un.plus_2bRemote)
    PortableRemoteObject.narrow(ref, moi.un.plus_2bRemote.class);

    x = 3;
    y = 5;
    int res = calc.plus(x, y);
    assertTrue(res == 8);




    } catch (NamingException ex) {
    fail(ex.getMessage());
    }




    }

    }

    ******************************

    thank you for any help,

    lolveley.
     
    lolveley, Dec 31, 2008
    #1
    1. Advertising

  2. lolveley

    lolveley Guest

    there are news: I created a new domain via the console, and I started
    the domain.
    now I have the message : moi.un.plus_2bBean not found.
    NB: the lookup method contains the argument "moi.un.plus_2bBean" which
    is the argument ,in the bean code, of the annotation
    "mappedName("moi.un.plus_2bBean")".

    olivier.




    lolveley a écrit :
    > hi there!
    >
    > I created a test project : a "enterprise application" containing an "EJB
    > module".In this module, there is a bean, and an interface ("remote"),
    > and a JUnit test class. this test class tries to access to the bean
    > method using JNDI, and this call fails.
    >
    > here are the main files :
    >
    > *****************************
    > plus_2bBean.java:
    >
    > package moi.un;
    >
    > import javax.ejb.Stateless;
    >
    > /**
    > *
    > * @author oliviersaint-eve
    > */
    > @Stateless
    > public class plus_2bBean implements plus_2bRemote {
    >
    > public int plus(int x, int y) {
    > return x+y;
    > }
    >
    > // Add business logic below. (Right-click in editor and choose
    > // "Insert Code > Add Business Method" or "Web Service > Add
    > Operation")
    >
    > }
    >
    > *************************
    > plus_2bBeanTest.java:
    >
    >
    > package moi.un;
    >
    >
    > import java.util.Properties;
    >
    >
    > import javax.naming.InitialContext;
    > import javax.naming.NamingException;
    > import javax.rmi.PortableRemoteObject;
    > import org.junit.AfterClass;
    > import org.junit.BeforeClass;
    > import org.junit.Test;
    > import static org.junit.Assert.*;
    >
    > /**
    > *
    > * @author oliviersaint-eve
    > */
    > public class plus_2bBeanTest {
    >
    > public plus_2bBeanTest() {
    > }
    >
    > @BeforeClass
    > public static void setUpClass() throws Exception {
    > }
    >
    > @AfterClass
    > public static void tearDownClass() throws Exception {
    > }
    >
    > /**
    > * Test of plus method, of class plus_2bBean.
    > */
    > @Test
    > public void testPlus() {
    > System.out.println("plus");
    > int x = 1;
    > int y = 2;
    > plus_2bBean instance = new plus_2bBean();
    > int expResult = 3;
    > int result = instance.plus(x, y);
    > assertEquals(expResult, result);
    > // TODO review the generated test code and remove the default
    > call to fail.
    > try {
    >
    >
    > Properties props = new Properties();
    > props.setProperty("java.naming.factory.initial",
    > "com.sun.enterprise.naming.SerialInitContextFactory");
    > props.setProperty("java.naming.factory.url.pkgs",
    > "com.sun.enterprise.naming");
    > props.setProperty("java.naming.factory.state",
    >
    > "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
    >
    > // optional. Defaults to 3700. Only needed if target orb port is not
    > 3700.
    > props.setProperty("org.omg.CORBA.ORBInitialPort", "3721");
    > props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
    >
    > InitialContext ctx = new InitialContext(props);
    > Object ref = ctx.lookup("moi.un.plus_2bRemote");
    > moi.un.plus_2bRemote calc = (moi.un.plus_2bRemote)
    > PortableRemoteObject.narrow(ref, moi.un.plus_2bRemote.class);
    >
    > x = 3;
    > y = 5;
    > int res = calc.plus(x, y);
    > assertTrue(res == 8);
    >
    >
    >
    >
    > } catch (NamingException ex) {
    > fail(ex.getMessage());
    > }
    >
    >
    >
    >
    > }
    >
    > }
    >
    > ******************************
    >
    > thank you for any help,
    >
    > lolveley.
    >
    >
    >
     
    lolveley, Dec 31, 2008
    #2
    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. Mike S
    Replies:
    0
    Views:
    23,105
    Mike S
    Sep 16, 2004
  2. Mick
    Replies:
    2
    Views:
    9,669
    Marcin Grunwald
    Feb 23, 2005
  3. Replies:
    0
    Views:
    369
  4. Lothar Scholz
    Replies:
    3
    Views:
    400
    Robert Kern
    Apr 19, 2005
  5. Raphaël Marmier
    Replies:
    2
    Views:
    176
    Raphaël Marmier
    Oct 20, 2009
Loading...

Share This Page