jzos.xml - unable to find

Issues and Questions related to running Apache Tomcat on z/OS
Post Reply
dfowler4
Posts: 13
Joined: Wed Apr 12, 2006 6:26 pm

jzos.xml - unable to find

Post by dfowler4 »

In http://www.jzos.com/docs/tomcat.html under the section Configuring a DB/2 JNDI datasource Step 3 instructs you to copy <JZOS_HOME>/tomcat/jsoz.xml to <TOMCAT_HOME>/conf/Catalina/localhost

I do not have a directory called tomcat under my <JZOS_HOME> directory. I did notice another post about jzos.war being missing.

I have been unable to make a connection from Tomcat (5.0.28) running under JZOS 1.2.3 (JDK 1.3.1 - z/OS 1.4) to our DB2 for z/OS version 7. Also the section mentions a JDBC test servlet. I cannot locate that either.

Is this step required? Are there any other docs that I could reference to
establish the connection to DB2 on the mainframe from Tomcat?

We are able to connect DB/2 with JDBC from the z/OS shell.

Thanks in advance for your help,
Dave.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Dave,

I apologize that these instructions are a little confusing.

First, the "jzos.war" that is references is the sample web application that is now part of the "TomcatSample" download. This package includes a sample Eclipse project that be hot-deploy to Tomcat. It uses the Tomcat "deployer" Ant tasks, and can be used from any IDE that supports Ant with a little setup. The JDBC sample servlet that you are looking for is included.

But if you don't want to use the sample Tomcat project, all you really need to do to use DB2 JDBC connections is to:

1) Update the server.xml as shown in the Tomcat setup how-to
2) Use the sample Tomcat JCL "TCJDBC2", since you are using type-2 drivers
3) Add a "resource reference" to the Tomcat web application context of whatever webapp that you want to connect to DB2. Tomcat 4 requires this to be added to server.xml, but Tomcat 5 allows it to be separate, as with the Tomcat setup instructions. Using the Tomcat ANT deployer, it can also be in a file called "META-INF/context.xml", which is where it is in the TomcatSample application. Here's that file:

Code: Select all

<!--Context for enabling JDBC under Tomcat -
	Tomcat 5: Copy this file to <TOMCAT_HOME>/conf/Catalina/localhost
	Tomcat 4: Insert this element in server.xml next to the other Context elements.  
	Note that other changes must be made to server.xml under both versions of tomcat.  
	See the Tomcat Setup HOW-TO for details -->
<Context path="/jzos" docBase="jzos" reloadable="true">
	<ResourceLink name="jdbc/db2" type="com.ibm.db2.jcc.DB2DataSource" global="jdbc/mydb2"/>
</Context>
This should work fine, but it may not be the best for high-performance JDBC servlets, since it doesn't use a JDBC connection pool.

DB2 has a JDBC connection pooling factory, buts it is complicated to setup and doesn't work nearly as well as the Apache "DBCP" pooling classes. The Tomcat docs can show you how to set these up with Tomcat 5.0.x, but it is messy.

If you go with Tomcat 5.5.x, this process has become VERY easy.
You don't even need to add resources to server.xml, everything can be setup in the web application. Here's an example of context.xml for a web app that uses the new DB2 Universal JDBC Drivers (which also support type-4 connections, as shown below). The Universal JDBC drivers are available if you are at DB2 V8 or with V7 and some PTFs.

Code: Select all

<!--Example Context for a Web app under Tomcat 5.5.
	Customize with your driver, HOST, PORT, DATABASE, etc.
	   
	For more information on configuration, see:
	
		http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html

	Configuration is somewhat different for Tomcat 5.0.X.  For example, the "commons-dbcp"
	and companion jars need to be present in <CATALINA_HOME>/common/lib.  For details, see:
	
		http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html
-->
<Context path="/jzos" reloadable="true">
	
  <Resource name="jdbc/db2" auth="Container" type="javax.sql.DataSource"
               maxActive="20" maxIdle="3" maxWait="10000"
               username="user" password="password" 
	  		   driverClassName="com.ibm.db2.jcc.DB2Driver"
               url="jdbc:db2://127.0.0.1:446/DBSG"/>

</Context>
This can be adapted to use type-2 connections by changing the URL as per the DB2 documentation.

I hope this helps a little with setting up DB2 JDBC with Tomcat. I hope to update our Tomcat how-tos in the near future to have more clear and complete information.

Kirk

PS> Some sites may wish to continue to define the JDBC JNDI resource in server.xml and then reference it from each webapp context that uses it, since this has the advantange of having a single pool of connections that are shared by several web apps.
dfowler4
Posts: 13
Joined: Wed Apr 12, 2006 6:26 pm

Post by dfowler4 »

Kirk,

Please bear with me as I am new to all of this. We have an application that currently is running on Windows XP, but it uses the JDBC-ODBC driver with a middleware product to make the connection to DB2. We are trying to move that application to run under Tomcat running under JZOS on the mainframe.

I'm still confused about the file jzos.xml ... is it not needed. Also I am including the <GlobalNamingResources> section of my server.xml ... would you review?

You reference the sampe Tomcat JCL "TCJDBC2". Where is that located? In the sampjcl library that is on the host I have members TCJDBC13,
TCJDBC14, and TCJDBC50. I'm using TCJDBC13.

The "resource reference" you mention, does that go in the <TOMCAT_HOME>/conf/Catalina/localhost directory? And what would it be called?

Thanks for your help and understanding,
Dave
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Dave,

"TCJDBC2" is available at dovetail.com on the downloads page.

"jzos.xml" is a copy of the Tomcat context xml that I posted. Tomcat 5.x supports putting a context xml file in conf/Catalina/localhost named "webapp.xml".

Kirk
Post Reply