I have deployed CMP bean in WAS 4.0.
Route is my Remote interface.
I have a findByStartEndCity in my RouteHome home interface.
Now when i use findByStartEndCity method it give me enumeration.
When i use the below statement
Route bean = (Route)enum.nextElement();
it give me the error
java.lang.ClassCastException: org.omg.stub.javax.ejb._EJBObject_Stub
And when i use the below statements it works fine
java.util.Enumeration enum = routeHome.findByStartEndCity("US","CANADA");
for (; enum.hasMoreElements() ;)
{
System.out.println( " Inside Loop ");
RouteKey routekeys = (RouteKey)
((javax.ejb.EJBObject)enum.nextElement)).getPrimaryKey();
Route bean = routeHome.findByPrimaryKey(routekeys);
System.out.println(bean.getFare());
}//end of for
Can any body tell why is it so ???????????????????????
Thanks
Rajan
-
FINDER METHOD in WAS 4.0 (2 messages)
- Posted by: rajan jain
- Posted on: September 04 2001 03:50 EDT
Threaded Messages (2)
- FINDER METHOD in WAS 4.0 by kiran killedar on September 04 2001 06:08 EDT
- FINDER METHOD in WAS 4.0 by rajan jain on September 04 2001 23:55 EDT
-
FINDER METHOD in WAS 4.0[ Go to top ]
- Posted by: kiran killedar
- Posted on: September 04 2001 06:08 EDT
- in response to rajan jain
Hi rajan ,
Could u pls send me the Initial context factory code coz i was working on weblogic & now i wanna try out the same thing on WAS.
Waitting for ur positive reply.
bye
-kiran -
FINDER METHOD in WAS 4.0[ Go to top ]
- Posted by: rajan jain
- Posted on: September 04 2001 23:55 EDT
- in response to kiran killedar
Hi kiran
I am sending u my complete client file.
If u coluld let me know why i am gettinf classcast exception.
It will be great
Rajan
import java.io.PrintStream;
import java.util.Hashtable;
import java.util.Properties;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import packroute.*;
public class RouteClient
{
public RouteClient()
{
}
public static void main(String args[])
{
try
{
Properties props = new Properties();
props.put("java.naming.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");
props.put("java.naming.provider.url", "iiop://204.160.254.211:900");
Context ctx = new InitialContext(props);
Object homeObject = ctx.lookup("packroute/Route");
System.out.println("Looked Up");
try
{
RouteHome routeHome = (RouteHome)javax.rmi.PortableRemoteObject.narrow(homeObject,RouteHome.class);
System.out.println("after getting home");
Route bean = null;
System.out.println(" creating EJB ...");
bean = routeHome.create(801,"CHINA",25234,"SRILANKA");
System.out.println("startcity " + bean.getStartCity());
RouteKey routekey = new RouteKey(8);
bean = routeHome.findByPrimaryKey(routekey);
System.out.println("startcity query " + bean.getEndCity());
java.util.Enumeration enum = routeHome.findByStartEndCity("US","CANADA");
for (; enum.hasMoreElements() ;) {
System.out.println( " Inside Loop ");
RouteKey routekeys = (RouteKey)((javax.ejb.EJBObject)enum.nextElement()).getPrimaryKey();
bean = routeHome.findByPrimaryKey(routekeys);
//bean = (Route)enum.nextElement(); it should work this way
System.out.println(bean.getFare());
}//end of for
}//end of try
catch(javax.ejb.FinderException e)
{
e.printStackTrace();
System.out.println("FinderException.......??????????");
}
catch(Exception e)
{
e.printStackTrace();
}
}
catch(Exception ex)
{
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
}