gi11ies
Programmer
- Mar 26, 2002
- 52
Hi
I am currently trying to learn EJBs, and am wondering if anyone has any help, tutorials, or know of development applications that aid in the development of EJBs, as well as might be able to help me with the simple EJB I have created that will not work.
Right now I am have created a simple "HelloWorld" EJB, using Text Pad to code it, and the J2EE Application Deployment Tool to deploy it ... but I am just getting errors when I complile it.
I have pasted the code I am using below, and any help at all with EJBs that anyone can offer would be a great help.
Thanks
Gillies
#BEAN
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class HelloWorldEJB implements SessionBean
{
public void Hello()
{
System.out.println("Hello World"
;
}
public HelloWorldEJB() {}
public void ejbCreate() {}
public void ejbRemove() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void setSessionContext(SessionContext sc) {}
}
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface HelloWorld extends EJBObject {
public void Hello() throws RemoteException;
}
#HOME INTERFACE
import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface HelloWorldHome extends EJBHome {
HelloWorld create() throws RemoteException, CreateException;
}
#REMOTE INTERFACE
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface HelloWorld extends EJBObject {
public void Hello() throws RemoteException;
}
#CLIENT FOR TESTING
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import HelloWorld;
import HelloWorldHome;
public class HelloWorldClient {
public static void main(String[] args) {
try {
Context initial = new InitialContext();
Object objref = initial.lookup("MyHelloWorld"
;
HelloWorldHome home =
(HelloWorldHome)PortableRemoteObject.narrow(objref,
HelloWorldHome.class);
HelloWorld myHello = home.create();
myHello.hello();
myHello.remove();
} catch (Exception ex) {
System.err.println("Caught an unexpected exception!"
;
ex.printStackTrace();
}
}
}
I am currently trying to learn EJBs, and am wondering if anyone has any help, tutorials, or know of development applications that aid in the development of EJBs, as well as might be able to help me with the simple EJB I have created that will not work.
Right now I am have created a simple "HelloWorld" EJB, using Text Pad to code it, and the J2EE Application Deployment Tool to deploy it ... but I am just getting errors when I complile it.
I have pasted the code I am using below, and any help at all with EJBs that anyone can offer would be a great help.
Thanks
Gillies
#BEAN
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class HelloWorldEJB implements SessionBean
{
public void Hello()
{
System.out.println("Hello World"
}
public HelloWorldEJB() {}
public void ejbCreate() {}
public void ejbRemove() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void setSessionContext(SessionContext sc) {}
}
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface HelloWorld extends EJBObject {
public void Hello() throws RemoteException;
}
#HOME INTERFACE
import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface HelloWorldHome extends EJBHome {
HelloWorld create() throws RemoteException, CreateException;
}
#REMOTE INTERFACE
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface HelloWorld extends EJBObject {
public void Hello() throws RemoteException;
}
#CLIENT FOR TESTING
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import HelloWorld;
import HelloWorldHome;
public class HelloWorldClient {
public static void main(String[] args) {
try {
Context initial = new InitialContext();
Object objref = initial.lookup("MyHelloWorld"
HelloWorldHome home =
(HelloWorldHome)PortableRemoteObject.narrow(objref,
HelloWorldHome.class);
HelloWorld myHello = home.create();
myHello.hello();
myHello.remove();
} catch (Exception ex) {
System.err.println("Caught an unexpected exception!"
ex.printStackTrace();
}
}
}