wood burning stoves 2.0*
The moose likes BEA/Weblogic and the fly likes how to deploy EJB.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "how to deploy EJB.." Watch "how to deploy EJB.." New topic
Author

how to deploy EJB..

megala raghavan
Greenhorn

Joined: Jun 01, 2003
Posts: 7
i have created the bean, home and remote interfaces.. when i try to deploy on weblogic 8.1 . do i need to create the .properties files and what and all i have to specify here and ejb.jar and weblogic-ejb.jar.
thanks in advance..
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi can u pls tell me whether u have Compiled ur EJB's or not i have prepared a step by step procedure to Deploy a EJB on weblogic 6 & 7 and i fee it will work on weblogic 8 also if u feel any problem pls send me mail with details.
***********************************************
1.Create a directory where you are going to write all your session beans(Applicable to both Stateless and stateful ).
2.If your session beans are to be in a package then a good option would be to use JCreator for compilation otherwise you have to compile always with the �d option and have to create complicated batch files with classpath settings.
3.For eg. if you have a package statement like -
package examples.SessionBeans;
Then you need to have a directory called examples inside which you need to have a directory called SessionBeans or some Name.
4.Inside the SessionBeans directory put your Home Interface, Remote Interface and Bean classes.
5.Inside the SessionBeans directory create a directory called "META-INF". Note that all the letters should be in capital.
6.In the META-INF directory put your ejb-jar.xml. This you will get along with any sample code.u can search in bea folder also.
7. You need to create another file called weblogic-ejb-jar.xml with the following lines
<?xml version="1.0"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN" "http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd">
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>UserSessionBean</ejb-name>
<jndi-name>UserSessionHome</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
The ejb name that you specify should be same as the one you specify in the ejb-jar.xml. The jndi-name is the one you should use when looking up the home from the JNDI tree.
8. Create a jar file from one level above the package structure where your class files are.
For eg. if your classes are in a package called examples.SessionBeans, the jar file should be created from one directory above the examples directory.
9.Open the jar file in winzip and make sure the directory structure is OK and the XML files are inside the META-INF directory.
10. You now need to do an ejb compilation. Though this is not mandatory it is very useful as it checks your bean�s validity. If your ejbc goes through successfully you can be sure that your bean will be deployed successfully.
The command for ejbc is as follows
java weblogic.ejbc -g -classpath %CLASSPATH% -compiler javac <src-file> <dest-file>
For ease of use, create a batch file called ejbc.bat and put the following lines in it
SET SOURCE_JAR=%1%
SET DEST_JAR=%2%
set classpath=C:\bea\weblogic700\server\lib\weblogic.jar;
java weblogic.ejbc -g -classpath %CLASSPATH% -compiler javac %SOURCE_JAR% %DEST_JAR%
Make sure the classpath is OK.
The bat file can be used as follows
ejbc <Source-bean-jar> <Source-bean-deployable-jar>
For eg.
ejbc UserBean.jar UserBeanDeployable.jar
11. You now have a Enterprise Java bean that is ready to be deployed !!!
12. In Weblogic 7.0 put the jar file created as a result of the ejbc in the following directory
C:\bea\samples\server\config\examples\applications. For Weblogic 6.0 or 6.1 there should be a similar directory called applications where you place your code.
13. Start the Weblogic server. Note that you can put the file here even after you have started the server, any files that are added to this directory are automatically deployed, any that are removed are undeployed and any file whose time stamp changes will be redeployed.
14. If you have a client that you need to run to call the methods of this bean do so with the following class file.
set classpath=.;c:\bea\weblogic700\server\lib\weblogic.jar;
java -Djava.naming.factory.initial=weblogic.jndi.TengahInitialContextFactory -Djava.naming.provider.url=t3://192.10.137.165:7001 <Client-java-class>
You can set the Initial context factory and naming provider url even inside your code if you want but this is a better way. The �D option basically sets a System property.
15.You have now deployed and tested a Session Bean
pls don't do step 10 i mean EJB COmpilation if ur a Beginner.
After ur bean will be Deployed u can check from the Console or the CMD prompt of server where ur Beans name will appear.
i would suggest u to follow ad Roman book n do first "Hello World" Example so that u Deploy n test. u can get a book of EDRoman Mastering ejb from www.theserverside.com.


SCJP 1.2
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Moving to the BEA/WebLogic Forum...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to deploy EJB..