Subject Re: [Firebird-Java] TestPoolingConnectionManager error
Author Rick Fincher
Hi Ludek,

Ah, OK. This is a problem with Sun One Studio. I use the same setup of Sun
One Studio that you have and I've never been able to get this working
properly with the built-in Tomcat. There are work-arounds though.

The Tomcat that Sun One Studio uses has a lot of modifications to work
internally with the program You are supposed to be able to store your jars
under ../modules/ext in Sun One Studio and have the built-in Tomcat see
them.

I can't get it to work.

You have two options:

1. Mount the jar files to your development file system by using the Explorer
and right click "Filesystems", select sub menus "mount" then "Archive (JAR,
Zip)", then browse to where the JayBird jar files are located and select
them.

This has the same effect as dropping the jar files into the WEB-INF/lib
folder of your web app.

You can then use the internal Tomcat.

As a last step before deploying your web app, remove the jar files from
WEB-INF/lib, recompile, and build your WAR file. Then just be sure the jars
are in CATALINA_HOME/common/lib of your production version of Tomcat.

One other caveat: I use some of the features of Tomcat that are only in
4.1.x like JDBC realm authentication. Of cource the 4.0.x version of Tomcat
in Sun One can't do that stuff so I have to comment out the parts of
WEB-INF/web.xml that use that stuff. Things in my web app that normally
make calls to getRemoteUser and getRemoteHost I set up as session variables
and put dummy values in them for testing. For deployment I comment out
setting the dummy variables, and uncomment calling getRemoteXXX() to set the
session vars.

All of that is a little bit of a pain in the butt but you only have to do it
when you deploy. The design cycle goes pretty quickly like this.

2. Use an external Tomcat. Sun One Studio can be configured to use a
standard version of Tomcat (or other servlet container) externally.

To me this is a problem because of the time it takes Tomcat to start up. It
slows the development cycle down. The internal Tomcat starts quickly and
loads the web app automatically without putting it in a war file.

The advantage is that you can run the same version of Tomcat that you will
use in production.

You can get around the startup delay problems a little by leaving the Tomcat
server running, using the Tomcat manager (in 4.1.x) to stop the old app,
then install the new files and restart the app.

Rick

----- Original Message -----

