Two Laptop Bag
The moose likes Websphere and the fly likes Query Based on Junit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Query Based on Junit" Watch "Query Based on Junit" New topic

Query Based on Junit

Krishnaraj kavitha

Joined: Apr 28, 2003
Posts: 2
Hi all,
We are using IBM websphere studio ver 5.0 for our development.
We plan to use Junit for our testing.

In my testcase while trying to lookup bean from testcase, I am getting this exception. The code and exception as follows,
*************** CODE ***************
package ejbTestCase;
import junit.framework.TestCase;
import java.util.*;
import junit.framework.*;
import junit.extensions.*;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import com.imantras.ejbJunit.*;

* @author Krishna
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
public class EJBTestCase extends TestCase {

protected StatelessFundmanagerEJBHome statelessFundmanagerEJBHome;
* Constructor for EJBTestCase.
* @param arg0

public EJBTestCase(String name) {
public static void main(String[] args) {;
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(new EJBTestCase("testaddFunds"));
return suite;
* @see TestCase#setUp()
protected void setUp() {

System.out.println("Entering in to ICF");
java.util.Hashtable properties = new java.util.Hashtable(2);
properties.put(javax.naming.Context.PROVIDER_URL, "iiop:///");
System.out.println("Get away from ICF");

System.out.println("Entering in to lookup");
javax.naming.InitialContext ctx =
new javax.naming.InitialContext(properties);
System.out.println("Entering in to lookup**************222222222");

Object home = ctx.lookup("ejb/com/imantras/ejbJunit/StatelessFundmanagerEJBHome");

System.out.println("Entering in to lookup***************3333333333");

statelessFundmanagerEJBHome = null;

statelessFundmanagerEJBHome =(StatelessFundmanagerEJBHome) PortableRemoteObject.narrow(home,StatelessFundmanagerEJBHome.class);

System.out.println("statelessFundManagerEJBHome" + statelessFundmanagerEJBHome);

catch (Exception e)



public void testaddFunds()


double amount=0;
double balance=100;


StatelessFundmanagerEJB statelessFundmanagerEJB= statelessFundmanagerEJBHome.create();

double balance1 = statelessFundmanagerEJB.addFunds(100,100);
double balance2 = statelessFundmanagerEJB.withdrawFunds(100,100);


System.out.println("Balance == " +balance);
System.out.println("Balance 2 == " +balance2);

catch(Exception e)



* @see TestCase#tearDown()
protected void tearDown() {
statelessFundmanagerEJBHome = null;

******************* EXCEPTION ***************
"javax.naming.ConfigurationException: The property is not set. The most likely cause is that the jar which contains the file com/ibm/websphere/naming/ cannot be found by the class loader.
Even I tried by placing my test case in both ejb jar and web war with the enterprise project, still I use to get the same exception
Can you give solution for this.

iMantras India pvt Limited
Chennai -41
Ph.No : 044 - 52125245
I agree. Here's the link:
subject: Query Based on Junit
jQuery in Action, 3rd edition