gpt4 book ai didi

java - Websocket + 漂亮面孔 = AbstractMethodError

转载 作者:行者123 更新时间:2023-12-01 16:43:12 26 4
gpt4 key购买 nike

我正在 tomcat 8.5 中构建一个简单的 JSF 2.3 应用程序。我让 websocket 正常工作,然后添加了 Pretty Faces。

如果我单独使用它们,它们都可以工作。我的意思是,如果我从 pom 中删除 Pretty Faces 的依赖项,我的 websocket 就可以工作。如果我保留依赖项,并删除 <f:websocket>在我看来,漂亮的面孔有效(重定向正常)!

但是,如果我尝试使用 Pretty Faces,而我有 <f:websocket>看来,AbstractMethodError当我导航到它时出现。从字面上看,如果我评论该标签,其他一切都会起作用。

我用的是莫哈拉。在我的 pom 中,我使用 https://github.com/javaserverfaces/mojarra/blob/master/README.md 中的依赖项,和the default ones对于漂亮的面孔。

根据我在 this BalusC answer 中读到的内容,我猜问题是我有冲突的依赖项,或者 Pretty Faces 和 Websocket 存在某种冲突。

如有任何帮助,我们将不胜感激。提前致谢。

这里是依赖项

<!-- Java EE containers -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>

<!-- Servlet Containers -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-shaded</artifactId>
<version>3.0.0.Final</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency> <!-- Optional, only when <f:websocket> is used. -->
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1</version>
</dependency>

<!-- Pretty Faces -->
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>3.4.2.Final</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-config-prettyfaces</artifactId>
<version>3.4.2.Final</version>
</dependency>

这里是异常(exception)

Nov 06, 2019 1:49:39 AM com.sun.faces.context.ExceptionHandlerImpl log
FATAL: JSF1073: java.lang.AbstractMethodError caught during processing of RENDER_RESPONSE 6 : UIComponent-ClientId=, Message=null
Nov 06, 2019 1:49:39 AM com.sun.faces.context.ExceptionHandlerImpl log
FATAL: No associated message
java.lang.AbstractMethodError
at javax.faces.application.ViewHandlerWrapper.getWebsocketURL(ViewHandlerWrapper.java:328)
at javax.faces.application.ViewHandlerWrapper.getWebsocketURL(ViewHandlerWrapper.java:328)
at com.sun.faces.push.WebsocketChannelManager.register(WebsocketChannelManager.java:151)
at 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)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:949)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1912)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:918)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1905)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:491)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:194)
at org.ocpsoft.rewrite.faces.RewriteViewHandler.renderView(RewriteViewHandler.java:196)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:151)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:151)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:126)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:223)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:226)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:470)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:395)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:316)
at org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler.handleResult(HttpRewriteResultHandler.java:42)
at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:297)
at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:198)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at 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)
at java.lang.Thread.run(Thread.java:748)

最佳答案

更新:

根据林肯的评论,新版本 PrettyFaces 3.4.3支持 JSF 2.3。除了其他更改之外,它现在还包含 RewriteViewHandler extend ViewHandlerWrapper 正如 BalusC 所建议的。

<小时/>

背景:

PrettyFaces 3.4.2 似乎与 JSF 2.3 不完全兼容。

非抽象类org.ocpsoft.rewrite.faces.RewriteViewHandler.RewriteViewHandler延伸javax.faces.application.ViewHandler但不重写抽象方法getWebsocketURL .

您可以使用漂亮的面孔和类路径上的 JSF 2.3 API 轻松地重现此内容:

package my.pkg;

import org.ocpsoft.rewrite.faces.RewriteViewHandler;

public class PrettyFacesTest {
public static void main(String[] args) {
new RewriteViewHandler(null).getWebsocketURL(null, null);
}
}

结果:

Exception in thread "main" java.lang.AbstractMethodError: org.ocpsoft.rewrite.faces.RewriteViewHandler.getWebsocketURL(Ljavax/faces/context/FacesContext;Ljava/lang/String;)Ljava/lang/String;
at my.pkg.PrettyFacesTest.main(PrettyFacesTest.java:7)

RewriteViewhandler注册于rewrite-integration-faces-3.4.2.Final.jar/META-INF/faces-config.xml :

<application>
<navigation-handler>org.ocpsoft.rewrite.faces.RewriteNavigationHandler</navigation-handler>
<view-handler>org.ocpsoft.rewrite.faces.RewriteViewHandler</view-handler>
</application>

我不确定是否有机会阻止此注册。如果是这样,您可以创建一个 CustomRewriteViewHandler延伸RewriteViewHandler ,覆盖getWebsocketURL以及调用 super.parent 的代表:

import javax.faces.application.ViewHandler;
import javax.faces.context.FacesContext;

import org.ocpsoft.rewrite.faces.RewriteViewHandler;

public class CustomRewriteViewHandler extends RewriteViewHandler {
public CustomRewriteViewHandler(ViewHandler viewHandler) {
super(viewHandler);
}

@Override
public String getWebsocketURL(FacesContext context, String channel) {
return super.parent.getWebsocketURL(context, channel);
}
}

然后您将注册此 CustomRewriteViewHandler 而不是原始的:

<application>
<view-handler>my.pkg.CustomRewriteViewHandler</view-handler>
</application>

正如 BalusC 所描述的 here您无法阻止部分faces-config.xml从包含的 jar 。相反,您可以设置 <faces-config ... metadata-complete="true">结果没有 faces-config.xml也没有任何包含的注释 jar正在处理,因此您需要重新定义您自己所需的所有 3d 派对内容 faces.config.xml .

关于java - Websocket + 漂亮面孔 = AbstractMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58721840/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com