4 Replies Latest reply on Jan 5, 2015 5:16 AM by Jaap Reitsma

    Wildfly 8 final + CDI + WAR inside EAR = problem

    alex kopylov Newbie

      I'm having trouble running official JEE 7 tutorial JCA example named 'Trading'. Originally this example is intended to run on GlassFish (and it runs there just fine). When I deploy the same on Wildfly 8 Final I got the following error immediately upon entering URL 'localhost:8080/trading/':



      11:03:01,607 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (default task-1) Error Rendering View[/index.xhtml]: org.jboss.weld.exceptions.WeldException: WELD-001524: Unable to load proxy class for bean Managed Bean [class javaeetutorial.trading.war.ResourceAccessBean] with qualifiers [@Default @Any @Named] with class class javaeetutorial.trading.war.ResourceAccessBean using classloader ModuleClassLoader for Module "deployment.trading-ear.ear:main" from Service Module Loader


      Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: javaeetutorial/trading/war/ResourceAccessBean


      Caused by: java.lang.ClassNotFoundException: javaeetutorial.trading.war.ResourceAccessBean from [Module "deployment.trading-ear.ear:main" from Service Module Loader]



      Apparently Weld has trouble finding 'ResourceAccessBean' class, which is a part of WEB archive packaged inside EAR.


      I found couple relevant links, which didn't help my much:

      Class Loading in WildFly - WildFly 8 - Project Documentation Editor




      This tutorial example is rather simple, so I don't see why WildFly would treat it differently than GlassFish.


      Help is much appreciated.

        • 1. Re: Wildfly 8 final + CDI + WAR inside EAR = problem
          alex kopylov Newbie

          After I extracted WAR and RAR from EAR and deployed them separately, I can see a problem in the following



              connectionFactory = ConnectionFactory.class,

              connectionFactoryImpl = TradeConnectionFactoryImpl.class, // this does not implement 'ConnectionFactory.class - ?

              connection = Connection.class,

              connectionImpl = TradeConnectionImpl.class // this does not implement 'Connection.class - ?


          public class TradeManagedConnectionFactory

              implements ManagedConnectionFactory,









          Looking into JCA 1.7 Spec I cannot be sure if 'connectionFactoryImpl' HAS TO implement the interface specified by 'connectionFactory'. Although that would seem logical.


          Citing connector_1_7.xsd:

          "The element connectionfactory-interface specifies the fully qualified name of the ConnectionFactory interface supported by the resource adapter."

          "The element connectionfactory-impl-class specifies the fully qualified name of the ConnectionFactory class that implements resource adapter specific ConnectionFactory interface."


          From two above citations it's possible to conclude that 'connectionfactory-impl-class' could implement some other than 'connectionfactory-interface'.


          Anyways, JBoss/WildFly throws the following:


          Caused by: org.jboss.jca.deployers.common.DeployException: IJ020066: Connection factory implementation (javaeetutorial.trading.rar.outbound.TradeConnectionFactoryImpl) doesn't implement connection factory interface (javax.resource.cci.ConnectionFactory)



          Looks like JBoss interprets the spec differently than GlassFish, as GlassFish happily accepts the fact that 'TradeConnectionFactoryImpl' does not implement 'ConnectionFactory'. Now the question is 'who is right'?

          • 2. Re: Wildfly 8 final + CDI + WAR inside EAR = problem
            Jaap Reitsma Newbie

            The javaee 7 tutorial trading example has multiple issues when deploying to WildFly. I tested with 8.1.

            First, the connection definition is invalid. It must be:

                connectionFactory = TradeConnectionFactory.class,
                connectionFactoryImpl = TradeConnectionFactoryImpl.class,
                connection = TradeConnection.class,
                connectionImpl = TradeConnectionImpl.class

            Each implementation must implement the interface it says to offer, sounds logical.


            Then the TradeManagedConnectionFactory as well as the TradeResourceAdapter must implement a hashCode() and equals().


            Furthermore, the TradeConnectionFactory interface must extend Serializable and Referenceable.


            The you need to supply a ironjacamar.xml file to define the factory (and remove the annotation on the resource adapter). [I have to verify again if the annotation works]. I added:



            All these are the simple issues, because WildFly will complain about it with clear messages. The most amazing issue is with CDI (?): If and only if the package name of the ResourceAccessBean (in the WAR) starts with 'java' then JSF will issue the error WELD-001524: Unable to load proxy class for bean Managed Bean .... If you just rename it from 'javatutorial' to 'thejavaeetutorial' then it is ok. Weird. The underlying reason for the weld error is a NoClassDefFoundError on the ResourceAccessBean.


            Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: javaeetutorial/trading/war/TradeResourceAccessBean

                    at org.jboss.weld.util.bytecode.ClassFileUtils.toClass(ClassFileUtils.java:101) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]

                    at org.jboss.weld.bean.proxy.ProxyFactory.createProxyClass(ProxyFactory.java:434) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]

                    at org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:319) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]

                    ... 78 more

            Caused by: java.lang.NoClassDefFoundError: javaeetutorial/trading/war/TradeResourceAccessBean

                    at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.7.0_51]

                    at java.lang.ClassLoader.defineClass(ClassLoader.java:800) [rt.jar:1.7.0_51]

                    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source) [:1.7.0_51]

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_51]

                    at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_51]

                    at org.jboss.weld.util.bytecode.ClassFileUtils.toClass2(ClassFileUtils.java:108) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]

                    at org.jboss.weld.util.bytecode.ClassFileUtils.toClass(ClassFileUtils.java:97) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]

                    ... 80 more

            Caused by: java.lang.ClassNotFoundException: javaeetutorial.trading.war.TradeResourceAccessBean from [Module "deployment.trading-ear.ear:main" from Service Module Loader]

                    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]


            I don't understand this, I tested with only one class in the WAR packed in the EAR without the RAR (I commented the connector code). Nothing else deployed in WildFly. To complicate things: This happens only when the WAR is embedded in an EAR. The standalone WAR deploys fine.

            • 3. Re: Wildfly 8 final + CDI + WAR inside EAR = problem
              jaikiran pai Master

              alex kopylov wrote:


              I'm having trouble running official JEE 7 tutorial JCA example named 'Trading'.

              Alex, where is it available?

              • 4. Re: Wildfly 8 final + CDI + WAR inside EAR = problem
                Jaap Reitsma Newbie

                I downloaded the JavaEE 7 SDK. The example is in folder glassfish4/docs/javaee-tutorial/examples/connectors.