2014-09-29 55 views
1

我工作的接缝,并试图通过使用煤层@In属性要求非空值

@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变化范围类型,雪村等尝试,它仍然是给我同样的eception

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

任何一个可以建议如果我错过了任何东西的情况下?

我确信豆的名称和变量名是相同的

回答

3

我解决了上述问题。这里注射没有问题,但问题在于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; 
+0

WOOW。 ü拯救我的生命! – 2015-11-09 11:24:31