First let me say that this issue could have been completely avoided by using Sun's Application Server. For reasons beyond my control, I had to deploy an application written with Java Studio Creator 2 to Tomcat on Windows. I hope this information saves someone else some time..
Here are the product instructions: Sun Java Studio Creator 2 Update 1 – Online Help
Deployment Example: Tomcat
This application uses a database which requires a datasource to be defined for the application server, and a fererence to the datasource in the applications web.xml file (Creator puts this there automatically).
I have been successfully deploying this application onto linux and Solaris on both Sun Application Server and Tomcat without any major problems. In fact after simply creating a Tomcat JNDI datasource, it worked perfectly. On Tomcat Linux (Ubuntu 6.06 and Tomcat 5.5.17), all I had to do to create a datasource was add the following to the <tomcatroot>/conf/context.xml:
<Resource name="jdbc/hrlite" auth="Container"
type="javax.sql.DataSource" username="hradmin" password="hradmin"
The trouble came when trying to deploy to a Windows Tomcat 5.5 server. The above technique for creating a datasource did not work for me.
Also, JSF will not run on the Windows flavor of Tomcat without adding a listener to the web.xml file in your application, so the application would not even start. This is manifested by a Null Pointer Exception on FacesServlet.init when accessing the application . This was resolved after adding the following to the application web.xml file:
Once the faces listener was added to my application's web.xml file, the creator came up, but when I went to a page in the application which used a datasource, I recieved an error from the RowSetReader. The datasource was clearly not being found.
So I attempted to add the database connection pool datasource as described in the Tomcat docs.
The Apache Jakarta Tomcat 5 Servlet/JSP Container
I tried many variations and could not get past this issue. I did find many other people with similar problems and a lot of misinformation. But untimately, I resolved my issue by removing Tomcat 5.5.20 and installing Tomcat 5.0.28 since the docs for Tomcat 5.5 datasource appear to be outdated, and I may have been experiencing a bug. In any event, here is the final solution which is now working for me for creating a datasource in Tomcat 5.0 on Windows.
Add the datasource to the <tomcathome>\\conf\\server.xml
I added the following near the end of the file, right before the closing Host tag (</Host>)
<Context path="/hrlite" docBase="hrlite"
debug="5" reloadable="true" crossContext="true">
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
<!-- Maximum number of idle dB connections to retain in pool.
Set to -1 for no limit. See also the DBCP documentation on this
and the minEvictableIdleTimeMillis configuration parameter.
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
<!-- MySQL dB username and password for dB connections -->
<!-- Class name for the old mm.mysql JDBC driver - uncomment this entry and comment next
if you want to use this driver - we recommend using Connector/J though
<!-- Class name for the official MySQL Connector/J driver
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
Here are a few links which I found along the journey.
Tags: Java Studio Creator
, Tomcat Datasource