我正在尝试使用 JSF/Primefaces 在应用程序中设置 CDI(用于 @ConversationScoped)并部署在 Jetty 上。我收到这个异常(我相信是)一个非常基本的 ConversationScoped bean。梳理了我能找到的所有相关搜索结果,但一无所获,因此将不胜感激任何建议。
@Named
@ConversationScoped
public class RegisterBean implements Serializable {
...
private @Inject Conversation conversation;
...
public String doSubmitBasicInfo() {
conversation.begin();
if(accountType == null)
return null;
if(accountType.equals("seller_account"))
return "register_seller_1?faces-redirect=true";
else if(accountType.equals("buyer_account"))
return "register_buyer_1?faces-redirect=true";
return null;
}
...
JSF 页面的相关部分是:
<div style="text-align:center;" class="noBorder autoMargin">
<p:commandButton type="submit" action="#{registerBean.doSubmitBasicInfo}" ajax="false" value="Submit" styleClass="autoMargin"></p:commandButton>
</div>
例外是:
javax.enterprise.context.ContextNotActiveException: Conversation Context not active when method called on conversation Conversation with id: 1
at org.jboss.weld.context.conversation.ConversationImpl.verifyConversationContextActive(ConversationImpl.java:197)
at org.jboss.weld.context.conversation.ConversationImpl.getLastUsed(ConversationImpl.java:154)
at org.jboss.weld.context.AbstractConversationContext.isExpired(AbstractConversationContext.java:337)
at org.jboss.weld.context.AbstractConversationContext.invalidate(AbstractConversationContext.java:285)
at org.jboss.weld.jsf.WeldPhaseListener.deactivateConversations(WeldPhaseListener.java:146)
at org.jboss.weld.jsf.WeldPhaseListener.afterPhase(WeldPhaseListener.java:91)
at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:486)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.eclipse.jetty.server.Server.handle(Server.java:350)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
at java.lang.Thread.run(Thread.java:722)