I recently downloaded JBoss 3.2.1 and PostgreSQL 7.3.2. I am new to both. I have been having somewhat of a hard time finding out the correct jar files for compilation, and figuring out the correct way of configuring JBoss to connect to PostgreSQL. This document also assumes you are using the “default” JBoss server, if you are using another configuration, you need to modify your paths to match it. Paths shown reflect my system, replace with the correct path for your system. I am writing this document in the hopes that it might be useful to others in a similar situation. Of course, I am not responsible if any advice you take from this document damages your system.
At the time of writing (May 2003) JBoss 3.2 is very new and there is very little documentation available for it. Most of the documentation available online covers JBoss 3.0 or earlier, many things seem to have changed on 3.2, making the configuration a bit harder than usual. I had two choices, download and install JBoss 3.0, or stay on the leading edge and try to configure JBoss 3.2 with little or no help. Since 3.0 will probably become obsolete in the near future, and I always enjoy a challenge, I opted for downloading and configuring the latest JBoss production version, 3.2.1. I have no experience with previous versions of JBoss, I hope this document will help other JBoss newcomers.
One of the first things I tried once I installed JBoss, was to deploy a simple Session Enterprise Java Bean. When trying to compile the code, I kept getting unknown packages and classes, this was a clear indicator that some libraries were missing from my CLASSPATH. I noticed JBoss has a number of directories containing jar files, including /usr/local/jboss3.2.1/lib, /usr/local/jboss3.2.1/server/default/lib and /usr/local/jboss3.2.1/client. I started trying to compile my code, then went to the jar files on these directories and did a jar tvf on them, trying to find the missing packages and classes, after including a few in my CLASSPATH, the error messages started disappearing, then I noticed a couple of jar files that looked suspiciously like they might include every package needed for compilation. I tried adding only those files to my CLASSPATH, and sure enough, I was able to compile successfully.
Note: Either the directory or the jar file containing the EJB classes must be added to the client's CLASSPATH in order to successfully compile it.
comes with a default database called HypersonicSQL, if you choose to use it as your database, then no configuration is necessary. If you need to use another database in conjunction with , this section explains how to do it.
This section explains how to set up a database for use with . It uses PostgreSQL as an example, however the procedure is very similar for other databases. includes a number of example XML configuration files to set up a number of databases including, but not limited to: Oracle, Sybase, Informix, Access, SQL Server, MySQL and PostgreSQL.
copy /usr/local/jboss-3.2.1/docs/examples/jca/postgres-ds.xml to /usr/local/jboss-3.2.1/server/default/deploy, modify the connection url, username and password on said file to match the your environment.
Even though the postgres-ds.xml file has “PostgreDS” as the jndi name, the actual name that needs to be used to connect to the database via a JNDI lookup is “java:/PostgreDS”.
Each datasource configuration file configures JBoss to use a specific database, for example, in my system, under PostgreSQL, there are a few databases, it is possible to configure JBoss to use more than one, there can be more than one datasource configuration file for the same RDBMS, I would recommend naming them after the database, for example, if you have a database named SalesOrder, I would name the file salesorder-ds.xml, then modify this file to access the correct database.
PostgreSQL specific note: It was necessary to modify the postgresql configuration file ps_hba.conf and change the authentication method from “ident” to “md5” to be able to connect to the database through JBoss.
To make your newly configured database the default one for deployment of CMP Entity beans, modify /usr/local/jboss-3.2.1/server/default/conf/standardjbosscmp-jdbc.xml, look for 2 lines near the top that read like:
And modify them to point to your desired RDBMS and database, use the JNDI name assigned to the database as explained earlier in this section. The <datasource-mapping> must be one of the ones defined on standardjbosscmp-jdbc.xml under
Pick one that matches the RDBMS you are using (In my case, PostgreSQL 7.2).
After making all of the above changes, I was able to successfully compile, deploy and execute a very small sample application consisting of one Session Bean, which gets a database connection through JNDI, and a stand alone client application that calls methods on the Session Bean. In order to deploy an EJB, all that is needed is to copy the jar file into /usr/local/jboss-3.2.1/server/default/deploy (assuming you are using the default server.
I am using JBoss with Jetty as the integrated Servlet/JSP engine. If you are using Tomcat or any other servlet engine your mileage may vary.
To deploy a JSP, it needs to be put into a war file. a war file is nothing but a jar file with a .war extension. No other files need to be put into the war file to successfully deploy the JSP. To actually deploy the JSP, copy the war file to In case the JSP uses java beans, then the beans might be put in a jar file in a subdirectory called WEB-INF/lib on the war file. If this procedure is followed, then the beans will be available only to the JSP in that particular war file. To make the beans available to other JSPs,servlets, EJBS, etc they need to be put in a jar file, then the jar file should be copied to /usr/local/jboss-3.2.1/server/default/deploy. Deployed EJBs (and any jar/war/ear file contents copied to /usr/local/jboss-3.2.1/server/default/deploy) are available instantaneously to any JSPs, beans, etc (i.e. just as if they were in the CLASSPATH).