This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Testing and the fly likes JUnit EJB problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "JUnit EJB problem" Watch "JUnit EJB problem" New topic
Author

JUnit EJB problem

kota reddy malli
Greenhorn

Joined: Sep 08, 2004
Posts: 2
Hi,
I am getting the follwing exception when i use Junit on ejb... Can anybody help on this....

protected void setUp() throws Exception {
InitialContext initial = new InitialContext();

SampleEJBHome remoteHome = (SampleEJBHome)PortableRemoteObject.narrow(initial.lookup("java:comp/env/ejb/test/testSample/ejb/SampleEJBHome"),SampleTestCase.class);

sampleLocal = remoteHome.create();
}


javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:255)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:292)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
at test.testcase.SampleTestCase.setUp(SampleTestCase.java:42)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)


thanks,
malli
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Just checking, are you running these tests inside an EJB Container or directly within Eclipse?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JUnit EJB problem
 
Similar Threads
NoClassDefFoundError exception in InitialContext()
Jboss rar JNDI lookup
Junit and Ejb - com/ibm/ejs/jts/jts/Current
WSAD 5.0 EJB Client jndi lookup problem
EJB Testing using JUnit