-
1. Re: Wildfly 8 final + CDI + WAR inside EAR = problem
nostravita Jun 4, 2014 4:12 PM (in response to nostravita)After I extracted WAR and RAR from EAR and deployed them separately, I can see a problem in the following
@ConnectionDefinition(
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,
ResourceAdapterAssociation,
Serializable,
Referenceable
{
...
}
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
reitsmaj Jan 4, 2015 5:09 PM (in response to nostravita)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:
@ConnectionDefinition( 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:
<ironjacamar> <connection-definitions> <connection-definition class-name="javaeetutorial.trading.rar.outbound.TradeManagedConnectionFactory" jndi-name="java:/eis/TradeConnectionFactory"/> </connection-definitions> </ironjacamar>
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 Jan 4, 2015 11:03 PM (in response to nostravita)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
reitsmaj Jan 5, 2015 5:16 AM (in response to jaikiran)I downloaded the JavaEE 7 SDK. The example is in folder glassfish4/docs/javaee-tutorial/examples/connectors.