Seam @In属性需要非null值

时间:2014-09-29 09:57:12

标签: seam

我正在研究接缝并尝试使用

注入接缝组件
@Name("myBeanClass")         
@Scope(ScopeType.CONVERSATION)
public class MyBeanClass {
    start();
}

并尝试使用以下start()来使用其他类

中的代码
@In(create = true, required = false, value = "myBeanClass")
protected MyBeanClass myBeanClass
public Class TestClass {
    public void start() {    
        myBeanClass.start();
    }
}

我甚至尝试将MyBeanClass中的范围类型更改为sesson等,但仍然给了我同样的感知

12:34:43,233 WARN  [org.jboss.seam.Component] [http-localhost%2F127.0.0.1-8080-2] Cannot create Seam component, scope is not active: favoriteManager(PAGE)
12:34:43,240 WARN  [org.jboss.seam.Component] [http-localhost%2F127.0.0.1-8080-2] Cannot create Seam component, scope is not active: favoriteManager(PAGE)
12:34:53,081 ERROR [org.jboss.aspects.tx.TxPolicy] [http-localhost%2F127.0.0.1-8080-2] javax.ejb.EJBTransactionRolledbackException: @In attribute requires non-null value: myBeanClass.favoriteManager
12:34:53,093 ERROR [STDERR] [http-localhost%2F127.0.0.1-8080-2] 

    javax.ejb.EJBTransactionRolledbackException: @In attribute requires non-null value: orgUnitUpdateManager.favoriteManager
    12:34:53,094 ERROR [STDERR] [http-localhost%2F127.0.0.1-8080-2]     at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:115)
    12:34:53,094 ERROR [STDERR] [http-localhost%2F127.0.0.1-8080-2]     at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
    12:34:53,094 ERROR [STDERR] [http-localhost%2F127.0.0.1-8080-2]     at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:194)
    12:34:53,140 ERROR [STDERR] [http-localhost%2F127.0.0.1-8080-2]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    12:34:53,140 ERROR [STDERR] [http-localhost%2F127.0.0.1-8080-2]     at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
    12:34:53,140 ERROR [STDERR] [http-localhost%2F127.0.0.1-8080-2]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
    12:34:53,140 ERROR [STDERR] [http-localhost%2F127.0.0.1-8080-2]     at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)

而且我也可以从Same类中注入其他类,但只有在注入myBeanClass时才会失败

任何人都可以建议我是否遗漏了任何东西?

我确信bean名称和变量名称相同

1 个答案:

答案 0 :(得分:4)

我解决了上述问题。这里注入没有问题,但问题出在MyBeanClass中。我们在MyBeanClass中再注入一个名为MyBeanManager的bean,接缝无法注入,我用两种方式解决了上述问题:

1)删除了FavoriteManager的注入(如果它没有在你的bean中使用)

2)之前我将FavoriteManager注入

@In(create = true)    
private MyBeanManager favoriteManager;  

更改为

@In(create = true,required = false, value = "favoriteManager")    
private MyBeanManager favoriteManager;