Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractMethodError when <f:websocket> is used #265

Open
TheTimeWalker opened this issue Jul 11, 2018 · 5 comments
Open

AbstractMethodError when <f:websocket> is used #265

TheTimeWalker opened this issue Jul 11, 2018 · 5 comments

Comments

@TheTimeWalker
Copy link

TheTimeWalker commented Jul 11, 2018

There's currently a compatibility issue with JSF 2.3 new websocket implementation.
As soon as a <f:websocket> block is being used in an XHTML, the facesServlet throws an exception:

java.lang.AbstractMethodError
	at javax.faces.application.ViewHandlerWrapper.getWebsocketURL(ViewHandlerWrapper.java:357)
	at javax.faces.application.ViewHandlerWrapper.getWebsocketURL(ViewHandlerWrapper.java:357)
	at com.sun.faces.push.WebsocketChannelManager.register(WebsocketChannelManager.java:152)
	at com.sun.faces.push.WebsocketChannelManager.register(WebsocketChannelManager.java:143)
	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:619)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1677)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1673)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1673)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:492)
	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:156)
	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:156)
	at org.omnifaces.viewhandler.OmniViewHandler.renderView(OmniViewHandler.java:115)
	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.executeLifecyle(FacesServlet.java:732)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:475)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1622)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:339)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
	at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:251)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:226)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:251)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:654)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:593)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:516)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:213)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:242)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
	at java.lang.Thread.run(Thread.java:748)

This can be reproduced only by having the library integrated and letting it load. Setting nothing up except an XHTML with <f:websocket> and a param with ENABLE_WEBSOCKET_ENDPOINT at true in web.xml is enough to make this appear.

ryoung seems to have a similar issue as seen on the support page of Rewrite
bmlikota is on a similar boat where they fixed that by removing the dependency for rewrite as seen in StackExchange

Running:
Payara Server 5.0.181
JSF 2.3

@lincolnthree
Copy link
Member

Hey! Thanks for reporting this.

Does the same error occur if you are not including OmniFaces?

@TheTimeWalker
Copy link
Author

TheTimeWalker commented Jul 12, 2018

Good idea, you made me try different combinations with Omnifaces + Rewrite and there could be a connection between the two.

Interestingly, on a clean slate project the WAR deploys and doesn't throw any error if either only Omnifaces 3.0 alone or only Rewrite 3.4.2.Final are integrated. For some reason I can't replicate that throw error there... but instead as soon as both are being added and ENABLE_WEBSOCKET_TRUE is set to true, you end up with a NullPointerException:

Error invoking ServletContainerInitializer org.glassfish.tyrus.servlet.TyrusServletContainerInitializer
java.lang.NullPointerException
	at org.glassfish.tyrus.servlet.TyrusServletContainerInitializer.onStartup(TyrusServletContainerInitializer.java:153)
	at org.apache.catalina.core.StandardContext.callServletContainerInitializers(StandardContext.java:5825)
	at com.sun.enterprise.web.WebModule.callServletContainerInitializers(WebModule.java:695)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:5722)
	at com.sun.enterprise.web.WebModule.start(WebModule.java:609)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:956)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:939)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:684)
	at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2099)
	at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1745)
	at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
	at org.glassfish.internal.data.EngineRef.start(EngineRef.java:123)

On another note, on my running project everything works fine if you use <o:socket> instead of <f:websocket>

@chkal
Copy link
Member

chkal commented Jul 12, 2018

Looks like the NPE is thrown here:

https://github.com/tyrus-project/tyrus/blob/1.14/containers/servlet/src/main/java/org/glassfish/tyrus/servlet/TyrusServletContainerInitializer.java#L153

ServletContext.addFilter() will return null if:

null if this ServletContext already contains a complete FilterRegistration for a filter with the given filterName or if the same filter instance has already been registered with this or another ServletContext in the same container

So maybe the initialization is triggered twice for some reason?

@TheTimeWalker
Copy link
Author

TheTimeWalker commented Jul 13, 2018

A new day, a fresh mind. After tweaking the application to not throw random errors (faces-config.xml issues), I've been able to test that out a bit more. When both Omnifaces and Rewrite run, I get the same error as on the original post. Now I've been thinking a bit and noticed that there could be an issue with the FakeEndpoint you have to add in to make <f:websocket> work on Glassfish implementations.

Interestingly, it's possible that Omnifaces is not the culprit of this seeing as <o:socket> works. Without any endpoint and without Omnifaces, I get a new exception:

Error Rendering View[/index.xhtml]
java.lang.NullPointerException
	at com.sun.faces.cdi.CdiUtils.getBeanReferenceByType(CdiUtils.java:223)
	at com.sun.faces.cdi.CdiUtils.getBeanReference(CdiUtils.java:206)
	at com.sun.faces.renderkit.html_basic.WebsocketRenderer.encodeEnd(WebsocketRenderer.java:111)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:619)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1677)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1673)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:492)
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:194)
	at org.ocpsoft.rewrite.faces.RewriteViewHandler.renderView(RewriteViewHandler.java:196)
	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.executeLifecyle(FacesServlet.java:732)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:475)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1622)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:339)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
	at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:251)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:226)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:251)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:654)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:593)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:516)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:213)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:242)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
	at java.lang.Thread.run(Thread.java:748)`

...which makes completely sense as <f:websocket> can't work if there's no endpoint for it. Now if I add in a fake endpoint which simply looks like this:

public class FakeEndpoint extends Endpoint {
    @Override
    public void onOpen(Session session, EndpointConfig config) {
        // https://java.net/jira/browse/WEBSOCKET_SPEC-240
    }
}

you get the NullPointerException error from my comment before! So what it seems like is that Rewrite clashes with the endpoint that gets manually added to conform with the WEBSOCKET SEC-240

@raul-marques
Copy link

Same problem =(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants