Search code examples
jbosswildfly-10apache-drill

Using a thirdparty jdbc jar conflicts with jboss_redirected. _DocumentBuilderfactory


I am using a third party jdbc jar (drill-jdbc-all-1.13.jar) in the jboss/modules/company/jdbc/other, with a module.xml as here :

<module xmlns="urn:jboss:module:1.3" name="vermilion.jdbc.others" slot="main">
    <resources>
        <resource-root path="drill-jdbc-all-1.13.0.jar"/>
    </resources>
    <dependencies>    
       <module name="javax.api"/>    
       <module name="javax.transaction.api"/>    
       <module name="sun.jdk"/>    
       <module name="org.apache.commons.collections"/>    
    </dependencies>  
</module>

However, when i invoke the driver, with the connection string, it seems to give me a conflict, with the following error:

WARN 2018-05-02 12:09:57,467 (com.vermilionsoftware.vrs.common.biz.db.DGSFactory:109) Failed to get DB connection: java.lang.ClassCastException: __redirected.__DocumentBuilderFactory cannot be cast to javax.xml.parsers.DocumentBuilderFactory

at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)

at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2516)

at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2492)
at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2405)
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1143)
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1115)
at oadd.org.apache.drill.exec.rpc.security.kerberos.KerberosFactory.createAndLoginUser(KerberosFactory.java:59)
at oadd.org.apache.drill.exec.rpc.user.UserClient.authenticate(UserClient.java:219)
at oadd.org.apache.drill.exec.rpc.user.UserClient.connect(UserClient.java:155)
at oadd.org.apache.drill.exec.client.DrillClient.connect(DrillClient.java:432)
at oadd.org.apache.drill.exec.client.DrillClient.connect(DrillClient.java:379)
at org.apache.drill.jdbc.impl.DrillConnectionImpl.<init>(DrillConnectionImpl.java:158)
at org.apache.drill.jdbc.impl.DrillJdbc41Factory.newDrillConnection(DrillJdbc41Factory.java:72)
at org.apache.drill.jdbc.impl.DrillFactory.newConnection(DrillFactory.java:69)
at oadd.org.apache.calcite.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:143)
at org.apache.drill.jdbc.Driver.connect(Driver.java:72)

The Configuration.java in Hadoop invokes the DocumentBuilderFactory.newInstance() without specifying any jaxp implementation, and so it creates the instance using the application class loader rather than class loader loading the Configutaion.java class.

Can some one help on how can I get around this error?

Thanks


Solution

  • I think the problem isn't that your JAXP implementation isn't being used, it's that you're including a JAXP API, which is disallowed. You should ensure that the drill-jdbc-all-*.jar does not include javax.xml classes.

    Generally a ClassCastException such as this is going to indicate duplicated API JARs.