Forums Register Login

EJB Compilation

+Pie Number of slices to send: Send
Hi All
I have successfully started the J2EE Server. My dir is as follows
c:\jdk1.3
c:\j2sdkee1.2.1
now i created 3 java files
Converter.java
ConverterHome.java
ConverterEJB.java
Now i have a batch file as follows:
set J2EE_HOME=c:\j2skee1.2.1
set CPATH=.;%J2EE_HOME%\lib\j2ee.jar
javac -classpath %CPATH% ConverterEJB.java ConverterHome.java Converter.java
i am unable to compile my files. I get errors like "can't resolve symbol". How should I PROCEED from here. What I am doing wrong.
Please Help
Preety Agarwal
+Pie Number of slices to send: Send
hi Preety,
i think, you did not set the classpath because i was also facing the same problem.what i done is.i set two classpath:
set classpath=%classpath%;c:\j2sdkee1.2.1\lib\j2ee.jar
and
set classpath=%classpath%;c:\curworkdir\untitled.jar ,this one you can get in your working dir,after deployment.
Thank you
Jyotisree

[This message has been edited by jyotisree (edited September 17, 2001).]
+Pie Number of slices to send: Send
Hi Jyoti
I have set the class path but i am still having the same problem.
canyou tell me a little step by step process how to go about compiling our first application.
I will be very thankful
Regards
Preety Agarwal
+Pie Number of slices to send: Send
Ok ! no problem, i am telling you the whole steps:
First :
set all the required paths, suppose your j2sdkee1.2.1 dir is in C drive.Open the Autoexec.bat file and then set path:
set path=c:\j2sdkee1.2.1\bin
set java_home=d:\jdk1.3\
set j2ee_home=c:\j2sdkee1.2.1\
set classpath=%classpath%;c:\j2sdkee1.2.1\lib\j2ee.jar
and then save it and after that run it in dos prompt.Like : c:\autoexec.bat
Second:
Suppose your working dir is : testejb in c:.Copy all the source file in this dir .for example : testHome,testRemote,testBean.And then goto the dos prompt like: c:\testejb>
Now compile all this files.Remember, first compile the remote interface and then set the classpath of current dir like:
set classpath=%classpath%;.
and then compile other files.
After that, run the j2ee server and give the deploytool command in the dos prompt .
Third, follow the steps for deploy the ejb and creating jar file which available in the doc directory under j2sdkee1.2.1.
After all that ,open your working dir ,you can find client jar file.Set path of that jar file and execute the client program.
I hope , now it will work.

Jyotisree

+Pie Number of slices to send: Send
make sure that "." and j2ee.jar Path are there in your CLASSPATH.

save all your related files( home,remote,bean ..) in to one folder. say C:\pathto\myDir\

now in command prompt,

cd C:\pathto\myDir

javac *.java
wait for the error listing(wish all ur programs compile with out any errors)

if u r still getting error messages, which is mostly unlikely, copy and paste them in your next post.

take care
+Pie Number of slices to send: Send
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

+Pie Number of slices to send: Send
array yaar prasanna its nice that u have given a step by step version but yaar i think u r working on ejb 1.0?? there are some changes in ejb 1.1 bro,plzz check.

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


What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1282 times.
Similar Threads
Help To fix J2ee_HOME...please
Getting error Build failed while running asant
j2sdkee1.2.1 and The Sun' Tutorial Exercise 1
Newbie to J2EE
Problem In Starting J2EE
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 00:48:26.