ClassCastException org.codehaus.stax2.XMLInputFactory2 when packaging stax in JBoss EAP 6

Solution Unverified - Updated -

Issue

  • We are trying to migrate a war from an old version of Weblogic to Jboss but have run into some sort of class cast exception having to do with XML parsing. In particular, the code in question utilizes the Codehaus Stax2 parsing libraries. There is a chunk of code:
private static XMLInputFactory2 getInputFactory() {
        if (my.inputFactory == null) {
            my.inputFactory = (XMLInputFactory2) XMLInputFactory2.newInstance();
        }
        return my.inputFactory;
    }

And XMLInputFactory2.newInstance() is returning a class of type "__redirected.__XMLInputFactory" but our code tries to cast to a (org.codehaus.stax2.XMLInputFactory2).

Environment

Red Hat JBoss Enterprise Application Platform (EAP) 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.