I've a simple jsf webapp working in a servlet context. I would apply portletbridge so that I can run it in the servlet context and in the portlet context in the same time. Adding a simple portlet.xml and the portletbridge 3.2.1 dependencies in the pom.xml, I get this error when I connect to the application outside the portlet context:
18:01:18,291 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/gatein-forums].[Faces Servlet]] (http--127.0.0.1-8080-1) Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
at org.jboss.portletbridge.context.exception.PortletExceptionHandler.handle(PortletExceptionHandler.java:64) [portletbridge-impl-3.2.1.Final.jar:3.2.1.Final]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
connect I see that the BridgeContext.getCurrentInstance() command returns null. How it misses? Can I use the portletbridge outside the portlet context?
Unfortunately it's not possible to have a single WAR used as both a JSF application and a JSF portlet.
As soon as you add Portlet Bridge and configure portlets in a WAR, it can no longer be run as a plain JSF app.