You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mike Baranski <li...@secmgmt.com> on 2009/11/03 16:28:39 UTC

Class not found when doing JNDI lookup

I have ifxjdbc.jar in WEB-INF/lib, which contains the Informix driver I'm
looking for (I opened it and verified).

I have the following in context.xml:

<Context path="">

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
	
    <!-- Uncomment this to disable session persistence across Tomcat
restarts -->
    <!--
    <Manager pathname="" />
    -->
		<Resource name="jdbc/proteus" auth="Container"
type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="install" password="install"
driverClassName="com.informix.jdbc.IfxDriver"
 
url="jdbc:informix-sqli://sigma:1960/proteus:INFORMIXSERVER=sigma;IFX_LOCK_M
ODE_WAIT=-1;IFX_ISOLATION_LEVEL=1">
		</Resource>		
</Context>

I get an error through the context lookup that I cannot load class
"com.informix.jdbc.IfxDriver".

Here is the lookup:

this.setDataSource((DataSource)new
InitialContext().lookup("java:comp/env/jdbc/proteus"));

Here's the web.xml entry:
<resource-env-ref>
		<description>
			Connection pool for xmlrpc.
		</description>
		<resource-env-ref-name>
			jdbc/proteus
		</resource-env-ref-name>
		<resource-env-ref-type>
			javax.sql.DataSource
		</resource-env-ref-type>
	</resource-env-ref>

Is JNDI somehow masking the classpath of WEB-INF/lib?  I have verified that
there are not multiple jars with this class in the webapp, and it is not in
the common/lib for tomcat.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Class not found when doing JNDI lookup

Posted by Mike Baranski <li...@secmgmt.com>.
Duh!  That makes perfect sense.

>-----Original Message-----
>From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
>Sent: Tuesday, November 03, 2009 10:38 AM
>To: Tomcat Users List
>Subject: RE: Class not found when doing JNDI lookup
>
>> From: Mike Baranski [mailto:list-subscriptions@secmgmt.com]
>> Subject: Class not found when doing JNDI lookup
>>
>> I have ifxjdbc.jar in WEB-INF/lib, which contains the Informix driver
>> I'm looking for (I opened it and verified).
>
>To quote from the doc:
>"Before you proceed, don't forget to copy the JDBC Driver's jar into
>$CATALINA_HOME/lib."
>
>The jar must be in Tomcat's lib directory, not the webapp's WEB-INF/lib,
>if you want Tomcat to manage the connection pool.
>
>> I have the following in context.xml:
>> <Context path="">
>
>The path attribute is not allowed.  Also, you appear to be modifying the
>global conf/context.xml, which is a really, really bad idea.  The
><Resource> element for the webapp should be in the webapp's <Context>
>element, located in the webapp's META-INF/context.xml file.
>
> - Chuck
>
>
>THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
>MATERIAL and is thus for use only by the intended recipient. If you
>received this in error, please contact the sender and delete the e-mail
>and its attachments from all computers.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Class not found when doing JNDI lookup

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Mike Baranski [mailto:list-subscriptions@secmgmt.com]
> Subject: Class not found when doing JNDI lookup
> 
> I have ifxjdbc.jar in WEB-INF/lib, which contains the Informix driver
> I'm looking for (I opened it and verified).

To quote from the doc:
"Before you proceed, don't forget to copy the JDBC Driver's jar into $CATALINA_HOME/lib."

The jar must be in Tomcat's lib directory, not the webapp's WEB-INF/lib, if you want Tomcat to manage the connection pool.

> I have the following in context.xml:
> <Context path="">

The path attribute is not allowed.  Also, you appear to be modifying the global conf/context.xml, which is a really, really bad idea.  The <Resource> element for the webapp should be in the webapp's <Context> element, located in the webapp's META-INF/context.xml file.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Class not found when doing JNDI lookup

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Mike Baranski wrote:
> Is JNDI somehow masking the classpath of WEB-INF/lib?  I have verified that
> there are not multiple jars with this class in the webapp, and it is not in
> the common/lib for tomcat.
>   
The correct way is to place resource-referenced jars in common/lib (or 
just lib for tomcat 6.x).
Simply speaking, WEB-INF/lib is inaccessible when container creates 
resources specified in context.xml.

-- 
Mikolaj Rydzewski <mi...@ceti.pl>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org