File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Guide to deploy  the AdviceBean on WebLogic 8.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Guide to deploy  the AdviceBean on WebLogic 8.1" Watch "Guide to deploy  the AdviceBean on WebLogic 8.1" New topic
Author

Guide to deploy the AdviceBean on WebLogic 8.1

Magnus Stattin
Ranch Hand

Joined: Jun 05, 2003
Posts: 65
This is a step by step guide on how to deploy the Advice beans to Weblogic Server 8.1 as John Liang suggested in a previous topic.
I will start from the beginning and try to explain every required step. I will only use the build tool Ant and the Weblogic command line tool weblogic.appc to make the process as transparant as possible.
I made this example on Windows 2000, but it works the same way on Linux (The only differences are how you Start the server and configuration wizard and the bea.home parameter in the build.properties file).
If you have the Weblogic server up and running and have configured a domain already, you can skip down to point 4.
1. Download Bea Weblogic Server 8.1 from http://commerce.bea.com/index.jsp.
2. Install Weblogic. The installation process is very easy.
a) I'm choosing C:\bea as my BEA Home Directory.
b) I'm choosing to make a complete installation.
c) I'm keeping the default values for everything.
More information about the installation process is availible here: http://edocs.bea.com/wls/docs81/install/index.html

3. Create a new domain for the application.
a) Go to Start/Program/Bea WebLogic Platform 8.1/Configuration Wizard.
b) Select Basic WebLogic Server Domain as Configuration Template.
c) Choose Express Configuration.
d) I'm choosing weblogic as password.
e) Choose developing mode and select the Sun SDK that is supplied by Bea.
f) Let mydomain be the name of the configuration.
More information on how this is done is availible here: http://edocs.bea.com/wls/docs81/adminguide/createdomain.html#1127576
4. I will use the same file structure att Kathy uses in Head First EJB. I start with only the source-files in the src folder.

You can download the stucture including all files from http://www.offthebeatentrack.se/advice/advice.zip
5. I will be using the ant-tool to compile the source-files and to create the stubs and container generated implementations of the interfaces (EJBObject and EJBHome). Ant can be downloaded from: http://ant.apache.org.
Ant uses a build.xml file to compile files and for other stuff. The build.xml file and all other files I use in this example is included in advice.zip.
6. To be able to compile the source-files I put the build.xml file and the build.properties file in the advice folder. Change the paths in the build.properties if your configuration differs from mine. We also have to add the deployment descriptors to a folder named META-INF in the classes folder as this:


The ejb-jar.xml is the same as in Head First EJB. weblogic-ejb-jar.xml is an additional descriptor used by Weblogic and in this case it only include a simple mapping between the Bean-name AdviceBean and the JNDI-name Advisor.

7. Now are we ready to compile the source-files. I open a command prompt and cd to the advice directory. Then I invoke the ant build script with "ant build" to compile the files.
C:\>cd projects\advice
C:\project\advice>ant build
This will put Advice.class, AdviceBean.class and AdviceHome.class in the classes/headfirst folder.
8. weblogic.appc compiler is the recommended approach for EJB compliation in WebLogic Server 8.1. It will examine the compiled classes and the deployment descriptors and create the stubs and the container generated implementations of the interfaces for us. I use "ant appc" to invoke the weblogic.appc. Please see the build.xml file to see how this is working.

C:\project\advice>ant appc
This will put all the container generated files in the classes/headfirst folder.

9. We are now ready to make a deployable jar-file of the classes in the headfirst folder and the deployment descriptors in the META-INF folder. I use "ant makejar" to make the jar.
C:\project\advice>ant makejar
This will create a jar file named AdviceApp.jar in the advice folder.
10. Deploy the AdviceApp.jar to the weblogic server.
a) Go to Start/Program/Bea WebLogic Platform 8.1/User Projects/mydomain/Start Server
b) Open a webbrowser and go to http://localhost:7001/console
c) Login using the password given when you created the domain (weblogic)
d) Go to deployments/EJB Modules and choose Deploy a new EJB Module
e) Choose upload your file(s) and upload the AdviceApp.jar.
f) Click on "myserver" and then on "upload" select AdviceApp.jar and click "Target Module".
e) Review your choices and click deploy. Hopefully the bean will be deployed sucessfully.

11. Create a client to test the bean. One difference between the Sun RI and Weblogic Server is that you have to specify how to get hold of the InitialContext. This can be done like this for Weblogic:
--------
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, "t3://localhost:7001");

Context ic = new InitialContext(properties);
--------
A AdviceClient.java i provided in the advice.zip. Copy it to the advice directory. Invoke "ant buildclient" to compile the client. Notice that I have named the business method getMessage() instead of getAdvice().
C:\project\advice>ant buildclient
Basicly this as the rest of the build scripts are very simple. It will compile AdviceClient.java to AdviceClient.class in the same directory. This can of course be done with javac, just be sure to include $BEA_HOME/weblogic81/server/lib/weblogic.jar and AdviceApp.jar in the classpath.
I'm using the AdviceApp.jar, the same as we used to deploy the bean, to make the stubs and interfaces availible to the the client. AdviceApp.jar includes more than the client needs (the bean and server side implementations of the interfaces) but it is easier in this case.
12. Run the client. To run the client you can use the "ant run" command (make sure the server is running).
C:\project\advice>ant run
Another way is to use the run.bat included i advice.zip like this:
C:\project\advice>run
Please see the build.xml or the run.bat to see how it works.
[ December 14, 2003: Message edited by: Magnus Stattin ]
vikram goyal
Greenhorn

Joined: Nov 21, 2003
Posts: 7
Magnus
Great job
Thanks
V
Ed Tse
Ranch Hand

Joined: Sep 18, 2003
Posts: 183
the client for weblogic is app server specific. I thought the client should also be WORM.


SCJP, Pre-SCJD (URLyBird 1.3.1), Teradata Cert'd Prof
Magnus Stattin
Ranch Hand

Joined: Jun 05, 2003
Posts: 65
Every application server has its own way to get the initial context. So the properties you have to specify is different. The reason why the client for the RI is simpler and seems to be generic is the default values happens to be sufficient as long as the client is located at the same server as the EJB is deployed.
/Magnus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Guide to deploy the AdviceBean on WebLogic 8.1
 
Similar Threads
Configure Weblogic 8.1
clustering in weblogic
using custom tags with weblogic
Entity Bean instance pool!
compiling ejb