# An important note about tomcat on gentoo

## Raptor85

Short backstory:   I needed tomcat for a web application I'm working on, not a big deal, it's in portage, seemed to install and work just fine, easy.

I'm using Tomcat 6, which is significantly newer than these docs here, but I skimmed them anyways to see if there was anything important, nothing stood out. http://www.gentoo.org/proj/en/java/tomcat-guide.xml

Got it working ok, got it deploying using the management console just fine, then the "bug" hit.

I started implementing the database connection, 3 days of debugging and "could not find a valid driver" messages later, which led me all the way to the point of debugging jstl itself as it seemed to be throwing the error (and you'd think something this important would be in the tomcat log file....but you'd be wrong) i finally found it to be using the file...... naming-factory-dbcp.jar, which the gentoo guide just kinda "mentions" that you don't really need in a short blurb.  

All JNDI functionality seems built off the functions in this file, and throws errors that are at best red herrings if you don't have it, so none of the "proper" ways of doing authentication or database connectivity in tomcat 6 work without it.  (the only way to open a connection to a database without it is to define it in the code instead of in the connection resources)  The fix at the moment seems to be to take this file from a binary install of tomcat and copy it into your libs folder, did that and it clears up everything instantly.

Just thought this needed to be posted up for anyone else who runs into this, it's not a bug in your code but a nasty little bug in gentoo's build of tomcat itself.

----------

## Herring42

Could you please raise a bug report?

 :Smile: 

----------

## john.newman

yes the tomcat install is missing several jar files, beyond the one you mentionned.  i wanted to report this a few weeks ago but forgot.  i had to manually download and copy the dbcp jar myself

steps to reproduce:

emerge -v tomcat

download the same exact version from the tomcat website and extract

compare the contents of the lib folders .. /usr/share/tomcat/lib (something like that) 

you'll see the vanilla install includes 6 or 7 jar files that the gentoo package does not.. it could be files besides the .jars too, i didn't check

fix

the package should include the same files as the vanilla version.  I was a bit perplexed about how that could even happen..    :Question: 

----------

## John R. Graham

The Gentoo Tomcat Guide touches on this: *Quote:*   

> Missing Jar - naming-factory-dbcp.jar
> 
> Currently the naming-factory-dbcp.jar is not build by default. To build that jar Tomcat robs .java source files from 3 other commons packages, collections, pool, and dbcp. There is no clean solution to compiling this jar at this time. Suggestions, patches, or any assistance on compiling that jar is greatly appreciated.
> 
> There are alternatives to this jar. You can use commons-dbcp.jar, or use the factory provided by most all jdbc drivers.
> ...

 Apparently others are missing as well. However, although it's documented, I don't think it's reasonable: components are are present in the upstream release are missing in the Portage-installed version. I believe that the ebuild should take on the dirty work and then report in the elog where it's still dirty.

- John

----------

## matthias_mo

 *Raptor85 wrote:*   

> 
> 
> All JNDI functionality seems built off the functions in this file, and throws errors that are at best red herrings if you don't have it, so none of the "proper" ways of doing authentication or database connectivity in tomcat 6 work without it.  (the only way to open a connection to a database without it is to define it in the code instead of in the connection resources)  The fix at the moment seems to be to take this file from a binary install of tomcat and copy it into your libs folder, did that and it clears up everything instantly.
> 
> Just thought this needed to be posted up for anyone else who runs into this, it's not a bug in your code but a nasty little bug in gentoo's build of tomcat itself.

 

This problem also hit me now. So I went looking for the naming-factory-dbcp.jar but also the vanilla binary tar.gz for 6.0.33 and 6.0.35 doesn't include this jar. What I found was this jar file from a tomcat-5.5 distribution but I suspect it's not compatible.

So can you tell me where did you find a tomcat 6.0.x version of naming-factory-dbcp.jar?

regards

matthias

----------

