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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content