Hello John,
 
I would like to encourage you to do this for JBuilder. However, IMHO setting up JBuilder is easier than VAJ, but VAJ is more powerful once everything works.
 
Nikolaus
----- Original Message -----
Sent: Friday, October 20, 2000 6:14 PM
Subject: Re: VAJ Tomcat, JOnAS, Struts Mini HOWTO

request for HOWTO
 
maybe I can do something similar for JBuilder or have you seen this somewhere already
 
thanks,
john archer
 
----- Original Message -----
Sent: Thursday, October 19, 2000 5:25 PM
Subject: VAJ Tomcat, JOnAS, Struts Mini HOWTO

Hello,
 
I'm currently writing a Mini HOWTO that just describes how to setup JOnAS, Struts and Tomcat under IBMs Visual Age for Java 3.5. As there have been some questions in the mailing-list concerning this I would send it to all who request it by email.
 
Best regards
 
Nikolaus Rumm
Title: VAJ J2EE with Open Source Tools Mini-HOWTO

IBM Visual Age For Java J2EE with Open Source Tools Mini-HOWTO

Version: Pre-Release 0.1

Date: 2000-10-19

Author: Nikolaus Rumm


What this Mini-HOWTO is about

This Mini-HOWTO describes how to setup IBM Visual Age For Java 3.5 Professional Edition for J2EE development using only VAJ and Open Source tools. The resulting environment will provide a J2EE EJB 1.1 compliant application server and a servlet/JSP container.

What this Mini-HOWTO is not about

  • How to use VAJ.
  • How to develop J2EE applications.
  • How to use the required tools (with or without VAJ).

Copyright Notice

(c) Copyright 2000 by Nikolaus Rumm. All registered trademarks used in this HOWTO belong to their owners. This document is provided 'as is'. No one shall make me responsible for any damages, loss of data or other failure caused by following the instructions.

I am not responsible for copyright and/or license agreement violations that one can make upon following these instructions. Read the license agreements of the downloaded and used tools carefully.

Furthermore this HOWTO is absolutely unsupported. Please do not ask for help on your specific application's problems. However, suggestions about improvements on this HOWTO, error reports, success stories (especially under Linux) and other critique is highly appreciated and will help me to improve this document. I hope that it will reach a state that allows me to make it available to a wider public.

Language warning: As I am not an english native speaker there will be many mistakes in the text. If anyone finds some I would much appreciate to hear from you so that I can fix them.


Introduction

This Mini-HOWTO gives you detailed instructions on how to setup IBM's Visual Age For Java 3.5 Professional Edition for developing Java 2 Enterprise applications by using freely available Open Source technology. The reason for writing this document is that I had to setup my own VAJ to cooperate with these tools and VAJ 3.5 was so instable for me that I had to reinstall it several times, following this procedure. Upon setting up the environment I always forgot to do some necessary step and so I started to write a text file, which is the core of this document. The result of the setup might not look very impressive, but that's not the point. The procedure is not sophisticated in any kind, but I found it very frustrating to setup things, worry about 'InvocationTargetExceptions', 'UnsatisfiedLinkErrors' and missing 'MESSAGE-resources' and solve classpath problems and other things that only freaks like to do.

Why use Open Source software for J2EE development ?

Why should you want to use Open Source software for J2EE development if there are many commercial tools available ? Well, the obvious answer is that commercial tools (including IBM's Websphere) cost money and J2EE application servers usually start from some thousand U.S. dollars per installation, which is quite much for a small company or someone who wants to train himself on J2EE development. Although most application server vendors provide free evaluation versions or free developer licenses of their products, you will not be able to deploy your application without paying quite a sum of money (or risking some legal activities against your person...). The fact that Open Source software is free does not mean that there isn't much work behind it. So if you can support the guys who do this great work just for interests and fame but not for money. That's the commercial point of view.

Furthermore, in my opinion Open Source products are more stable once they've reached a mature state which all of the required tools (with exception of Tomcat Struts) have now. The support by the Open Source community is very good. Support reaction times are not guaranteed, but normally you get accurate and useful replies from some competent person within hours. If there are known problems, patches are delivered quickly. And unlike others who love to integrate proprietary things into their products just to increase customer dependence the Open Source tools tend to stick to accepted standards. Whoever has been depending on some major player's support knows what I'm speaking of.

However, there's a price for this. The documentation of these products often does not extend some html-drafts like this Mini-HOWTO, there are no 'multimedia tutorials', nore are there sophisticated integrated tools (like IBM's Websphere Studio). So be warned: If you want to develop J2EE applications in a productive environment with guaranteed professional support, trained people from the job market and tool integration, you should definitely choose a professional product like IBM's Websphere.


Prerequisites

As there are many possible setups of VAJ on your machine, this HOWTO makes the following assumptions:

IBM Visual Age For Java 3.5 Professional Edition has just been installed. As we will import many classes this setup won't work with the VAJ Entry Edition, which has a limit of some hundred classes (however, there is some chance that it is possible to do it if you keep most of the stuff out of the repository, but I've never tried this. Developing J2EE applications with a limit of some hundred classes is pointless). The repository and the workspace are set to the default installation. Especially, the features 'IBM Enterprise Extension Libraries 3.5' and 'IBM XML Parser for Java 2.0.15' have not been brought into your workspace. You will need the 'Apache Tomcat Test Environment', which is available for download from the VADD.

Check the links on the bottom of this document for the required tools.

You've successfully installed and setup JOnAS to work with your database, are able to launch the server from outside the VAJ IDE and especially are able to generate the server classes from the command line. See the JOnAS docs on how to do this. This prerequisite requires that you've downloaded the required JNDI-classes (see the JOnAS docs).

You've downloaded the Tomcat Struts binary distribution and all of it's required prerequisite Jars (parser.jar and jaxp.jar). See the Struts docs on where to find these things.

You have experience with VAJ. For convenience I do not explain things like 'How do you add a feature to VAJ step by step'. Please forgive me for my ignorance, but if you want to write server-side J2EE applications with VAJ it is a very strong prerequisite to be able to use the IDE.

Well, this HOWTO has been made for MS Windows NT/2000 users. However it should be possible with little changes to do it under Linux, too. If you're a Linux freak it will be easy to guess the changes on the path settings (let me know if you succeeded, so that I can update this HOWTO).

The setup has been tested on my own machine, which is...

  • MS Windows 2000 Professional with SP1
  • IBM Visual Age for Java Professional 3.5 with patch 1 and a clean, fresh repository
  • IBM's Apache Tomcat Test Environment
  • Envidian / Bullsoft's JOnAS application server 2.1
  • Tomcat Struts 0.5 binary distribution
  • PostgreSQL database running on a RedHat 6.2 server with a TCP/IP connection to the workstation and a database user exclusively setup for use with JOnAS (for security reasons)

What you will be able to do

After you've executed the following steps you will be able to...

  • Run the JOnAS application server inside the IDE
  • Set breakpoints in and debug your application's EJB classes whilst running the application server
  • Run Tomcat and it's rudimentary HTTP-server inside the IDE, enabling you to access your presentation layer from your web browser
  • Use Java Servlets / JSP's from inside the IDE and debug the compiled code using the IDE (however the debugging features are not as powerful as in the Websphere environment)
  • Use the Struts framework inside the IDE

What you will not be able to do

  • Generate the server classes from inside the IDE (must be done externally)
  • Generate most of the required EJB-interfaces and other classes with fancy wizards from inside the IDE (however, there are some tools available to do this. See the JOnAS homepage for further information)
  • Restart the application server in a soft way (you'll have to kill the process..)

Installation and setup procedure

Execute the following steps carefully. Especially the imports of jar-files must happen exactly in the stated order.

Step 1: Install and setup VAJ

1) Install VAJ 3.5 on your local machine. For convenience I suggest to use the folder 'VAJ' instead of 'Visual Age For Java'. This way you don't have to think about specialities on path settings.

2) Apply the VAJ 3.5 Patch 1. There have been rumors about if this patch actually helps but I did it and it worked so you should do it, too.

3) Install the Apache Tomcat Test Environment.

4) Launch VAJ and add the 'Apache_Tomcat_Test_Environment' feature (File -> Quick Start -> Add feature ...)

Step 2: Import and setup JOnAS application server

5) Add a new product to your workspace and call it 'Jonas'. I will refer to this project as the 'Jonas-project'.

6) Import RMI_Jonas.jar to the Jonas-project. This jar-file can be found in the lib-directory of your stand-alone Jonas installation. The import wizard will inform you that the javax.rmi and javax.transaction packages have been imported into pre-existing packages. Ignore this remark for now. The warning means that the RMI_Jonas.jar file contained some classes in some packages that VAJ has put into your workspace by default and that these classes have been imported into these preexisting packages.

7) Move the rest of the J2EE packages (javax.ejb, javax.ejb.deployment, javax.sql, javax.transaction.xa) that have been imported with Jonas from the Jonas-project to the 'Java class libraries' project. As these packages don't have associated resource files, you can safely ignore the resulting warning.

8) Import the JNDI jar-files (jndi.jar, providerutil.jar, rmiregistry.jar) into the 'Java class libraries' project.

9) Take a look at the 'all problems' tab. You should now have 1 deprecation warning in the Apache_Tomcat_Test_Environment project and 40 errors in the Jonas project. Next we will eliminate the errors.

10) Remove all erroneous classes from the Jonas package (they are not needed for running Jonas inside the IDE). Remember that before you can remove a class you have to remove all of it's inner classes. There are some iterations necessary until all problems are 'fixed', as the deletion of some classes causes other problems. This is some kind of 'brute force fixing', but it works. The reason why we have to do this is that the RMI_Jonas.jar contains some static references to external classes that have not been shipped with JOnAS.

11) Import the various *.properties files from your stand-alone JOnAS installation into the root-directory (for me this is 'H:\Program files\IBM\JAV\project_resources\Jonas') of the Jonas-project. (I didn't find a way to import resources to the project's root directory, because the IDE always selected some subdirectory when I opened the context-menu. If you don't find a way copy these files by hand...).

Now you have a stripped down version of Jonas along with all necessary J2EE packages and the Apache Tomcat Test Environment installed. The next step will be to get your EJB-application to run. Don't worry if you don't have an EJB application yet. JOnAS comes with some examples that you can use for this purpose. I hope you were able to run JOnAS external to the IDE and start these examples, as this is a good training for your to-come power applications :-)

11) Browse to the class org.objectweb.jonas.server.Server and set it's runtime parameters:

install.root=.
java.security.policy=./java.policy 

12) Setup the workspace classpath to include the project directory of your Jonas project and that of your application's project. This is necessary for getting VAJ's RMI registry to work. Don't forget to hit the 'Apply'-Button on the bottom of the options-dialog (or close the options dialog).

13) Restart the RMI registry (Window -> Options -> RMI registry -> Restart) and start the class org.objectweb.jonas.server.Server. Jonas should now run (but not do anything useful :-<). If it does not run, try to hit the 'apply'-button in the options dialog and restart the RMI registry. If it runs, kill the Jonas process.

We'll now setup your application.

14) Edit the jonas.properties file in the Jonas project to include your deployment descriptors. Remember to use '\\' instead of '\' for path separating and use an absolute path, i.e.

jonas.beans.descriptors H:\\Programme\\IBM\\VAJ\\ide\\project_resources\\Dolores\\com\\dolores\\ejb\\congress\\meeting\\META-INF\\ejb-jar.xml

Apply all changes that you've made to jonas.properties and the other *.properties files in your stand-alone JOnAS installation to the imported *.properties files. Although don't forget to import your database-setups.

14) Add your application's project to the Jonas runtime parameters (Tab 'class path' -> Project path)

15) Import your database's JDBC driver into the Jonas project or add it to the workspace CLASSPATH.


Summary of the JOnAS settings for org.objectweb.jonas.server.Server

Runtime properties:

install.root=.
java.security.policy=./java.policy

Project path:

<your application>

Extra directories path:

<empty>

Remember that the entries from the workspace CLASSPATH are inserted here automatically.

Workspace CLASSPATH

The workspace CLASSPATH will be used by VAJ's RMI registry. It must include your appplication's project directory and the project directory of the JOnAS-project. For me this is:

H:\Programme\IBM\VAJ\ide\project_resources\Dolores\;
H:\Programme\IBM\VAJ\ide\project_resources\Jonas\; 

Setting up Struts

1) Import struts.jar into the 'Apache Tomcat Test Environment'-project

2) Create a new project and call it XML

3) Now comes the weird thing: VAJ can't handle static references (i.e. through inheritance) to external classes, but Jonas and Struts need different versions of XML parsers. A workaround (some kind of a hack, though) is to move the relevant Jonas packages (org.w3c.* and org.xml.*) to the XML package and mix this with the XML parser API needed by Struts. Move the packages org.w3c.* and org.xml.* from Jonas to XML. Import jaxp.jar and parser.jar into XML. This is the weakest of all steps. If someone finds a better solution please let me know.

4) Check that there are no errors left (press F5 to refresh the 'All Problems' display).

5) Add the project 'XML' to the runtime path ('project path') of Jonas' Server class and to the runtime path ('project path') of the com.ibm.ivj.tomcat.TomcatRunner class.

