注入seam组件时出现IllegalArgumentException

时间:2016-05-26 08:29:27

标签: seam2

我正在尝试将使用seam 2.1.2的应用程序从JBoss 5.2迁移到JBoss 6.4 EAP。我将所有与seam相关的库添加为maven依赖项,现在我让应用程序部署没有任何错误,并且似乎成功创建了seam上下文(并且一些流程按预期工作)。

我偶然发现了一个问题,我希望有人可以帮忙提出建议。

我的EAR具有以下结构:

myapp.ear
|
|--- warpck.war
|
|--- ejb.jar
|
|--- client1.jar
|
|--- client2.jar
|
|--- commons.jar
|
|--- loggers.jar

在client1.jar中我定义了以下java bean:

@Name(CustomClient.NAME)
@AutoCreate
public class CustomClientImpl implements CustomClient {
...  
}

CustomClient界面如下所示:

public interface CustomClient extends GeneratedSoapClients {

    String NAME = "customClient";

}    

在部署期间,我有以下日志:

09:14:44,574 INFO  [org.jboss.seam.Component] (ServerService Thread Pool -- 81) Component: customClient, scope: EVENT, type: JAVA_BEAN, class: myapp.client.impl.CustomClientImpl

...所以我假设组件在接缝上下文中正确注册。

问题是当我尝试将此组件注入到ejb.jar包中的一个类中时。我收到以下错误:

09:14:49,319 ERROR [org.jboss.as.ejb3.invocation] (http-/127.0.0.1:8080-1) JBAS014134: EJB Invocation failed on component CustomAdapterWs for method public myapp.webservice.v5.CustomResponse myapp.webservice.impl.CustomAdapterWs.customInformation(myapp.webservice.v5.CustomInformation): javax.ejb.EJBException: java.lang.IllegalArgumentException: could not set field value: CustomAdapterController.customClient

Caused by: java.lang.IllegalArgumentException: could not set field value: CustomAdapterController.customClient
        at org.jboss.seam.Component.setFieldValue(Component.java:1927) [jboss-seam-2.1.2.jar:2.1.2]
        at org.jboss.seam.Component.access$600(Component.java:126) [jboss-seam-2.1.2.jar:2.1.2]
        at org.jboss.seam.Component$BijectedField.set(Component.java:2940) [jboss-seam-2.1.2.jar:2.1.2]
        at org.jboss.seam.Component.injectAttributes(Component.java:1736) [jboss-seam-2.1.2.jar:2.1.2]
        at org.jboss.seam.Component.inject(Component.java:1554) [jboss-seam-2.1.2.jar:2.1.2]
        at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61) [jboss-seam-2.1.2.jar:2.1.2]
        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam-2.1.2.jar:2.1.2]
        at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44) [jboss-seam-2.1.2.jar:2.1.2]
        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam-2.1.2.jar:2.1.2]
        at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) [jboss-seam-2.1.2.jar:2.1.2]
        at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185) [jboss-seam-2.1.2.jar:2.1.2]



Caused by: java.lang.IllegalArgumentException: Could not set field value by reflection: CustomAdapterController.customClient on: myapp.controller.CustomAdapterController with value: class myapp.client.impl.CustomClientImpl_$$_javassist_seam_2



Caused by: java.lang.IllegalArgumentException: Can not set myapp.client.CustomClient field myapp.controller.CustomAdapterController.customClient to myapp.client.impl.CustomClientImpl_$$_javassist_seam_2

CustomAdapterController:

@Name(CustomAdapterController.NAME)
@AutoCreate
public class CustomAdapterController {

    public static final String NAME = "CustomAdapterController";

    @In(value = CustomClient.NAME)
    private CustomClient customClient;

我使用的javassist依赖项(它已在EAR pom中添加):

    <dependency>
        <groupId>org.javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.20.0-GA</version>
    </dependency>

jboss-deployment-structure.xml:

<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>

<deployment>
    <exclusions>
        <module name="org.hibernate" slot="main"/>
        <module name="org.javassist" slot="main"/>
    </exclusions>
    <dependencies>
        <module name="javax.faces.api" slot="1.2" export="true"/>
        <module name="com.sun.jsf-impl" slot="1.2" export="true"/>
        <module name="org.apache.log4j" export="true"/>
        <module name="org.dom4j" export="true"/>
        <module name="org.apache.commons.logging" export="true"/>
        <module name="org.apache.commons.collections" export="true"/>
    </dependencies>
</deployment>

<sub-deployment name="warpck.war">
    <exclusions>
        <module name="javax.faces.api" slot="main"/>
        <module name="com.sun.jsf-impl" slot="main"/>
    </exclusions>
    <dependencies>
        <module name="javax.faces.api" slot="1.2"/>
        <module name="com.sun.jsf-impl" slot="1.2"/>
    </dependencies>
</sub-deployment>

<sub-deployment name="ejb.jar">
    <dependencies>
        <module name="client1.jar"/>
    </dependencies>
</sub-deployment>

</jboss-deployment-structure>

正确注入ejb.jar中定义的所有组件。每次我尝试注入一个在不同的包中定义的bean时,就会出现问题。谁能告诉我我在这里失踪了什么?

1 个答案:

答案 0 :(得分:0)

除非你使用这个版本的接缝

,否则你不能这样做

Seam 2.2.3

这是jboss-deployment-structure.xml