This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes EJB Compilation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB Compilation" Watch "EJB Compilation" New topic
Author

EJB Compilation

Preety Agarwal
Ranch Hand

Joined: Sep 28, 2000
Posts: 75
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
Jyotisree Dhar
Ranch Hand

Joined: Sep 15, 2001
Posts: 30
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).]
Preety Agarwal
Ranch Hand

Joined: Sep 28, 2000
Posts: 75
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
Jyotisree Dhar
Ranch Hand

Joined: Sep 15, 2001
Posts: 30
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

Ranjith R
Greenhorn

Joined: Sep 18, 2001
Posts: 22
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

Take care<BR>r@njith
s prasanna
Greenhorn

Joined: Oct 04, 2001
Posts: 2
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

Rohit Ahuja
Ranch Hand

Joined: Oct 04, 2001
Posts: 121
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



Face Off.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB Compilation
 
Similar Threads
Newbie to J2EE
Getting error Build failed while running asant
j2sdkee1.2.1 and The Sun' Tutorial Exercise 1
Problem In Starting J2EE
Help To fix J2ee_HOME...please