Take care<BR>r@njith
Originally posted by s prasanna:
hai
i got ur message which is posted by u. Herewith i am adding all
the steps which are required to run a simple hello world program in ejb using j2ee server. just go thru it. If u got any error u
can contact me in this address prasanna@genesisexcellence.com
buy for now
1. Install the j2ee server ( In NT Server)
2. using mycomputer property Environment set the follwing varaiables
J2EE_HOME -> path of the server ( J2EE_HOME -> e:\j2sdkee1.2)
JAVA_HOME -> path of the java s/w ( JAVA_HOME -> c:\jdk1.2)
3. in a separate jvm compile the following files
c:\> set classpath=%classpath%;e:\j2sdkee1.2\lib\j2ee.jar
Interface
//RemoteInterface
import javax.ejb.*;
import java.rmi.*;
public interface HelloInter extends EJBObject
{
public String sayHello() throws RemoteException;
}
//HomeInterface
import java.io.*;
import java.rmi.*;
import javax.ejb.*;
public interface HelloHome extends EJBHome
{
HelloInter create() throws RemoteException,CreateException;
}
//EJBBean
import java.io.*;
import javax.ejb.*;
import java.rmi.*;
public class HelloEjb implements SessionBean
{
public String sayHello()
{
return "Hello !";
}
public HelloEjb() {}
public void ejbCreate() {}
public void ejbRemove() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void setSessionContext(SessionContext sc) {}
}
//Client
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;
public class HelloClient
{
public static void main(String args[]) throws Exception
{
Context Initial = new InitialContext();
Object obj = Initial.lookup("myapp");
HelloHome home =(HelloHome)PortableRemoteObject.narrow(obj,HelloHome.class);
HelloInter c = home.create();
System.out.println(c.sayHello());
c.remove();
}
}
4.start the server using ( separate JVM)
e:\> path=%path%;e:\j2sdkee1.2\bin
e:\>j2ee -verbose
5. start the deployment tool ( separate jvm)
e:\> path=%path%;e:\j2sdkee1.2\bin
e:\> deploytool
6. in the deploytool create a new application ( File -> CreateNewApplication)
appname -> demo
app path -> e:\demo\demo.ear
7. create a new entrisebean ( File -> NewEnterpriseBean) ( Wizard use to create a jar file)
add the following content in the jar file
HelloInter.class
HelloHome.class
HelloBean.class
8. specify the jndi-name ( eg.myapp)
9. click finish to create a jar file
10. select the bean (user defined name) in the deploytool and specify the jndi-name
(eg. myapp)
11. deploy the application using tools->deployapplication)
12. in a separate jvm run the client
c:\> set classpath=%classpath%;e:\demo\demoClient.jar
c:\> java HelloClient
Face Off.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |