Jboss seam自定义servlet“没有活动事件上下文”

时间:2012-04-26 22:15:33

标签: servlets jboss seam

我有jboss seam web服务。我将我的服务类映射到web.xml中,如下所示

<servlet>
    <servlet-name>pluginhandler</servlet-name>
    <servlet-class>service.PlugInHandler</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>pluginhandler</servlet-name>
    <url-pattern>/*</url-pattern> 
</servlet-mapping>

我在一些博客上看到,如果你在jboss seam中使用自定义servlet,那么你必须添加过滤器org.jboss.seam.servlet.SeamServletFilter来生成我可能需要与seam组件通信所需的所有上下文

<filter>
    <filter-name>Seam Servlet Filter</filter-name>
    <filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>
</filter> 
<filter-mapping>
    <filter-name>Seam Servlet Filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping> 

我有一个seam组件Action,我试图在web方法中实例化,但我一直得到空指针异常(当我尝试调用它的方法时),根本原因是“没有活动事件上下文”。我已经附加了如下的异常堆栈

    Servlet.service() for servlet pluginhandler threw exception
java.lang.IllegalStateException: No active event context
    at org.jboss.seam.core.Manager.instance(Manager.java:250)
    at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:55)
    at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    at java.lang.Thread.run(Unknown Source)

我不知道可能出现什么问题。我是否缺少使用自定义servlet的特定配置? 我非常感谢你的帮助和时间。我使用的是seam 2.0.1.GA和jboss版本是4.2.2.GA

由于

1 个答案:

答案 0 :(得分:1)

如果您以非标准方式访问Seam组件,则需要使用Lifecycle.beginCall()Lifecycle.endCall()

包装方法调用
Lifecycle.beginCall() 
Component.getInstance('...').call();
Lifecycle.endCall()