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

NullPointerException thrown due to Mojarra 2.3 PartialViewContextImpl inspecting InternalIE8CompatiblityLinks as a resource #831

Closed
ngriffin7a opened this issue Jul 31, 2017 · 8 comments
Assignees
Milestone

Comments

@ngriffin7a
Copy link

ngriffin7a commented Jul 31, 2017

Although this issue was first encountered with the FacesBridge for Portlet 3.0 + JSF 2.3 using Mojarra 2.3, at this time I don't think it is related to Portlet 3.0. In other words, it should be possible to reproduce this in a plain BootsFaces webapp that uses f:ajax in order to handle onchange inside of a text field.

According to the stacktrace below, PartialViewContextImpl.renderComponentResources(renderComponentResources(FacesContext context, UIViewRoot viewRoot) is trying to execute the following loop:

        for (UIComponent resource : viewRoot.getComponentResources(context)) {
            String name = (String) resource.getAttributes().get("name");
            String library = (String) resource.getAttributes().get("library");

            if (resource.getChildCount() == 0 
              && resourceHandler.getRendererTypeForResourceName(name) != null 
              && !resourceHandler.isResourceRendered(context, name, library)) 
            {
            ...

And when the resource variable is an instance of InternalIE8CompatiblityLinks.java, the value of name and library are both equal to null. Because of this, the call to resourceHandler.getRendererTypeForResourceName(name) throws a NullPointerException further up the stack.

31-Jul-2017 14:07:34.770 SEVERE [http-nio-8180-exec-6] com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError java.lang.NullPointerException
    at com.liferay.faces.bridge.util.internal.FileNameUtil.getFileNameExtension(FileNameUtil.java:70)
    at com.liferay.faces.bridge.util.internal.FileNameUtil.getFileNameMimeType(FileNameUtil.java:80)
    at com.liferay.faces.bridge.context.internal.ExternalContextCompat_2_0_Impl.getMimeType(ExternalContextCompat_2_0_Impl.java:207)
    at com.sun.faces.application.resource.ResourceHandlerImpl.getContentType(ResourceHandlerImpl.java:549)
    at com.sun.faces.application.resource.ResourceHandlerImpl.getRendererTypeForResourceName(ResourceHandlerImpl.java:260)
    at javax.faces.application.ResourceHandlerWrapper.getRendererTypeForResourceName(ResourceHandlerWrapper.java:218)
    at javax.faces.application.ResourceHandlerWrapper.getRendererTypeForResourceName(ResourceHandlerWrapper.java:218)
    at com.sun.faces.context.PartialViewContextImpl.renderComponentResources(PartialViewContextImpl.java:505)
    at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:337)
    at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:252)
    at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1124)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1905)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:465)
    at javax.faces.view.ViewDeclarationLanguageWrapper.renderView(ViewDeclarationLanguageWrapper.java:126)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:194)
    at com.liferay.faces.bridge.application.internal.ViewHandlerCompatImpl.renderView(ViewHandlerCompatImpl.java:95)
    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 com.liferay.faces.bridge.internal.BridgePhaseResourceImpl.execute(BridgePhaseResourceImpl.java:266)
    at com.liferay.faces.bridge.internal.BridgeImpl.doFacesRequest(BridgeImpl.java:179)
    at javax.portlet.faces.GenericFacesPortlet.serveResource(GenericFacesPortlet.java:618)
    at sun.reflect.GeneratedMethodAccessor1161.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.pluto.container.bean.processor.AnnotatedMethod.invoke(AnnotatedMethod.java:187)
    at org.apache.pluto.container.bean.processor.PortletInvoker.invokePortletMethod(PortletInvoker.java:137)
    at org.apache.pluto.container.bean.processor.PortletInvoker.serveResource(PortletInvoker.java:285)
    at org.apache.pluto.driver.services.container.FilterChainImpl.doFilter(FilterChainImpl.java:292)
    at org.apache.pluto.driver.services.container.FilterChainImpl.processFilter(FilterChainImpl.java:145)
    at org.apache.pluto.driver.services.container.FilterManagerImpl.processFilter(FilterManagerImpl.java:118)
    at org.apache.pluto.container.driver.PortletServlet3.dispatch(PortletServlet3.java:510)
    at org.apache.pluto.container.driver.PortletServlet3.doPost(PortletServlet3.java:338)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:720)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
    at org.apache.pluto.driver.container.DefaultPortletInvokerService.invoke(DefaultPortletInvokerService.java:243)
    at org.apache.pluto.driver.container.DefaultPortletInvokerService.serveResource(DefaultPortletInvokerService.java:162)
    at org.apache.pluto.container.impl.PortletContainerImpl.doServeResource(PortletContainerImpl.java:275)
    at org.apache.pluto.driver.PortalDriverServlet.doGet(PortalDriverServlet.java:182)
    at org.apache.pluto.driver.PortalDriverServlet.doPost(PortalDriverServlet.java:254)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1100)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:687)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)```
@stephanrauh stephanrauh self-assigned this Jul 31, 2017
@stephanrauh stephanrauh added this to the v1.2.0 milestone Jul 31, 2017
@stephanrauh
Copy link
Collaborator

I've managed to reproduce the bug, sort of, that is. Mojarra adds an additional null-check, so there's no NPE in Mojarra. But I was using the Liferay Faces bridge, the NPE would be thrown as you describe. BTW, thanks for your excellent description and analysis!

I suggest we tackle the problem on both fronts:

  • I assign a dummy name to the resource. Maybe Liferay isn't the only library omitting the null check.
  • You add an extra null check, as Mojarra does. Because maybe BootsFaces isn't the only library simply using null as a resource name :).

@stephanrauh
Copy link
Collaborator

@ngriffin7a When I set the name, the CombinedResourceListener of OmniFaces seems to expect that the file exists. So I could add a dummy file. But that seems to be a bit odd to me. I suggest you add an extra null check in your code.

BTW, it's funny that our AddResourcesHandler causes trouble with Liferay. I've invented it specifically because I wanted BootsFaces to be compatible with the Liferay Faces bridge!

@ngriffin7a
Copy link
Author

@ngriffin7a
Copy link
Author

@ngriffin7a
Copy link
Author

Fixed in the bridge https://issues.liferay.com/browse/FACES-3168

Feel free to close this issue if you don't want to make any changes to BootsFaces.

Thans @stephanrauh ! :)

@stephanrauh
Copy link
Collaborator

Your welcome! Yes, that was the method I was referring to.

@stephanrauh
Copy link
Collaborator

Using a dummy resource doesn't work well with the CombinedResourceHandler of OmniFaces. It takes the dummy resource, puts it into the combined JavaScript file and deletes our resource. So our resource can't render itself. Hence I close the ticket without modifying anything.

@ngriffin7a
Copy link
Author

OK thanks for the effort. :)

@stephanrauh stephanrauh modified the milestones: v1.1.3, v1.2.0 Aug 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants