This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 20909 - Adding resources to $CATALINA_HOME/lib still not able to connect to Oracle database
Summary: Adding resources to $CATALINA_HOME/lib still not able to connect to Oracle da...
Status: CLOSED WORKSFORME
Alias: None
Product: serverplugins
Classification: Unclassified
Component: Tomcat (show other bugs)
Version: -FFJ-
Hardware: PC Windows ME/2000
: P3 blocker (vote)
Assignee: _ rkubacki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-02-26 23:40 UTC by joannelau
Modified: 2002-06-07 22:41 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description joannelau 2002-02-26 23:40:58 UTC
020225_2 EE win2000, jdk1.4

I've renamed the Oracle driver classes12.zip to classes12.jar and placed it
in $CATALINA_HOME/lib  and $CATALINA_HOME/classes. However I'm still 
having problem when executing my web app with the error of not able to
connect to the Oracle Database. It seems to me the only way to do that
is set in the Tomcat classpath.
If this is a Tomcat limitation, this should be documented.
Comment 1 Damian Frach 2002-02-27 08:48:02 UTC
Is it problem, the tomcat did not find the driver or the tomcat could 
not create a DB connection?

Can you add some exceptions or more detailed description?
Comment 2 _ rkubacki 2002-02-27 14:34:10 UTC
There are different cases how you can access your database. Either you
can get connection to database directly in your web application using
sequence like

Class.forName("acme.MyDriver");
Connection conn = DriverManager.getConnection(connectstring,...);

In this case you need to make your driver accessible within scope of
your application. According to
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html
the convenient and prefered way how to achieve this is to put .jar
file containg driver classes into WEB-INF/lib (you may need to rename
the file if it has an extension like .zip) or expanded classes into
WEB-INF/classes directory of your web module if you want to make them
accessible only for you web application. Or you can use
$CATALINA_HOME/lib or $CATALINA_HOME/classes to share them for all web
modules that runs on this tomcat instance.

Another way is to use JNDI for accessing resources. Then you need to
configure the resource in WEB-INF/web.xml and also in
$CATALINA_HOME/conf/server.xml. JNDI Resources HOW-TO for Tomcat
clearly states that your JDBC Driver has to be accessible to both
Tomcat internal classes and to your web application. See the URL:
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/jndi-resources-howto.html#JDBC%20Data%20Sources
 section 1. Install your JDBC Driver
Comment 3 joannelau 2002-02-27 17:17:01 UTC
I'm using JNDI resources to connect to database for my webapp.
Renaming classes12.zip as .jar and place it in $CATALINA_HOME/lib
and executing the web app results to cannot connect to database
error.

2002-02-27 09:10:34 WebappLoader[/bookstore1]: Deploying class 
repositories to work directory 
C:\forte4j_ee_26\tomcat401\work\localhost\bookstore1
2002-02-27 09:10:34 WebappLoader[/bookstore1]: Deploy JAR 
/WEB-INF/lib/classes12.jar to 
C:\CFQA\bookstore1WebModule\WEB-INF\lib\classes12.jar
2002-02-27 09:10:34 StandardManager[/bookstore1]: Seeding random 
number generator class java.security.SecureRandom
2002-02-27 09:10:34 StandardManager[/bookstore1]: Seeding of random 
number generator has been completed
2002-02-27 09:10:35 ContextConfig[/bookstore1]: Added certificates -> 
request attribute Valve
2002-02-27 09:10:35 Couldn't create bookstore database bean: Couldn't 
open connection to database: null
2002-02-27 09:10:35 StandardWrapper[/bookstore1:default]: Loading 
container servlet default
2002-02-27 09:10:35 default: init
2002-02-27 09:10:35 jsp: init

So the zip file must be set in the TC classpath in order to work 
as also stated in Misha's mail. 
This should be documented somewhere. Therefore, I reopen the issue.
Comment 4 _ rkubacki 2002-02-28 07:46:18 UTC
Apparently you haven't read previous comment carefully and didn't
follow to links. To make it easier I wil cite from JNDI Resources HOWTO

<cite>
Use of the JDBC Data Sources JNDI Resource Factory requires that you
make an appropriate JDBC driver available to both Tomcat internal
classes and to your web application. This is most easily accomplished
by installing the driver's JAR file(s) into the
$CATALINA_HOME/common/lib directory, which makes the driver available
both to the resource factory and to your application.
</cite>

It means that you are asking for documentation that already exists.
Thus I close it.
Comment 5 joannelau 2002-02-28 16:53:50 UTC
You perhaps are missing my point. When I said that I'm using
JNDI resources, obviously I've not only just put the driver in
$CATALINA_HOME/lib or $CATALINA_HOME/common/lib but I've also
set resource reference in WEB-INF/web.xml and I've also 
configured the JNDI resource in $CATALINA_HOME/conf/server.xml

The Tomcat documents did not point out specifically for such a
case as with the Oracle driver which has .zip file where one could
only possibly set it through the TC classpath in this case.
Following the Tomcat instructions just did not work as we are
going thru all the discussion.

What I request is to at least document it somewhere in our 
FFJ documentations though there is nothing done on the Engineering 
side. It is a documentation issue.
I hope I've made more clarifications on that.
I will talk to Jeff Hoffman. 



Comment 6 Milan Kuchtiak 2002-02-28 17:11:50 UTC
Radim I think you are more familiar with this bug.
Comment 7 jhoffman 2002-03-07 23:34:28 UTC
I am providing input for our online help to describe this type of 
situation and suggest the TC classpath approach for now.
Comment 8 _ rkubacki 2002-03-13 13:52:43 UTC
I tried to reproduce with the same module as reported and it works for
me.