Sapana Mehta (CS 6V81) Instructions for using Jboss User Manual.

24
Sapana Mehta (CS 6V81) Instructions for using Jboss User Manual

Transcript of Sapana Mehta (CS 6V81) Instructions for using Jboss User Manual.

Sapana Mehta (CS 6V81)

Instructions for using Jboss

User Manual

Sapana Mehta (CS 6V81)

How to Deploy on JBoss

1. Write your beans and package them in an ejb-jar file.

2. Write your servlets/JSPs and package them in a war file.

3. Add a Class-Path attribute to your war files MANIFEST.MF file to reference your beans package. for detailed information on that see J2EE Deployment specification.

Sapana Mehta (CS 6V81)

How to Deploy in JBoss

4. Package your application in an ear file.An ear file is a jar archive which contains:

• Your jar files • Your war files • A deployment descriptor for your

application.

This file must be named "application.xml", and must belocated in the META-INF directory in the ear archive. Thisfile tells JBoss which modules are EJBs, which ones areweb modules, and the context paths for the web-modules.

Sapana Mehta (CS 6V81)

Sample Application.xml file

<?xml version="1.0" encoding="ISO-8859-1"?> <application> <display-name>My application</display-name> <module> <web> <web-uri>webmodule.war</web-uri> <contextroot>/servlets</context-root> </web> </module> <module> <ejb>beans.jar</ejb> </module> </application>

Sapana Mehta (CS 6V81)

Deploying in JBoss

5. Deploy your ear file.

Option 1: Copy your ear file to JBOSS_HOME/deploy (wow!)

Write once Deploy AnyWhere!!

Sapana Mehta (CS 6V81)

Steps A

• Log on to the system using username and password of UTD• Log on to

ssh root@jboss• Password : root123

Screen shot on next page

Sapana Mehta (CS 6V81)

Sapana Mehta (CS 6V81)

Step B

• To set path and start the Jboss and cloudscape run the following command (every time server goes down)

export J2EE_HOME=/usr/j2sdkee1.3/export ANT_HOME=/usr/Ant/PATH=$PATH:/usr/Cloudscape_3.6/:/usr/j2sdkee1.3/bin/nohup cloudscape1098 -start&cd /usr/jboss/JBoss-2.4.1_Jetty-3.1.RC9-1nohup sh run.sh&

Sapana Mehta (CS 6V81)

Steps for Pet store Application

1. Download the Pet Store

You can get the source from Sun's J2EE Download Page. It's inthe "J2EE Blueprints" package.Download the 1.1.2 version. Unpackit anywhere. The root directory ofthe Pet Store demo is referred to belowas $PETSTORE (#stan/petstore1.1.2/jps1.1.2/)

Sapana Mehta (CS 6V81)

Step 2 For Pet store Application

2.Download the JBoss Pet Store patch fileRunning the Pet Store demo in Jbossrequires several minor changes todeployment files in the Pet Storeapplication (.ear) file. The current patchfile, jps112-01.zip is currently available inthe documentation files section of themanual.

Sapana Mehta (CS 6V81)

Step 3

3. Configure JBossYou need a servlet container to run the Java PetStore. If you're using the JBoss-Jetty or JbossTomcat releases, the server is preconfigured.• DO not need to do do this step

Sapana Mehta (CS 6V81)

Step 4

4. Rebuild the Pet Store application (petstore.ear)

The following step overwrites several filesin the Pet Store application sources. Youmay want to make a separate copy of theJBoss version of the Pet Store.This step adds the file jboss-web.xml tothe WEB-INF directory in petstore.war,modifies the serverType in the web.xmlfile of that directory to identify the Jbossserver to the application, and modifiesthe application.xml file in the META-INFdirectory of petstore.ear.

Sapana Mehta (CS 6V81)

Step 4A

4A. Copy the jps112-01.zip file to the rootdirectory ($PETSTORE) of your Pet Storedistribution. Change to this directory andunzip the file.

Note: This will overwrite the original web.xml file.

>cd $PETSTORE (#stan/petstore1.1.2/jps1.1.2/)

unzip jps1.1.2-01.zip

Sapana Mehta (CS 6V81)

Logged on and directory having petstore example

Sapana Mehta (CS 6V81)

Step 4B

4B. Rebuild the Pet Store application. Run build.sh or build.bat in the$PETSTORE/src/petstore/build directory.

The result is a new petstore.ear in the$PETSTORE/src/petstore/build directory.

This is the file you deploy by copying it to $JBOSS_HOME/deploy

Sapana Mehta (CS 6V81)

Build directory having all three war, jar and ear files

Sapana Mehta (CS 6V81)

Step 5

5. Prepare the DatabaseModify the Cloudscape startup command to useport 1098.

You do this by adding -port port_number. Forexample:

java ... RmiJdbc.RJJdbcServer -port 1098COM.cloudscape.core.JDBCDriver

Start Cloudscape.

Sapana Mehta (CS 6V81)

Deploy directory in JBoss home path

Sapana Mehta (CS 6V81)

Step 6

6. Add JARS to JBossCopy your DB driver JAR to the lib/extdirectory of your JBoss installation($JBOSS_HOME).

For Cloudscape, copy client.jar andRmiJdbc.jar to the lib/ext directory.

Copy tools.jar from the J2 SDK to thelib/ext directory of your JBoss installation($JBOSS_HOME).

Sapana Mehta (CS 6V81)

Step 7

7. Start JbossAlready done by doing Step BStart JBoss and copy the newpetstore.ear to the deploy directory.You should see JBoss deploy the PetStore EJBs.

Sapana Mehta (CS 6V81)

Step 8

8.Run the Pet StorePoint your browser to http://jboss.utdallas.edu:8080/estore

To start pet store example

Sapana Mehta (CS 6V81)

Problems faced

1.When user logged off the system, initially the JBoss application was stopped and the application can not be displayed.

In order to solve this problem, use nohup command

For Jboss: nohup sh run.shFor cloudscape: usr/cloudscape_3.6# nohup cloudscape –

start

Output of nohup in ‘nohup.out’ file> Tail –f nohup.out

Sapana Mehta (CS 6V81)

Problems faced

2. Cloudscape and JBoss were both using same port number 1099 and as a result it was not possible for application to run

We changed the java commands in the cloudscapeexecutable file as per the new java command and saved itas 'cloudscape1098' so that whenever we type'cloudscape1098 -start', cloudscape starts on port 1098.

Even then JBoss couldn't connect to Cloudscape. Thereason was that there is a jboss.jcml configuration file in/usr/jboss/JBoss-2.4.1_Jetty-3.1.RC9-1/jboss/conf/jettydirectory. It contains a section where JDBC tries to connectto Hypersonic database. This had to be changed to makeJDBC connection to Cloudscape.

Sapana Mehta (CS 6V81)

Problems Faced

3.Application is killed when server restarted

To restart the pet-store anytime, all need to be done is run the following commands: export J2EE_HOME=/usr/j2sdkee1.3/ export ANT_HOME=/usr/Ant/PATH=$PATH:/usr/Cloudscape_3.6/:/usr/j2sdkee1.3/bin/nohup cloudscape1098 -start&cd /usr/jboss/JBoss-2.4.1_Jetty-3.1.RC9-1 nohup sh run.sh&