DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34081>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34081

           Summary: JDBCRealm embeded in Context wont load if driver class
                    isn't global
           Product: Tomcat 5
           Version: Nightly Build
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


When initializing a StandardContext, the JDBCReam doesn't use the Context's
class loader making the driver classes unavailable if they aren't installed
globally (eew).  This breaks the ability to use the manager application to
deploy an app that uses a JDBCRealm because the driver class is unknown to the
default loader.  This also erodes abstraction between the web application and
the application server and would appear to be a bug rather than a feature
request as in bug 33266 
(http://issues.apache.org/bugzilla/show_bug.cgi?id=33266).

This issue was particularly irritating due to bug 34080
(http://issues.apache.org/bugzilla/show_bug.cgi?id=34080) that I just entered
in.  Because I didn't have my jdbc driver classes globally installed, I was
getting this for an error (trace from 5.0.28 BTW):

JDBCRealm[]: Exception performing authentication
java.sql.SQLException: oracle.jdbc.driver.OracleDriver
        at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:589)
        at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:344)
        at ... blah blah blah ...

This obviously didn't give me the information that I needed to understand what
the problem was, although I did get a hint.

Consider lines 678 through 686 in the current JDBCRealm.java:

        // Instantiate our database driver if necessary
        if (driver == null) {
            try {
                Class clazz = Class.forName(driverName);
                driver = (Driver) clazz.newInstance();
            } catch (Throwable e) {
                throw new SQLException(e.getMessage());
            }
        }

it would appear that solving this problem would be as simple as changing line
681 to:

                Class clazz = container.getLoader() != null
                        ? Class.forName(driverName, container.getLoader())
                        : Class.forName(driverName);

This would be my 1st time building tomcat, so I'll have to try this this
weekend.  Is anybody aware of issues that would occur with having a class that
was loaded by a different loader however?  Also, can anybody think of problems
that this could cause for containers other than Contexts (i.e., should we check
if container is a Context before we do this)?

Thanks,
Daniel

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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

Reply via email to