> Hi Rick,
>
> I tried following:
>
> First I created firebird.jar file from firebirdsql.jar,
> mini-concurent.jar, mini-j2ee.jar, concurrent.jar, jaas.jar
> and log4j-core.jar files. This file I put to the
> CATALINA_HOME/common/lib directory. When I run the sample
> JSP-page I got this error message:
>
> javax.naming.NamingException: Cannot create resource instance
> at org.apache.naming.NamingContext.lookup(NamingContext.java:837)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
> ...
>
> Second, I did, what you wrote: I put mini-concurrent.jar, mini-j2ee.jar,
> firebirdsql.jar to CATALINA_HOME/common/lib and check the jndi.jar.
> After execution JSP-page I got this error messaqge:
>
> java.lang.NoClassDefFoundError: javax/resource/Referenceable
> at java.lang.ClassLoader.defineClass0(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:509)
> at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
> ...
>
> Under Win2K appeared this error message on the browser and in the log,
> under Red Hat 7.1 only in the log, from browser I got the dialog
> box with this text: "The document contained no data.
> Try again later, or contact the server's administrator."
>
> I am using under Win2K Sun One 4 Studio Update 1 CE, J2SDK 1.4.1
> and under Red Hat 7.1 Sun Forte for Java 4 CE, J2SDK 1.4.0.
>
> I don't know, may be, that the new firebird java jca-jdbc driver
> really needs newer Tomcat version (4.0.1 in my case).
>
> Ludek
>
> >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
>
> On 12/18/02, 9:44:21 PM, "Rick Fincher" <rnf@...> wrote regarding
Re:
> [Firebird-Java] TestPoolingConnectionManager error:
>
>
> > Hi Ludek,
>
> > ----- Original Message -----
>
> > > Hi Rick,
> > >
> > > this error message I receive under Win2K and Red Hat 7.1 and you are
> > > right this
> > > may be a timing problem.
>
> > This has been confirmed to be a problem with the test code not JayBird
> > itself. They just haven't got around to fixing the test code yet.
> > >
>
> > I'm not sure if your old version of the code was before the refactoring
> but
> > you need to be sure to put mini-concurrent.jar and mini-j2ee.jar as well
> as
> > firebirdsql.jar into CATALINA_HOME/common/lib. Depending on the version
> of
> > JDK you are using you may need to put a copy of jndi.jar in there as
well
> > (pre-1.3 JDK).
>
> > Are you getting this error when you start the Tomcat server or when you
> load
> > this page?
>
> > It looks like it is not creating the named resource properly when the
> server
> > starts up.
>
> > Does this error appear on the browser screen or in the log files?
>
> > You may also want to try it with Tomcat 4.1.17 to see if it is a Tomcat
> bug
> > that has been fixed in a later release. This is probably not the case
> since
> > it was working before, but you never know.
>
> > Rick
>
> > > I have another problem with the latest firebird java jca-jdbc driver
from
> > > cvs.
> > > Old version, I'm not sure, I think, from October, works fine with
Tomcat
> > > 4.0
> > > Server. I'm using this driver in JSP like resource:
> > >
> > > <%@page contentType="text/html"%>
> > > <%@page import="java.sql.*"%>
> > > <%@page import="org.firebirdsql.jdbc.*"%>
> > > <%@page import="javax.naming.*"%>
> > > <html>
> > > <head><title>JSP Page</title></head>
> > > <body bgcolor='white'>
> > > <%
> > > Connection con = null;
> > > Statement stmt = null;
> > > ResultSet rst = null;
> > > Context initCtx = (Context) new InitialContext();
> > > Context ctx = (Context) initCtx.lookup("java:comp/env");
> > > FBWrappingDataSource ds = (FBWrappingDataSource)
> > > ctx.lookup("jdbc/Employee");
> > > con = ds.getConnection();
> > > try {
> > > stmt = con.createStatement();
> > > rst = stmt.executeQuery("SELECT * FROM EMPLOYEE");
> > > out.println("<br>");
> > > while (rst.next()) {
> > > out.println(rst.getString(1) + " ");
> > > out.println(rst.getString(2) + " ");
> > > out.println(rst.getString(3) + " ");
> > > out.println(rst.getString(4) + " ");
> > > out.println(rst.getString(5) + " ");
> > > out.println(rst.getString(6) + " ");
> > > out.println(rst.getString(7) + " ");
> > > out.println(rst.getString(8) + " ");
> > > out.println(rst.getString(9) + " ");
> > > out.println(rst.getString(10) + "<br>");
> > > }
> > > }
> > > finally {
> > > if (rst != null) rst.close();
> > > if (stmt != null) stmt.close();
> > > if (con != null) con.close();
> > > }
> > > %>
> > > </body>
> > > </html>
> > >
> > > But with the new driver I have following problems:
> > >
> > > javax.naming.NamingException: Cannot create resource instance
> > > at
org.apache.naming.NamingContext.lookup(NamingContext.java:837)
> > > at
org.apache.naming.NamingContext.lookup(NamingContext.java:181)
> > > at
org.apache.naming.NamingContext.lookup(NamingContext.java:822)
> > > at
org.apache.naming.NamingContext.lookup(NamingContext.java:194)
> > > at
org.apache.jsp.firebird$jsp._jspService(firebird$jsp.java:83)
> > > at
> > > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
> > > at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > > ...
> > >
> > > Could you give me some hint what I have to change to use the latest
> > > driver.
> > >
> > > Thanks,
> > >
> > > Ludek
> > >
> > >
> > > >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
> > >
> > > On 12/17/02, 8:51:09 PM, "Rick Fincher" <rnf@...> wrote
regarding
> > Re:
> > > [Firebird-Java] TestPoolingConnectionManager error:
> > >
> > >
> > > > Hi Ludek,
> > >
> > > > That is a bogus error message that is caused by a timing problem in
the
> > > test
> > > > code when running on some systems. The developers are aware of it.
> > >
> > > > You probably see something like this in the build window:
> > >
> > > > [junit] Running org.firebirdsql.jca.TestPoolingConnectionManager
> > > > [junit] Tests run: 4, Failures: 1, Errors: 0, Time elapsed: 90.711
sec
> > > > [junit] TEST org.firebirdsql.jca.TestPoolingConnectionManager
FAILED
> > >
> > > > That's what I get under windows 2000.
> > >
> > > > Your compiled code is OK to use.
> > >
> > > > Rick
> > >
> > > > ----- Original Message -----
> > >
> > > > > Hi,
> > > > >
> > > > > I downloaded the latest version of the firebird jca jdbc driver
and
> > after
> > > > > compilation at the TestPoolingConnectionManager I got the error:
> > > > >
> > > > > testShortBlocking Failure Blocking Timeout occurred in
> > > > > ShortBlocking test.
> > > > >
> > > > > junit.framework.AssertionFailedError: Blocking Timeout
> > occurred
> > > > > in ShortBlocking test
> > > > > at
> > > > >
> > org.firebirdsql.jca.TestPoolingConnectionManager.testShortBlocking(TestP
> > > > > oolingConnectionManager.java:143)
> > > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
> > > > > at
> > > > >
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> > > > > a:39)
> > > > > at
> > > > >
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> > > > > Impl.java:25)
> > > > >
> > > > > Java Version 1.4.0
> > > > > Java Vendor Sun Microsystems Inc.
> > > > > Java VM Name Java HotSpot(TM) Client VM
> > > > > Java VM Version 1.4.0-b92
> > > > > Java VM Info mixed mode
> > > > > OS Name Red Hat Linux 7.1
> > > > > OS Version 2.4.18-17.7.x
> > > > > OS Arch i386
> > > > >
> > > > > What I have to do to fix it?
> > > > >
> > > > > Best regards
> > > > >
> > > > > Ludek Falta