Code from Enterprise JavaBeans 3.1 chapter 4. If you need more code or information just ask!
public class SimpleCalculatorIntegrationTest {
private static SimpleCalculatorBean calc;
private static Context namingContext;
private static final String JNDI_NAME_CALC = "java:global/SimpleCalculatorEJB/SimpleCalculatorBean";
@BeforeClass
public static void obtainProxyReferences() throws NamingException {
namingContext = new InitialContext();
calc = (SimpleCalculatorBean) namingContext.lookup(JNDI_NAME_CALC);
}
@Test
public void testAddition() {
int expectedSum = 1 + 2 + 3 + 4; // 10
assertEquals(expectedSum, calc.add(1, 2, 3, 4));
}
}
Stacktrace:
11.okt.2011 20:41:28 com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default. java.lang.RuntimeException: Orb initialization erorr at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:180) at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:365) at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:372) at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:402) at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455) at javax.naming.InitialContext.lookup(InitialContext.java:392) at no.breakpoint.ejbbook.calculator.test.SimpleCalculatorIntegrationTest.obtainProxyReferences(SimpleCalculatorIntegrationTest.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.NullPointerException at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:152) ... 23 more