6) Start the com.ibm.ivj.tomcat.TomcatRunner class. Tomcat should start up without any errors. If you like you can test Tomcat by calling

http://localhost:8080

in your web browser and check out some examples. Stop and exit the Apache Tomcat test environment when you're finished. Do not kill the Apache Tomcat test environment thread, as this can have side-effects that require rebooting. Always use the Exit-Button of the small GUI.

7) If you like you can add the struts examples to the webapps directory of the 'Apache Tomcat Test Environment'. Just import the three *.war-files from the Struts distribution's webapps directory to the webapps directory of the Apache Tomcat test environment. After starting the 'Apache Tomcat Test Environment', the war-Files are extracted and the test applications are being installed. However, Tomcat can't find the required application classes by default, because the 'Apache Tomcat Test Environment' uses VAJs internal compiler and the compiler can't resolve static references to external classes, so you have to import all these classes into the 'Apache Tomcat Test Environment' (you can find the classes in the src directory of the Struts distribution). Alternatively you could disable the compiler interceptor (as stated in the Apache_Tomcat_Test_Environment documentation), but I've never tried this, as you will loose the ability to debug the servlets easily within VAJ. Although do not forget to add every example's webapps directory to the extra CLASSPATH (both the WEB-INF\classes and the application's root directory) to get Tomcat to find the resources.

8) Test the struts examples in this order:

http://localhost:8080/struts-documentation
http://localhost:8080/struts-test
http://localhost:8080/struts-test/logic-compare.jsp
http://localhost:8080/struts-example 

9) I suggest to remove the three struts*.war files from the webapps directory to speed up Tomcat's startup and to avoid the annoying 'resources have been externally changed' messages.

10) After the work is done, version all your projects and get a cup of tea.


Summary of the 'Apache_Tomcat_Test_Environment' settings for com.ibm.ivj.tomcat.TomcatRunner

Command line arguments

org.apache.tomcat.startup.Tomcat 

Runtime properties:

tomcat.home=.
tomcat.dir=.

Project path:

XML

Extra directories path:

.\;
.\lib\webserver.jar;
.\lib\servlet.jar;
.\lib\xml.jar;
.\lib\jasper.jar;
.\conf\;
.\webapps\;
.\webapps\examples\jsp\;
.\webapps\examples\WEB-INF\classes\;
.\webapps\admin\;
.\webapps\admin\WEB-INF\classes\;
.\webapps\struts-documentation\; *)
.\webapps\struts-documentation\WEB-INF\classes\; *)
.\webapps\struts-test\; *)
.\webapps\struts-test\WEB-INF\classes\; *)
.\webapps\struts-example\; *)
.\webapps\struts-example\WEB-INF\classes\; *)
.\classes\;
..\JSP Page Compile Generated Code\;
..\IBM IDE Utility class libraries\;
..\IBM IDE Utility local implementation\; 

*) Only required if you installed the struts examples.

Remember that the entries from the workspace CLASSPATH are inserted here automatically.

Workspace CLASSPATH

The workspace CLASSPATH will be used by VAJ's RMI registry. It must include your appplication's project directory and the project directory of the JOnAS-project. For me this is:

H:\Programme\IBM\VAJ\ide\project_resources\Dolores\;
H:\Programme\IBM\VAJ\ide\project_resources\Jonas\; 

Common problems

RMI problems

JOnAS Server, version 2.1, running on rmi. 
TransactionService: Cannot rebind TM:
 javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException:
    Connection refused to host: localhost; nested exception is:
    java.net.ConnectException:    Connection refused: no further information]
JOnAS: Cannot start Transaction Service : EJBServer halting

Check if the RMI server has been started.

Struts example problems

...

javax.servlet.ServletException: Missing resources attribute org.apache.struts.action.MESSAGE 
java.lang.Throwable(java.lang.String)
java.lang.Exception(java.lang.String) 
javax.servlet.ServletException(java.lang.Throwable)

...

… You forgot to add the struts-example application's root and webapps\classes directories to the extra CLASSPATH of the com.ibm.ivj.tomcat.TomcatRunner class.


Where to go from here

Congratulations, you've successfully setup a J2EE development environment. I suggest that you import a well-known J2EE application into your workspace and set it up, so that it is running.

Unfortunately there is no small example application available that covers all three components (Tomcat, JOnAS, Struts). Maybe if someone finds time to write this, I would like to integrate it into this HOWTO.

Links

IBM Visual Age Developer Domain

Apache Tomcat Homepage

JOnAS Homepage

Struts Homepage

Sun Java Page

Reply via email to