我正在研究接缝并尝试使用
注入接缝组件@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名称和变量名称相同
答案 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;