Search code examples
javasecurityweblogicclassloader

ClassCastException on weblogic


Question 1: (Solved)

I'm facing an issue with class loader in Weblogic.

I've a Web application which executes the following code.

AccessController.doPrivileged()

This is handled by another classloader.

When the above code gets executed, Class Not Found exception occurred for a project specific class(for example Sample.class) which exist in web project.

How can I solve this issue?

Solution: Weblogic 10.3.1.0 is using com.bea.core.apache.commons.net_1.0.0.0_1-4-1.jar... I want to use commons-net-2.0.jar from my code


Question 2:

After getting solution as I mentioned earlier, now its throwing ClassCastException as follows.

java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory
    at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:128)

Solution

  • To answer your second question: the most probable thing is that you already have an implementation of the SAX somewhere (which is located upper in the classpath).

    For example JSF requires one implementation of SAX parser (WL admin console webapp uses JSF, so chances are SAX is already imported).

    There should be only one implementation, otherwise you could experience strange behavior and strange exceptions. Delete the second implementation from the lib folder of the application.