s prasanna

Greenhorn
+ Follow
since Oct 04, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts 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

hai everybody
when i am try to run the following servlet-ejb in j2ee server i got some errors. Anybody give me a solution for this?

thanks in advance
prasanna
import javax.servlet.*;
import java.io.*;
import javax.rmi.*;
import javax.naming.*;
public class HelloServlet extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res) throws
ServletException,IOException
{
PrintWriter out = res.getWriter();
try
{
Context c = new InitialContext();
Object ob = c.lookup("Hello");
HelloHome home = (HelloHome)PortableRemoteObject.narrow(ob,HelloHome.class);
HelloInter s = home.create();
out.println("Message : " + s.hello());
}
catch(Exception e1)
{
out.println(e1.getMessage());
}
}
}

error Message :
Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial