jboss7.x - Is it possible to initialize Seam 2.3 component if the class is located in different EAR on JBoss 7.1.1? -
i have 2 ears, ear actual application, ear b used debugging , testing.
ear contains jar seam component classes, annotated @name. ear contains war seam 2.3 webapp , defines components in components.xml. works fine.
ear b contains war b, stripped version of war ear a. ear b correctly defines dependency on subdeployment "jar a" in jboss-deployment-structure.xml. war b defines few components jar a, fail initialize during webapp deployment. caused by:
java.lang.illegalargumentexception: component class must have @name annotation or name must specified in components.xml: [name of class]
when debug initialization , set breakpoint in seam class org.jboss.seam.init.initialization:488
if ( !clazz.isannotationpresent(name.class) ) { throw new illegalargumentexception( "component class must have @name annotation or name must specified in components.xml: " + clazz.getname()); } name = clazz.getannotation(name.class).value();
the if condition false. when inspect clazz's annotations in debugger, can see annotation correct value.
interface org.jboss.seam.annotations.name=@org.jboss.seam.annotations.name(value=org.jboss.seam.security.identity)
i suspect has loading @name annotation in 2 different deployments (i.e. classloaders), because when move war b ear a, works. please let me know if right or if there way how achieve this.
i presume problem caused fact have jboss-seam.jar
library in both wars, creates classloading conflict because @name
annotation defined in both classloaders , isannotationpresent(name.class)
fails because indeed class not have warb:name.class
rather wara:name.class
.
to solve issue, move jboss-seam.jar
common ancestor classloader:
- move
jboss-seam.jar
lib directory of server. - put
jboss-seam.jar
among ear libraries , 2 wars in same ear. - alternatively, drop dependency between 2 ears, packaging shared jar in both ears.
- finally, can make dependency in "the ee way", via ejb invocation services in ear a.
in jboss 7, there's way of sharing modules among ears, explore solution (this not ee standard behaviour not portable other containers). in jboss-deployment-structure.xml
of ear b declare dependent modules:
<?xml version="1.0" encoding="utf-8"?> <jboss-deployment-structure> <ear-subdeployments-isolated>false</ear-subdeployments-isolated> <deployment> <dependencies> <module name="ear_a.ear.jar_a.jar" export="true" /> </dependencies> </deployment> </jboss-deployment-structure>
i don't know if worth it, easier duplicate dependency in both ears.
also, note if components in src/hot
, you're in debug mode have problems using them separate war, regardless of classloading you're using (components in src/hot
exists in separate classloader created seam when deploying application, server knows nothing classes).
Comments
Post a Comment