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

L

lolveley

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.
 
L

lolveley

there are 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 :
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top