You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Mark Barnes <ma...@coat.com> on 2006/09/12 19:05:40 UTC

Source for Packages org.apache.tomcat.dbcp and below?

I have downloaded the 5.5.17 source, and am looking for the source for class 
org.apache.tomcat.dbcp.dbcp.BasicDataSource but cannot find it.  In fact, I 
cannot find org.apache.tomcat.dbcp.

Can someone please point me to where it is?

I've also looked under Jakarta Commons but can't seem to find it there either. 
I seem to be able to find only org.apache.commons.dbcp.BasicDataSource.  But 
that's not the kind of DataSource return via JNDI from Tomcat.


Thanks,
---Mark

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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Marcus Better <ma...@better.se>.
Remy Maucherat wrote:
> Normally, it's difficult to do. You can easily patch Tomcat to have it
> use the regular commons-dbcp by default (it's a constant), but it will
> have the usual drawbacks (you will expose a bunch of JARs to webapps).

Excuse my ignorance, but why is this a problem?

Marcus



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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Remy Maucherat <re...@apache.org>.
Fernando Nasser wrote:
> And we have the same problem on JPackage, and as consequence on Red Hat, 
> Fedora, Suse, Mandriva....
> 
> I wonder if the magic could not be done by having the original 
> commons-dhcp JAR as input and doing some manipulation on it to move the 
> classes to the desired package at tomcat build time...

Normally, it's difficult to do. You can easily patch Tomcat to have it 
use the regular commons-dbcp by default (it's a constant), but it will 
have the usual drawbacks (you will expose a bunch of JARs to webapps).

Rémy

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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Fernando Nasser <fn...@redhat.com>.
Marcus Better wrote:
> William L. Thomson Jr. wrote:
>   
>> Basically the main problem on Gentoo is we don't want to have to pull in
>> sources for 3 other commons apps in conjunction with Tomcat's sources
>> just to build the naming-factory-dbcp.jar. Despite it looking like
>> that's the only way.
>>     
>
> We have the same problem in Debian, and we are not building
> naming-factory-dbcp.jar. Instead we rely on commons-collections.jar.
>
> Regards,
>
> Marcus
>
>
>
>   
And we have the same problem on JPackage, and as consequence on Red Hat, 
Fedora, Suse, Mandriva....

I wonder if the magic could not be done by having the original 
commons-dhcp JAR as input and doing some manipulation on it to move the 
classes to the desired package at tomcat build time...

Regards to all,
Fernando


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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Marcus Better <ma...@better.se>.
William L. Thomson Jr. wrote:
> Basically the main problem on Gentoo is we don't want to have to pull in
> sources for 3 other commons apps in conjunction with Tomcat's sources
> just to build the naming-factory-dbcp.jar. Despite it looking like
> that's the only way.

We have the same problem in Debian, and we are not building
naming-factory-dbcp.jar. Instead we rely on commons-collections.jar.

Regards,

Marcus



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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by "William L. Thomson Jr." <wl...@gentoo.org>.
On Wed, 2006-09-13 at 15:07 +0200, Remy Maucherat wrote:
>
> The resultant package is significantly smaller, and there's no chance of 
> version conflict if the user wants to put a different version of DBCP in 
> the shared folder.

Ok that makes sense. Thanks for the info. Any chance of Tomcat making
it's own implementation? Even less chance of a version conflict then ;)
Although it does not seem like Tomcat uses that jar. So if there was a
version conflict, the user could remedy by removing one or the other of
the conflicting dbcp jars.

Basically the main problem on Gentoo is we don't want to have to pull in
sources for 3 other commons apps in conjunction with Tomcat's sources
just to build the naming-factory-dbcp.jar. Despite it looking like
that's the only way.

Otherwise we have to do some craziness just to build that one jar. Which
for the end user I am not sure as to the benefit? Other than size or
version conflict avoidance.

In the mean time we are building Tomcat less that one jar. For those
that must use Tomcat's naming factory, we have them fetch the jar from a
binary copy of Tomcat. Otherwise they can use commons naming factory. Or
since it most always pertains to JDBC usage, the naming factory in their
JDBC driver.

Are there any performance benefits or etc? What about bugs or etc if a
bug is detected in commons-dbcp how does that get addressed in Tomcat?
Any major hangups or reasons for Tomcat to not have it's own
implementation? Aside from reuse of existing code and etc.

Thanks

-- 
William L. Thomson Jr.
Gentoo/Java

Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by "William L. Thomson Jr." <wl...@gentoo.org>.
On Wed, 2006-09-13 at 15:07 +0200, Remy Maucherat wrote:
>
> The resultant package is significantly smaller,

Ok, not trying to nit pick this. But if we are talking about
commons-dbcp.jar and naming-factory-dbcp.jar. The latter sure does not
seem smaller?

-rw-r--r-- 1 root root 106216 Jul 23
14:24 /usr/share/commons-dbcp/lib/commons-dbcp.jar

-rw-r--r-- 1 wlt users 154109 Apr 14 14:09
Desktop/apache-tomcat-5.5.17/common/lib/naming-factory-dbcp.jar

So it's not smaller by any means. Which would make sense since it's not
just commons-dbcp being re-packaged. Aspects of commons-collections and
commons-pool are included in naming-factory-dbcp.jar.

If naming-factory-dbcp.jar could be built or etc with those as binary
dependencies it would be fine. That would be more like the rest of
Tomcat's build system. It's just that one jar, that has a unique way of
being built.

-- 
William L. Thomson Jr.
Gentoo/Java

Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Remy Maucherat <re...@apache.org>.
William L. Thomson Jr. wrote:
> Greetings,
> 
> On Tue, 2006-09-12 at 15:38 -0400, Yoav Shapira wrote:
>> No, it just means the package names are changed, from
>> org.apache.commons.dbcp to org.apache.tomcat.dbcp.
>>
>> They don't extend, they don't wrap, it's the same class just renamed
>> to a different package. 
> 
> Is there a reason for this? One of the few problems we have on Gentoo
> with compiling Tomcat from source is the naming-factor-dbcp.jar. I
> believe it to be related to this discussion. I believe the above
> pertains to that jar and it's contents?
> 
> If so is there a reason for the renaming and re-packaging? If it's not
> being modified for Tomcat's needs. Could Tomcat just use commons-dbcp?
> 
> At this moment it's really difficult for us to build
> naming-factory-dbcp.jar since it pulls sources from 3 commons packages.
> If there is any way to change that, it would be great.

The resultant package is significantly smaller, and there's no chance of 
version conflict if the user wants to put a different version of DBCP in 
the shared folder.

Rémy

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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by "William L. Thomson Jr." <wl...@gentoo.org>.
Greetings,

On Tue, 2006-09-12 at 15:38 -0400, Yoav Shapira wrote:
>
> No, it just means the package names are changed, from
> org.apache.commons.dbcp to org.apache.tomcat.dbcp.
> 
> They don't extend, they don't wrap, it's the same class just renamed
> to a different package. 

Is there a reason for this? One of the few problems we have on Gentoo
with compiling Tomcat from source is the naming-factor-dbcp.jar. I
believe it to be related to this discussion. I believe the above
pertains to that jar and it's contents?

If so is there a reason for the renaming and re-packaging? If it's not
being modified for Tomcat's needs. Could Tomcat just use commons-dbcp?

At this moment it's really difficult for us to build
naming-factory-dbcp.jar since it pulls sources from 3 commons packages.
If there is any way to change that, it would be great.

Thanks

-- 
William L. Thomson Jr.
Gentoo/Java

Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Yoav Shapira <yo...@apache.org>.
Hi,


On 9/12/06, Mark Barnes <ma...@coat.com> wrote:
> Okay, I see that this re-packaging is done on the fly during tomcat build.
>
> So how do I find the correct source of commons.dbcp from when tomcat 5.5.17 was
> built?

You look at the build/build.properties.default file in Tomcat's SVN
repository for the TOMCAT_5_5_17 tag:
http://svn.apache.org/viewvc/tomcat/build/tags/tc5.5.x/TOMCAT_5_5_17/

You'll see it's DBCP 1.2.1.

It's also pretty easy to build custom versions of Tomcat with whatever
DBCP version (including a custom one) you want.

Yoav

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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Mark Barnes <ma...@coat.com>.
Yoav Shapira wrote:
> Hi,
> One more thing:
> 
> 
> On 9/12/06, Mark Barnes <ma...@coat.com> wrote:
>> I look at the current (1.2.1) DBCP source, and it looks like it cannot 
>> possibly
>> be what tomcat 5.5.17 is using.  If my code were to call the 1.2.1 
>> version of
>> method...
>>
>>      BasicDataSource.getConnection(String username, String password)
>>
>> ...I would expect to get an UnsupportedOperationException from class
>> PoolingDataSource.  It's not the outcome I would have hoped for, but 
>> at least it
>> makes it seem someone has at least noted the problem I am having and 
>> has written
>> a "fix" for it, of sorts, making the method unsupported.
> 
> No, you're misreading something here.  The JavaDocs on the web site
> are for the 1.2.2 (or 1.3, whatever the DBCP committers decided to
> call it) release.  They reflect changes made in SVN to throw these
> exceptions, probably in response to JIRA issue DBCP-36 which sounds
> similar to yours.  In DBCP 1.2.1, these methods do not throw
> UnsupportedOperationExceptions, nor are they documented to throw these
> exceptions.


Hi, Yoav -


I guess I really *am* confused now.

Below is the code from PoolingDataSource.java from the 1.2.1 source tree I 
downloaded.  I read the code for BasicDataSource method createDataSource(), and 
I can see that BasicDataSource delegates to a PoolingDataSource, whose method 
does indeed throw UnsupportedOperationException, as seen in the JavaDocs and in 
the code below:

     /**
      * Throws {@link UnsupportedOperationException}
      * @throws UnsupportedOperationException
      */
     public Connection getConnection(String uname, String passwd) throws 
SQLException {
         throw new UnsupportedOperationException();
     }


Here's the code for geConnection(String,String) from BasicDataSource.java:

     public Connection getConnection(String username, String password) throws 
SQLException {
         return createDataSource().getConnection(username, password);
     }



Here's the code for createDataSource() from BasicDataSource.java, where the 
delegate is created:

         // Create and return the pooling data source to manage the connections
         dataSource = new PoolingDataSource(connectionPool);


Maybe I'm missing somewhere in the DBCP source where the 
UnsupportedOperationException is caught and silently ignored???  I can't see it.

Or is it possible that the source I downloaded isn't really for release 1.2.1 
even though the download page says it is, and even though the name of the 
directory created when un-zipping has "1.2.1" in it.


---Mark

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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Yoav Shapira <yo...@apache.org>.
Hi,
One more thing:


On 9/12/06, Mark Barnes <ma...@coat.com> wrote:
> I look at the current (1.2.1) DBCP source, and it looks like it cannot possibly
> be what tomcat 5.5.17 is using.  If my code were to call the 1.2.1 version of
> method...
>
>      BasicDataSource.getConnection(String username, String password)
>
> ...I would expect to get an UnsupportedOperationException from class
> PoolingDataSource.  It's not the outcome I would have hoped for, but at least it
> makes it seem someone has at least noted the problem I am having and has written
> a "fix" for it, of sorts, making the method unsupported.

No, you're misreading something here.  The JavaDocs on the web site
are for the 1.2.2 (or 1.3, whatever the DBCP committers decided to
call it) release.  They reflect changes made in SVN to throw these
exceptions, probably in response to JIRA issue DBCP-36 which sounds
similar to yours.  In DBCP 1.2.1, these methods do not throw
UnsupportedOperationExceptions, nor are they documented to throw these
exceptions.

Yoav

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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Mark Barnes <ma...@coat.com>.
Remy Maucherat wrote:
> Mark Barnes wrote:
>> But back to my original question:
>>
>> Where is the actual source to this "re-packaged" class???  I cannot 
>> find it in the downloaded source tree.
>>
>> Which version of commons.dbcp was re-packaged?
>>
>> If I look at the commons.dbcp source can I be absolutely sure it's the 
>> same version of the class in the jar file?
> 
> The source in that case is the build script (and looking at which 
> versions are used doesn't hurt, of course).



Okay, I see that this re-packaging is done on the fly during tomcat build.

So how do I find the correct source of commons.dbcp from when tomcat 5.5.17 was 
built?

I look at the current (1.2.1) DBCP source, and it looks like it cannot possibly 
be what tomcat 5.5.17 is using.  If my code were to call the 1.2.1 version of 
method...

     BasicDataSource.getConnection(String username, String password)

...I would expect to get an UnsupportedOperationException from class 
PoolingDataSource.  It's not the outcome I would have hoped for, but at least it 
makes it seem someone has at least noted the problem I am having and has written 
a "fix" for it, of sorts, making the method unsupported.  What I am seeing 
instead is an error from the database complaining about an invalid 
username/password.  The username and password being passed into getConnection() 
obviously are not being used.

Apparently, Application-managed DataSource authorization (auth=Application) is 
not implemented in Tomcat.  But I guess I can try the fallback of setting the 
username and password properties instead for the BasicDataSource, but to do it I 
must cast to BasicDataSource.  So much for write-once-run-anywhere.


Thanks again for your comments.

---Mark

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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Remy Maucherat <re...@apache.org>.
Mark Barnes wrote:
> Actually, the problem with the cast was I had a typo in the path for the 
> jar file when I added it to the CLASSPATH.  I can get it to compile now.
> 
> 
> 
> But back to my original question:
> 
> Where is the actual source to this "re-packaged" class???  I cannot find 
> it in the downloaded source tree.
> 
> Which version of commons.dbcp was re-packaged?
> 
> If I look at the commons.dbcp source can I be absolutely sure it's the 
> same version of the class in the jar file?

The source in that case is the build script (and looking at which 
versions are used doesn't hurt, of course).

Rémy


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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Mark Barnes <ma...@coat.com>.
Thanks.  I really appreciate your input.



Yoav Shapira wrote:
> Hi,
> 
>> "re-packaged"?   Does that mean "wrapped"?
> 
> No, it just means the package names are changed, from
> org.apache.commons.dbcp to org.apache.tomcat.dbcp.
   .
   .
   .
>> I was also trying to cast the DataSource returned by JNDI so I can 
>> query its
>> properties.  Casting to org.apache.tomcat.dbcp.dbcp.BasicDataSource 
>> doesn't seem
>> to work, resulting in a "package does not exist" even after including 
>> the jar
>> file in the CLASSPATH.
> 
> Really, that casting doesn't seem to work?  I would expect it to...
> Maybe you have an extra
> .dbcp. in the package name above?


Actually, the problem with the cast was I had a typo in the path for the jar 
file when I added it to the CLASSPATH.  I can get it to compile now.



But back to my original question:

Where is the actual source to this "re-packaged" class???  I cannot find it in 
the downloaded source tree.

Which version of commons.dbcp was re-packaged?

If I look at the commons.dbcp source can I be absolutely sure it's the same 
version of the class in the jar file?



Thanks again.

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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Yoav Shapira <yo...@apache.org>.
Hi,

> "re-packaged"?   Does that mean "wrapped"?

No, it just means the package names are changed, from
org.apache.commons.dbcp to org.apache.tomcat.dbcp.

> How are these related?  By extension?  By wrapping?  Do I cast one of these to:
>     org.apache.tomcat.dbcp.dbcp.BasicDataSource
> or can I cast it to:
>     org.apache.commons.dbcp.BasicDataSource

They don't extend, they don't wrap, it's the same class just renamed
to a different package.  You can cast it to the Tomcat package name
(top one of the two above).  If you also have DBCP in its own original
jar in the same classloader repository, you should also be able to
cast the datasource to the DBCP name.

> I can find org.apache.tomcat.dbcp.dbcp.BasicDataSource in the jar files.  I
> cannot find org.apache.commons.dbcp.BasicDataSource in the jar files.

As expected: like I said we're not extending or wrapping this DBCP
class, only renaming it.

> I was also trying to cast the DataSource returned by JNDI so I can query its
> properties.  Casting to org.apache.tomcat.dbcp.dbcp.BasicDataSource doesn't seem
> to work, resulting in a "package does not exist" even after including the jar
> file in the CLASSPATH.

Really, that casting doesn't seem to work?  I would expect it to...
Maybe you have an extra
.dbcp. in the package name above?

Yoav

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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Mark Barnes <ma...@coat.com>.
Yoav -

Thanks for responding.


"re-packaged"?   Does that mean "wrapped"?


It has a different package structure than that in Jakarta Commons DBCP.
    org.apache.tomcat.dbcp.dbcp.BasicDataSource
vs
    org.apache.commons.dbcp.BasicDataSource


How are these related?  By extension?  By wrapping?  Do I cast one of these to:
    org.apache.tomcat.dbcp.dbcp.BasicDataSource
or can I cast it to:
    org.apache.commons.dbcp.BasicDataSource


I can find org.apache.tomcat.dbcp.dbcp.BasicDataSource in the jar files.  I 
cannot find org.apache.commons.dbcp.BasicDataSource in the jar files.


I'm trying to figure out why I cannot get Application-managed DataSource 
(auth=Application) to work.  I want to look at the source code to investigate. 
I was also trying to cast the DataSource returned by JNDI so I can query its 
properties.  Casting to org.apache.tomcat.dbcp.dbcp.BasicDataSource doesn't seem 
to work, resulting in a "package does not exist" even after including the jar 
file in the CLASSPATH.


Thanks!
---Mark


Yoav Shapira wrote:
> org.apache.tomcat.dbcp should be just a repackaged Jakarta Commons
> DBCP, with no code changes.  The data source you get back from
> Tomcat's JNDI by default is just that repackaged one, which of course
> implements the standard javax.sql.DataSource interface.
> 
> Yoav
> 
> On 9/12/06, Mark Barnes <ma...@coat.com> wrote:
>> I have downloaded the 5.5.17 source, and am looking for the source for 
>> class
>> org.apache.tomcat.dbcp.dbcp.BasicDataSource but cannot find it.  In 
>> fact, I
>> cannot find org.apache.tomcat.dbcp.
>>
>> Can someone please point me to where it is?
>>
>> I've also looked under Jakarta Commons but can't seem to find it there 
>> either.
>> I seem to be able to find only 
>> org.apache.commons.dbcp.BasicDataSource.  But
>> that's not the kind of DataSource return via JNDI from Tomcat.
>>
>>
>> Thanks,
>> ---Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org


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


Re: Source for Packages org.apache.tomcat.dbcp and below?

Posted by Yoav Shapira <yo...@apache.org>.
org.apache.tomcat.dbcp should be just a repackaged Jakarta Commons
DBCP, with no code changes.  The data source you get back from
Tomcat's JNDI by default is just that repackaged one, which of course
implements the standard javax.sql.DataSource interface.

Yoav

On 9/12/06, Mark Barnes <ma...@coat.com> wrote:
> I have downloaded the 5.5.17 source, and am looking for the source for class
> org.apache.tomcat.dbcp.dbcp.BasicDataSource but cannot find it.  In fact, I
> cannot find org.apache.tomcat.dbcp.
>
> Can someone please point me to where it is?
>
> I've also looked under Jakarta Commons but can't seem to find it there either.
> I seem to be able to find only org.apache.commons.dbcp.BasicDataSource.  But
> that's not the kind of DataSource return via JNDI from Tomcat.
>
>
> Thanks,
> ---Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

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