我在渲染f:websocket组件时遇到问题。服务器是Tomcat v8.5。
关于链接的说明:
http://balusc.omnifaces.org/2013/10/how-to-install-cdi-in-tomcat.html
How to update JSF 2.2 to JSF 2.3 using Maven in a Spring Application
https://blog.payara.fish/jsf-2.3-the-websocket-quickstart-under-payara-server
maven依赖项是:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-shaded</artifactId>
<version>3.0.3.Final</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2</version>
</dependency>
这是test.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form>
<h:outputText value="#{pisSocketView.count}" styleClass="display" />
<p:commandButton value="Click"
actionListener="#{pisSocketView.increment}" />
<f:websocket channel="counter" onmessage="handleMessage" />
</h:form>
<script type="text/javascript">
function handleMessage(message, channel, event) {
$('.display').text(message);
}
</script>
</h:body>
</html>
&#13;
当我加载页面时,我收到错误:
java.lang.AbstractMethodError 在javax.faces.application.ViewHandlerWrapper.getWebsocketURL(ViewHandlerWrapper.java:328) 在javax.faces.application.ViewHandlerWrapper.getWebsocketURL(ViewHandlerWrapper.java:328) at com.sun.faces.push.WebsocketChannelManager.register(WebsocketChannelManager.java:151) 在com.sun.faces.push.WebsocketChannelManager.register(WebsocketChannelManager.java:142) at com.sun.faces.push.WebsocketChannelManager $ Proxy $ _ $$ _ WeldClientProxy.register(Unknown Source) at com.sun.faces.renderkit.html_basic.WebsocketRenderer.encodeEnd(WebsocketRenderer.java:115) 在javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:949) 在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1912) 在javax.faces.render.Renderer.encodeChildren(Renderer.java:176) 在javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:918) 在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1905) 在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908) 在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908) 在com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:491) 在com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:194) 在org.ocpsoft.rewrite.faces.RewriteViewHandler.renderView(RewriteViewHandler.java:186) 在javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:151) 在javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:151) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:126) 在com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:223) 在javax.faces.webapp.FacesServlet.service(FacesServlet.java:671) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:205) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:117) 在org.springframework.boot.web.support.ErrorPageFilter.access $ 000(ErrorPageFilter.java:61) at org.springframework.boot.web.support.ErrorPageFilter $ 1.doFilterInternal(ErrorPageFilter.java:92) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:110) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 在org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) 在org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:790) 在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1459) 在org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run(Thread.java:748)