Bug 1309174 - [GSS] (6.4.z) LinkageError due to javax.transaction.xa being in javax.transaction module and system loader
Summary: [GSS] (6.4.z) LinkageError due to javax.transaction.xa being in javax.transac...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Class Loading
Version: 6.4.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: CR1
: EAP 6.4.8
Assignee: Dmitrii Tikhomirov
QA Contact: Peter Mackay
URL:
Whiteboard:
Depends On:
Blocks: 1310484 eap648-payload
TreeView+ depends on / blocked
 
Reported: 2016-02-17 04:48 UTC by James Livingston
Modified: 2017-01-17 12:38 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-01-17 12:38:03 UTC
Type: Bug


Attachments (Terms of Use)
bz1309174-test.zip (3.46 KB, application/octet-stream)
2016-04-01 23:45 UTC, dereed
no flags Details


Links
System ID Priority Status Summary Last Updated
JBoss Issue Tracker JBEAP-3340 Blocker Closed javax.transaction/javax.sql class loading is wrong 2018-05-14 11:20:32 UTC
JBoss Issue Tracker WFLY-6117 Major Closed Modify javax.transaction.api to exclude the .xa subpackage 2018-05-14 11:20:31 UTC

Description James Livingston 2016-02-17 04:48:57 UTC
https://issues.jboss.org/browse/WFLY-6117 and linked issues report a problem caused by javax.transaction.xa.* classes being exported by the javax.transaction module which are different from the ones in system loader that javax.sql sees.

After trying a javax.sql module for a while, upstream switched to simply making javax.transaction re-export the system loader's classes, by adding this to the module.xml:
    <exports>
        <exclude path="javax/transaction/xa"/>
    </exports>

    <dependencies>
        <system export="true">
            <paths>
                <path name="javax/transaction/xa"/>
            </paths>
        </system>
    </dependencies>


Although the technical change is quite small, the impact may not be, and we will need to do some decent testing to make sure such a change does not break any rarely used code.

Comment 1 James Livingston 2016-02-17 04:50:57 UTC
Dennis noted you can force the problem to occur:

--
I've been able to reproduce the error locally with a simple example class.

    package example;

    import javax.sql.XAConnection;
    import javax.transaction.xa.XAResource;
    import java.sql.Connection;
    import javax.sql.ConnectionEventListener;
    import javax.sql.StatementEventListener;

    public class Test implements XAConnection
    {
       public XAResource getXAResource() { return null; }

        public void addConnectionEventListener( ConnectionEventListener listener ) {}
        public void addStatementEventListener ( StatementEventListener listener ) {}
        public void close () {}
        public Connection getConnection () { return null; }
        public void removeConnectionEventListener ( ConnectionEventListener listener ){}
        public void removeStatementEventListener ( StatementEventListener listener ) {}
    }

Packaged in a module, with the recommended dependencies for the Oracle driver:

        <module name="javax.api"/>
        <module name="javax.transaction.api"/>

If the following three lines are run, in any order, an error occurs in the 3rd one:

    Class.forName ( "javax.transaction.xa.XAResource", true, example.Test.class.getClassLoader() );
    Class.forName ( "javax.transaction.xa.XAResource", true, javax.sql.XAConnection.class.getClassLoader() );
    new example.Test();

If example.Test is last, the error is:

    ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/test].[jsp]] (http-/127.0.0.1:8080-1) JBWEB000236: Servlet.service() for servlet jsp threw exception: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "example.Test.getXAResource()Ljavax/transaction/xa/XAResource;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, example/Test, and the class loader (instance of <bootloader>) for interface javax/sql/XAConnection have different Class objects for the type tion/xa/XAResource; used in the signature

If one of the Class.forNames is last, the error is (with a different classloader for each):

    ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/test].[jsp]] (http-/127.0.0.1:8080-1) JBWEB000236: Servlet.service() for servlet jsp threw exception: java.lang.LinkageError: loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/transaction/xa/XAResource"
--



A customer experienced this through what appears to be regular usage of a connection, there is likely to be some kind of race where it works unless a variety of classes are loaded in exactly the right order.

Comment 5 dereed 2016-04-01 23:45:00 UTC
Created attachment 1142722 [details]
bz1309174-test.zip

Attached test case.  See included README for details on running it.

Comment 7 Peter Mackay 2016-05-05 11:58:31 UTC
Verified with EAP 6.4.8.CP.CR2

Comment 8 JBoss JIRA Server 2016-06-14 11:36:05 UTC
Jiri Pallich <jpallich@redhat.com> updated the status of jira JBEAP-3340 to Closed

Comment 9 Petr Penicka 2017-01-17 12:38:03 UTC
Retroactively bulk-closing issues from released EAP 6.4 cumulative patches.


Note You need to log in before you can comment on or make changes to this bug.