【问题标题】:Seam @In attribute requires non-null valueSeam @In 属性需要非空值
【发布时间】:2014-09-29 09:57:12
【问题描述】:

我正在处理接缝并尝试通过使用来注入接缝组件

@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)

而且我还可以从同一类中注入其他类,并且只有在注入 myBeanClass 的情况下才会失败

如果我遗漏了什么,有人可以建议吗?

而且我确定 bean 名称和变量名称是相同的

【问题讨论】:

    标签: seam


    【解决方案1】:

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

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

    2) 早些时候我被注入了 FavoriteManager 为

    @In(create = true)    
    private MyBeanManager favoriteManager;  
    

    改为

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

    【讨论】:

      猜你喜欢
      • 2013-04-28
      • 1970-01-01
      • 2021-12-28
      • 1970-01-01
      • 2012-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-25
      相关资源
      最近更新 更多