Integrating JBuilder 6 Personal Edition with JBoss 2.4.4_Tomcat-4.0.1

By: CodeGear

Abstract: Abstract: This document is a step-by-step guide to setting up and running a JBoss server instance, and debugging your EJB classes all from within JBuilder 6 Personal Edition. By Brent Thompson

Integrating JBuilder 6 Personal Edition with JBoss 2

Setting up the JBoss Server Instance

Before we start, on your machine you must have installed:


7
Jdk1.3.1_xx

7 J2sdkee1.3

7
Jakarta-ant-1.4

7
JBoss2.4.4_tomcat-4.0.1.zip

7
documentation-example.zip from the www.jboss.org site

Note:

There is a JBoss Setup Wizard that will automate the process of setting up the server instance. If you have the JBoss Setup Wizard then you can skip to section Setup a Debug Session and continue from there. This wizard will setup JBoss running in default, tomcat or catalina. The wizard can be found on code central id#17446. This document will setup the JBoss server to run catalina.

7 For this discussion, the JBoss distribution is unzipped to c:jboss2.4.4 and the environment variable ANT_HOME is     set to

C:jakarta-ant-1.4

7 This will allow you run ant from the command line

7 Unzip the documentation-example.zip. In this case the directory is

          C:javaexamples

7 Startup JBuilder and create a new project called jbsetup

7 Click on the Finish button.

7 What we want to do is define a new library, which contains the required jar files and paths to run the server and compile our ejbs and client applications. In this case, we will be adding all the Jboss and tomcat jar files.

7 Next select from the projects menu Project/Project Properties/Required Libraries Add and New. Type in JBoss-server for the library name. DO NOT add anything at this point, we will open the file in WordPad and add the libraries we need.

 

7 Click OK and you should have this screen

7 Now go to the .jbuilder6 directory, note there is a "." In front of this directory.

7 This file on my machine is located at

           C:Documents and Settingsbthompson.BRENTW2KHOME.jbuilder6

7 In explorer, go to this directory and open up the file you just created called jboss-server.library. Open this file in WordPad. You should have the following:

<?xml version="1.0" encoding="UTF-8"?>
<library>
<!--JBuilder Library Definition File-->
<fullname>jboss-server</fullname>
</library>

7 Cut and paste the following into this file, overwriting the previous text. Remember to change to the correct path on your system. (All that should change is the c:/jboss2.4.4 part)

<?xml version="1.0" encoding="UTF-8"?>
<library>
<!--JBuilder Library Definition File-->
<fullname>jboss-server</fullname>
<class>
<path>[C%|/JBoss2.4.4/jboss/lib/crimson.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/common/lib/mail.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/common/lib/jdbc2_0-stdext.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/common/lib/jndi.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/common/lib/tyrex-0.9.7.0.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/common/lib/naming-resources.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/common/lib/naming-common.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/common/lib/activation.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/common/lib/jta.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/common/lib/xerces.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/common/lib/servlet.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/server/lib/servlets-manager.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/server/lib/servlets-invoker.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/server/lib/jakarta-regexp-1.2.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/server/lib/servlets-snoop.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/server/lib/tomcat-ajp.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/server/lib/servlets-default.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/server/lib/warp.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/server/lib/tomcat-util.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/server/lib/servlets-webdav.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/server/lib/catalina.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/server/lib/servlets-common.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/bin/bootstrap.jar]</path>
<path>C%|/JBoss2.4.4/catalina/conf</path>
<path>[C%|/JBoss2.4.4/catalina/lib/jasper-runtime.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/lib/jasper-compiler.jar]</path>
<path>[C%|/JBoss2.4.4/catalina/lib/naming-factory.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/activation.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/castor-0.9.1.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/tyrex-0.9.8.5.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jboss.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jpl-util-0_5b.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jbosssx.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jcert.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jboss-management.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jbosspool.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jndi.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/gnu-regexp-1.0.8.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/oswego-concurrent.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jsse.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/ots-jts_1.0.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jbossmq.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/log4j.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/hsql.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jmxtools.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jbosscx.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/hsqldb.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jnpserver.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/mail.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jnet.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/jboss-j2ee.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/ext/catalina-service.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/jboss-jaas.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/jaas.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/jmxri.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/jboss-jdbc_ext.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/lib/jaxp.jar]</path>
<path>C%|/JBoss2.4.4/jboss/conf</path>
<path>C%|/JBoss2.4.4/jboss/conf/catalina</path>
<path>[C%|/JBoss2.4.4/jboss/bin/verifier.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/bin/BeanCacheMonitorJMX.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/bin/run.jar]</path>
<path>[C%|/JBoss2.4.4/jboss/bin/BeanCacheMonitorJMS.jar]</path>
<path>C%|/JBoss2.4.4/jboss/tmp</path>
</class>
<required>jboss-server</required>
</library>

