QName incompatibility in JBoss EAP 5

Solution Unverified - Updated -

Issue

I stumbled upon an incompatibility of the class javax.xml.namespace.QName in the follwing situation:

An RMI server is being run using a Sun JDK 5 environment.
JBoss EAP 5.0.0 is running with an Sun JDK 6 environment.

An application in JBoss is calling the RMI server and during that call in the RMI response there are contained javax.xml.namespace.QName objects. I get an incompatible class exception, becaus JBoss uses a QName class from stax-api.jar which is contained in the server's endorsed directory. This class does not have a serialVersionUID entry, so a computed value is used. The server uses the default implementation from the JDK which has a serialVersionUID; that leads to the conflict.

I managed to get the connection running by moving stax-api.jar from the endorsed lib which of course seems to be no satisfying solution. Is this a useable workaround or what else could I do? Do I need the stax-api.jar as an endorsed when JBoss is running within a Sun JDK that contains the corresponding QName class?

Alas this is not the solution (I already tried that), as this property fixes an incompatibility that Sun introduced between Java 1.4 and 1.5. They changed the serialVersionUID from -9120448754896609940 to 4418622981026545151 with no need. Then they introduced in javax.xml.namespace.QName two fields, defaultSerialVersionUID and compatibleSerialVersionUID, and in a static initializer they do:

    static {
        try {
            // use a privileged block as reading a system property
            String valueUseCompatibleSerialVersionUID = (String) AccessController.doPrivileged(
                    new PrivilegedAction() {
                        public Object run() {
                            return System.getProperty("com.sun.xml.namespace.QName.useCompatibleSerialVersionUID");
                        }
                    }
            );
            useDefaultSerialVersionUID = (valueUseCompatibleSerialVersionUID != null && valueUseCompatibleSerialVersionUID.equals("1.0")) ? false : true;
        } catch (Exception exception) {
            // use default if any Exceptions
            useDefaultSerialVersionUID = true;
        }

        // set serialVersionUID to desired value
        if (useDefaultSerialVersionUID) {
            serialVersionUID = defaultSerialVersionUID;
        } else {
            serialVersionUID = compatibleSerialVersionUID;
        }
    }

But this has nothing to do with my problem, because JBoss 5.0.0 is using javax.xml.namespace.QName from server/lib/endorsed/stax-api.jar which does not define any serialVersionUID at all, so a computed value is used and leads to the following entry in the server's log:

ERROR [STDERR] Caused by: java.io.InvalidClassException: javax.xml.namespace.QName; local class incompatible: stream classdesc serialVersionUID = -9120448754896609940, local class serialVersionUID = -711357515002332258

The stream class value is the one from the JDK, produced by the RMI server, and the local one (-711357515002332258) is a computed one.

So actually I see three possibilities:

1) add the same stax-api.jar to the RMI server's endorsed directory. This is no solution as I don't have access to that server.

2) remove stax-api.jar from jboss/server/lib/endorsed. This I have done for the moment, but this may lead to problems which I cannot see yet.

3) replace the stax-api.jar with a version that contains either no QName at all or a QName class with a correct serialVersionUID.

Environment

  • JBoss Enterprise Application Platform 5 ( Java 6 )
  • RMI Server ( Java 5 )

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.