Hi I am new to
EJB and trying to execute my first application
but I am getting the following error please help me in finding out the solution
---------------
java.lang.ClassCastException
at com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at HelloClient.main(HelloClient.java:16)
---------------------------------------
Here I am pasting my
Java Code
** Home Object **
import javax.ejb.*;
import java.rmi.RemoteException;
public interface HelloHome extends EJBHome
{
Hello create() throws RemoteException,CreateException;
}
==================================
** Remote Interface **
import javax.ejb.*;
import java.rmi.RemoteException;
import java.rmi.Remote;
public interface Hello extends EJBObject
{
public
String hello() throws java.rmi.RemoteException;
}
========================
** My Bean **
import javax.ejb.*;
public class HelloBean implements SessionBean
{
public void ejbCreate()
{
System.out.println("ejbCreated()");
}
public void ejbRemove()
{
System.out.println("ejbRemove()");
}
public void ejbActivate()
{
System.out.println("ejbActivate()");
}
public void ejbPassivate()
{
System.out.println("ejbPassivate()");
}
public void setSessionContext(SessionContext ctx)
{
System.out.println("setSessionContext()");
}
// Business methods
public String hello()
{
System.out.println("Hello()");
return "Hello World!";
}
}
===========================
** Client ******
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;
import java.util.Properties;
//import javax.rmi.PortableRemoteObect;
public class HelloClient
{
public static void main(String[] args)
{
try
{
Properties props=System.getProperties();
Context ctx=new InitialContext(props);
Object obj = ctx.lookup("HelloBean");
HelloHome home= (HelloHome) PortableRemoteObject.narrow(obj, HelloHome.class);
Hello hello=home.create();
System.out.println(hello.hello());
hello.remove();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
=====================================
Please Help I have been stuck here since 8 days not finding any solution.
Thanking you in advance
Saradhi
------------------
Intelligent Hard work never goes waste