[jboss-as7-dev] problem with the classloader, not able to load a JDBC driver

Flemming Harms flemming.harms at gmail.com
Fri Jul 20 10:58:19 EDT 2012


Hi

I'm trying to finish https://issues.jboss.org/browse/AS7-1371 but I ran
into a problem with the class loader. I need way to load the class for a
specified JDBC driver, but I can't seem to figure out how to make it
available on the classpath too my authentication service.

I try to load the connection class like this, and testing it with the
existing H2 JDBC driver:
ClassLoader original = null;
        try {
            original = Thread.currentThread().getContextClassLoader();
            if (original != null) {
                Thread.currentThread().setContextClassLoader(null);
            }
            Class.forName(this.driver).newInstance();
        } finally {
            if (original != null) {
                Thread.currentThread().setContextClassLoader(original);
            }
}

The user can setup a outbound connection to a database for authentication,
by using the configuration below

 <security-realm name="ManagementRealm">
      <authentication>
           <local default-user="$local"/>
           <database connection="db" plain-text="true">
             <!-- simple-select-users table="users" username-field="user"
password-field="password"/ -->
             <sql-select-users sql="select user,password from users where
user = ?" />
           </database>
      </authentication>
</security-realm>

<outbound-connections>
        <database>
            <connection driver="org.h2.jdbcx.JdbcDataSource" name="db"
url="jdbc:h2:/tmp/test;DB_CLOSE_DELAY=-1" username="sa" password=""
min-pool-size="10" max-pool-size="20" />
        </database>
</outbound-connections>

Any suggestions how to solve this?

Thanks!

br
Flemming
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-as7-dev/attachments/20120720/fd251552/attachment.html 


More information about the jboss-as7-dev mailing list