Hi Greg, hi David!

Sure, there is anoter factory you could use: The tomcat-built-in datasource factory. Unfortunately I do not know the classname of this factory, but I think it is somewhere in the library naming-factory-dbcp.jar which is located in common/lib.
(The Tomcat-guys didn't want to add the complete jakarta-commons-pool and jakarta-commons-dbcp libraries because most of the classes inside these libraries are not needed by tomcat. So they extracted the required classes only and repacked them thogether with some other classes into naming-factory-dbcp.jar. To avoid confusions and errors, they also modified the package names - thats why you get a ClassNotFoundException when you configure the JNDI-context to use the "org.apache.commons.dbcp.BasicDataSourceFactory").
But I'm not sure if it is a good idea to extend one of those tomcat-internal datasource factories! This would REALLY tie your code close to tomcat!
Apart from that: If you implement/extend an existing DataSource factory, you have to put your implementation inside the common/classes directory - otherwise tomcat won't find it when it initializes the JNDI-context! So why not put the commons-pool and commons-dbcp jars into common/lib too?
So my suggestion: Extend BasicDataSourceFactory from commons-dbcp and put the two jars mentioned above into common/lib.


Best regards,
 Tex


Greg Guerin schrieb:

Hi David, Mario,

We actually specify the factory parameter because we extend the
BasicDataSourceFactory so we can encrypt passwords in the resource
definition.  My question is: Is there already a way to do that using another
factory I'm unaware of? It works fine, but we have to include the jars that
Mario mentioned and it'd be nice to not have to tie our code that close to
the container.

Greg

-----Original Message-----
From: Mario Winterer [mailto:[EMAIL PROTECTED] Sent: Thursday, February 03, 2005 4:37 PM
To: Tomcat Users List
Subject: Re: Tomcat 5.5.4/Windows 2000 server - Failed to register in JMX:
BasicDataSourceFactory


Hi David!

I think, you do not need to explicitely define a bean factory because Tomcat
5 automatically uses dbcp for JNDI-DataSources (I think tomcat looks at the
type of resource - in your case a javax.sql.DataSource - and uses the
tomcat-internal dbcp-factory). In my project, I've configured a
JNDI-DataSource using the Oracle thin driver and it works perfectly without
specifying a bean factory and without adding any special libraries to my
tomcat installation (apart from the oracle database driver which is in
commons/lib).

So try the following configuration:

<Resource name="jdbc/as400" auth="Container"
type="javax.sql.DataSource"
maxActive="20" maxIdle="10" maxWait="-1"
removeAbandoned="true" removeAbandonedTimeout="60"
logAbandoned="true"
driverClassName="com.ibm.as400.access.AS400JDBCDriver"


url="jdbc:as400://a53pb3;naming=system;libraries=,pgmdbt,caelib;errors=full"
username="userid" password="password"
/>


Again: You do not need any additional commons-libraries!

Best regards,
 Tex



Hi Mario,

Thanks for getting back to me.  Below is the context I set up.

After doing my own digging, I realized I was missing some jakarta commons jar files. After getting these jars and restarting Tomcat the ClassNotFoundExceptions went away.

What I find really puzzling though is why I didn't get the same ClassNotFoundException on my local machine that was running the same version of Tomcat but on Windows XP profession.


<Context debug="0" privileged="true">

<!-- the jdbc driver's jar needs to go into $CATALINA_HOME/common/lib
-->
<Resource name="jdbc/as400" auth="Container"
type="javax.sql.DataSource" factory="org.apache.commons.dbcp.BasicDataSourceFactory"
maxActive="20" maxIdle="10"
maxWait="-1"
removeAbandoned="true" removeAbandonedTimeout="60"
logAbandoned="true"
driverClassName="com.ibm.as400.access.AS400JDBCDriver"


url="jdbc:as400://a53pb3;naming=system;libraries=,pgmdbt,caelib;errors=full


"


username="userid" password="password"/>

</Context>









Mario Winterer <[EMAIL PROTECTED]>
02/02/2005 07:19 PM
Please respond to
"Tomcat Users List" <tomcat-user@jakarta.apache.org>


To Tomcat Users List <tomcat-user@jakarta.apache.org> cc

Subject
Re: Tomcat 5.5.4/Windows 2000 server - Failed to register in JMX: BasicDataSourceFactory







Hi!

How did you define your JDBC DataSource?
As far as I know, the original jakarta-commons-dbcp and jakarta-commons-pool-libraries are not included with Tomcat. Instead, just a subset of the required classes with modified package names (starting with 'org.apache.tomcat.dbcp') are packed in 'naming-factory-dbcp.jar' that can be found in commons/lib.
But if you configure your JDBC DataSource correctly, this should not bother. Please post your resource-configuration!


Best regards,
Tex





I'm running Tomcat 5.5.4 on Windows 2000 Server and encountered the below








error on Tomcat startup:

Feb 2, 2005 10:50:49 AM org.apache.catalina.core.NamingContextListener
addResource
WARNING: Failed to register in JMX: javax.naming.NamingException: Could not create resource factory, ClassNotFoundException:org.apache.commons.dbcp.BasicDataSourceFactory



My webapp uses JDBC DataSource's and the BasicDataSourceFactory for pooling so this problem of "ClassNotFoundException" is causing my webapp to not work properly.


I have Tomcat 5.5.4 also installed on my local maching which has Windows XP on it, and there is absolutely no problem on startup and and my




webapp.




Does anyone no what's happening here? Why does Tomcat register the BasicDataSourceFactory with no problems in Tomcat 5.5.4 on Windows XP and








not on Windows 2000 Server?








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]










--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to