У меня проблема с инъекцией компонента Seam, который аннотируется как бин @Stateful в другой, который аннотируется так же.Итак, у меня есть компонент:
@Stateful
@Name("userFncModalAction")
@Scope(ScopeType.SESSION)
public class UserFncModalAction extends ... {
@In
private UserPanelListActionLocal userPanelListAction;
}
Впрыснутый почти такой же (аннотируется как @Name, @Stateful).Моя проблема после того, как страница пытается загрузить и сделать инъекцию.Исключение повышается> javax.naming.NameNotFoundException: ни один объект не связан с именем java: comp / env / TutorialWeb-ear / UserPanelListAction.
Я не знаю, где проблема.Я использую оба определения ejb ref 1. web.xml = ссылка на ejb для внедрения веб-модуля 2. ejb-jar.xml = поддержка внедрения ejb в другой компонент Seam
Конфигурация моего проекта:
web.xml ejb ref
<code><ejb-local-ref>
<ejb-ref-name>TutorialWeb-ear/UserPanelListAction</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home/>
<local>cz.cca.web.action.user.UserPanelListActionLocal</local>
</ejb-local-ref>
TutorialWeb-уха / UserFncModalActionсессия cz.cca.web.action.user.UserFncModalActionLocal
components.xml
<core:init debug="false" jndi-pattern="java:comp/env/TutorialWeb-ear/#{ejbName}"/>
ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
version="3.0">
<enterprise-beans>
<session>
<ejb-name>UserPanelListActionLocal</ejb-name>
<ejb-local-ref>
<ejb-ref-name>TutorialWeb-ear/UserPanelListAction</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home/>
<local>cz.cca.web.action.user.UserPanelListActionLocal</local>
</ejb-local-ref>
</session>
<session>
<ejb-name>UserFncModalActionLocal</ejb-name>
<ejb-local-ref>
<ejb-ref-name>TutorialWeb-ear/UserFncModalAction</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home/>
<local>cz.cca.web.action.user.UserFncModalActionLocal</local>
</ejb-local-ref>
</session>
</enterprise-beans>
<interceptors>
<interceptor>
<interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
</interceptor>
</interceptors>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>*</ejb-name>
<interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
</interceptor-binding>
</assembly-descriptor>
</ejb-jar>
Когда я использую аннотацию @In как простую, это вызовет:
INFO: EJB5018: An exception was thrown during an ejb invocation on [UserFncModalAction]
INFO: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: org.jboss.seam.RequiredException: @In attribute requires non-null value: userFncModalAction.userPanelListAction
org.jboss.seam.RequiredException: @In attribute requires non-null value: userFncModalAction.userPanelListAction
at org.jboss.seam.Component.getValueToInject(Component.java:2361)
at org.jboss.seam.Component.injectAttributes(Component.java:1739)
at org.jboss.seam.Component.inject(Component.java:1557)
at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:29)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:30)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
...
...
...at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Когда я использую аннотацию с выражением - это означает:
@In("#{userPanelListAction}")
private UserPanelListActionLocal userPanelListAction;
, после этого выдает:
INFO: EJB5018: An exception was thrown during an ejb invocation on [UserFncModalAction]
INFO: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: org.jboss.seam.InstantiationException: Could not instantiate Seam component: userPanelListAction
org.jboss.seam.InstantiationException: Could not instantiate Seam component: userPanelListAction
at org.jboss.seam.Component.newInstance(Component.java:2170)
at org.jboss.seam.Component.getInstance(Component.java:2024)
at org.jboss.seam.Component.getInstance(Component.java:1986)
at org.jboss.seam.Component.getInstance(Component.java:1980)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:148)
at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
at ...
...
...
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/env/TutorialWeb-ear/UserPanelListAction
at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:834)
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:396)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.jboss.seam.Component.instantiateSessionBean(Component.java:1403)
at org.jboss.seam.Component.instantiate(Component.java:1367)
at org.jboss.seam.Component.newInstance(Component.java:2148)
... 192 more
Наконец-то я решил проблему !!!- атрибуты аннотации нужны, поэтому я написал
@In(create=true, required=false)
private UserPanelListActionLocal userPanelListAction;
и все в порядке.