我使用GlassFish 4.0和PrimeFaces 4.0在本地计算机上开发了Java7 EE Web项目。我已经通过运行Apache Tomcat 7.0.27的WebServer上的.war-file成功部署了它。
一切都是相同的,除了这个小代码片段:
...
<h:form id="autoComplete">
<p:autoComplete id="auto" size="55" converter="autoConverter" value="#{autoComplete.indexObj}" var="per" itemLabel="#{per.name}" itemValue="#{per.id}" completeMethod="#{autoComplete.complete}" onkeydown="styleOnKey();">
<p:ajax event="itemSelect" listener="#{autoComplete.handleComplete}" update=":content" oncomplete="styleOnKey();"/>
</p:autoComplete>
</h:form>
...
<h:form id="selectMenu">
<p:selectOneMenu value="#{autoComplete.strSelectedSearch}">
<c:forEach items="#{autoComplete.lstSearches}" var="search">
<f:selectItem itemLabel="#{search}" itemValue="#{search}" />
</c:forEach>
<p:ajax event="change" update=":autoComplete:auto :content" listener="#{autoComplete.handleSelect(event)}"/>
</p:selectOneMenu>
</h:form>
...
我的支持bean的一些片段:
@ManagedBean(name = "autoComplete")
@ViewScoped
public class AutoCompleteBean implements Serializable {
...
public void handleComplete(SelectEvent event) {
Logger.Log("complete fired");
}
...
public void handleSelect(SelectEvent event) {
Logger.Log("select fired");
}
...
}
有关此代码段的有趣之处,在Windows 7 SP1上使用带有GlassFish 4.0的.war文件时,p:selectOneMenu(handleSelect)上的ajax事件正在触发。
如果您使用Apache Tomcat 7.0.27在Windows 2008 R2 Server上部署此代码,则不会。
任何人都知道为什么会这样?有人能够重现这个吗?
守则的其余部分也是如此。
任何帮助将不胜感激... ^^
编辑: 我设法在Tomcat-Logs中找到以下StackTrace:
SEVERE: java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at org.apache.el.util.ReflectionUtil.isAssignableFrom(ReflectionUtil.java:319)
at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:185)
at org.apache.el.parser.AstValue.invoke(AstValue.java:257)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at org.primefaces.component.behavior.ajax.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxBehaviorListenerImpl.java:53)
at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113)
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:804)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1812)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
答案 0 :(得分:0)
我通过使用以下代码片段解决了这个问题:
...
<p:ajax event="change" update=":autoComplete:auto :content" onsuccess="#{autoComplete.handleSimulatedSelect(event)}"/>
...
使用onSuccess-Attribute可以同时使用两个服务器,但有没有人对此进行重新解释?