7 Save the file.

7 To verify select project properties/required libraries, select Add and under User Home select jboss-server, then click on the Edit button and you should see

7 Select Ok then Ok again and you will be back to the project view in Jbuilder.

7 Open Project -> Project Properties -> Run and select

Main Class: org.jboss.Main

7 Copy and past this under VM Parameter:


-Dtomcat.home=C:JBoss2.4.4catalina -Duser.dir=C:JBoss2.4.4jbossbin -Djavax.xml.parsers.SAXParserFactory=org.apache.crimson.jaxp.SAXParserFactoryImpl -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.crimson.jaxp.DocumentBuilderFactoryImpl

7 Under Application Parameter:
catalina

7 We now have created a project called jbsetup, the required libraries and runtime parameters. Our next step is two modify some of the configuration parameters in the JBoss conf files.

Modify log4j.properties and jboss.jcml

7 There are two was to configure JBuilder to run JBoss.

7 One is to set under Project/Project Properties/Paths the working directory as:

                    C:/JBoss2.4.4/jboss/bin for jbsetup.jpx

7 Then you can leave the conf files as is

OR

7 If you want to use the existing projects working directory.

7 Go to file C:JBoss2.4.4jbossconfcatalinalog4j.properties.

7 In this file change the line

                    log4j.appender.Default.File=../log/server.log

7 To

                    log4j.appender.Default.File=C:/JBoss2.4.4/jboss/log/server.log

7 You also want to go to the Auto Deployment section in file C:JBoss2.4.4jbossconfcatalinajboss.jmcl and add in

7 C:/JBoss2.4.4/jboss/deploy,C:/JBoss2.4.4/jboss/deploy/lib

7 where you see ../deploy,..deploy/lib


<!-- Auto deployment -->
<!--=============================================================== -->
<mbean code="org.jboss.ejb.AutoDeployer" name="EJB:service=AutoDeployer">
<attribute name="Deployers">
J2EE:service=J2eeDeployer;
JCA:service=RARDeployer
</attribute>
<attribute name="URLs">C:/JBoss2.4.4/jboss/deploy,C:/JBoss2.4.4/jboss/deploy/lib</attribute>
</mbean>

7 We have to modify this file because the relative paths are now based on your project, not the JBoss installation.

7 Now what we can do is start jboss, select Debug and you should see a Main tab at the bottom left hand corner of the IDE, with the jboss server process initializing.

7 It should be error free. If there are any errors, go back over the config files and check that you paths are correct.

7 The next step is to unzip the javaopen example, create a new project,specifying our previous project as the default.

Setup a Debug Session

7 Unzip the documentation-example.zip file to your disk. We will use

c:javaexamples our directory for the example files.

7 Your directory should now read

                    c:javaexamplesbuild
                                             org
                                             resources

7 Stop the JBoss instance from running and select Project/Project Properties and add the source path to the jbsetup project and click OK and restart the debug session.

7 This will allow us to debug our EJB code.

7 From JBuilder select file/New Project input the following:

7 Click on next and you should have the following, then under required libraries click on add

7 Under required libraries we should see

7 Here we want to add a resource file that comes with our example, select it under required libraries. Click Add/ the New and type in resource for the name, then select the following file.

7 Click OK

7 We should now see our new project, with the JBoss server instance still running.

7 We want to add our java files to the project. To do this right click on the project pane and select Add File/packages.

7 Select Ok

7 Right click on examples.jpx and select rebuild.

7 Now open Project -> Project Properties -> Run and select InterestClient.

7 To recap what we have done up to now. We have created a project called examples which contains our client code and includes the jboss-server library. We have compiled all our client and EJB code from within Jbuilder. What we want to do now, is use ant to create a EJB JBoss jar file that we can deploy, then debug the code from within JBuilder.

7 Open a cmd window and cd to the jboss example files.

                    cd c:javaexamplesbuild

7 At the prompt type

                    c:> ant intro-interest-jar

7 The jar file we just create can be found in C:javaexamplesbuild-examplesinterestinterest.jar

7 Copy this jar file to C:jboss2.4.4jbossdeploy

7 We should now see in the JBuilder message view just above the Main tab the following :

7 JBoss has deployed our interest EJB.

7 Select a break point.

7 and here

7 Select debug and we should see the following

7 Stepping through, press F8 we will end up in our Main instance stopping at the break point we set in the Interest Bean

7 We can now step through our client app and EJBs. If you want to step through JBosss code then you will have to set the appropriate source paths to the JBoss source.


Server Response from: ETNASC04