RE: NPE in javax.portlet.faces.GenericFacesPortlet.getBridgeClassName()

thumbnail
David H Nebinger, modified 5 Years ago. Junior Member Posts: 39 Join Date: 3/5/13 Recent Posts
I tried posting this question as a response to my other post that Neil answered before, but it was marked as spam, so I'm going to try posting again. 
We are getting this NPE when we deploy a faces portlet:

2020-06-30 14:54:08.931 ERROR [Refresh Thread: Equinox Container: 402a09bd-b355-472a-9a4e-609d3120ea9d][PortletBagFactory:214] java.lang.NullPointerException
java.lang.NullPointerException
        at javax.portlet.faces.GenericFacesPortlet.getBridgeClassName(GenericFacesPortlet.java:193)
        at javax.portlet.faces.GenericFacesPortlet.getBridge(GenericFacesPortlet.java:762)
        at javax.portlet.faces.GenericFacesPortlet.init(GenericFacesPortlet.java:448)
        at com.liferay.portlet.internal.InvokerPortletImpl.init(InvokerPortletImpl.java:248)
        at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet.init(MonitoringInvokerPortlet.java:151)
        at com.liferay.portlet.internal.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:278)
        at com.liferay.portlet.internal.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:181)
        at com.liferay.portal.kernel.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:48)
        at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:210)
        at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:108)
        at com.liferay.portal.service.impl.PortletLocalServiceImpl.initWAR(PortletLocalServiceImpl.java:923)
        at jdk.internal.reflect.GeneratedMethodAccessor828.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
        at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
        at com.sun.proxy.$Proxy54.initWAR(Unknown Source)
        at com.liferay.portal.kernel.service.PortletLocalServiceUtil.initWAR(PortletLocalServiceUtil.java:457)
        at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:232)
        at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:97)
        at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:229)
        at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
        at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)
        at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:189)
        at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:179)
        at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:44)
        at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:75)
        at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:57)
        at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:55)
        at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:141)
        at com.liferay.portal.kernel.servlet.SecurePluginContextListener.contextInitialized(SecurePluginContextListener.java:152)
        at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletContextListenerExceptionAdapter._initializeContext(ServletContextListenerExceptionAdapter.java:119)
        at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletContextListenerExceptionAdapter.contextInitialized(ServletContextListenerExceptionAdapter.java:99)
        at jdk.internal.reflect.GeneratedMethodAccessor170.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.eclipse.equinox.http.servlet.internal.registration.ListenerRegistration$EventListenerInvocationHandler.invoke(ListenerRegistration.java:143)
        at com.sun.proxy.$Proxy433.contextInitialized(Unknown Source)
        at org.eclipse.equinox.http.servlet.internal.context.ContextController.doAddListenerRegistration(ContextController.java:350)
        at org.eclipse.equinox.http.servlet.internal.context.ContextController.addListenerRegistration(ContextController.java:303)
        at org.eclipse.equinox.http.servlet.internal.customizer.ContextListenerTrackerCustomizer.addingService(ContextListenerTrackerCustomizer.java:71)
        at org.eclipse.equinox.http.servlet.internal.customizer.ContextListenerTrackerCustomizer.addingService(ContextListenerTrackerCustomizer.java:1)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
        at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903)
        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:891)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:804)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:228)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:487)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:1004)
        at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.initListeners(WabBundleProcessor.java:625)
        at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.init(WabBundleProcessor.java:231)
        at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer._initWabBundle(WebBundleDeployer.java:159)
        at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer.doStart(WebBundleDeployer.java:88)
        at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory$WABExtension.start(WabFactory.java:113)
        at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:66)
        at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:48)
        at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:475)
        at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:1)
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
        at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:230)
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:137)
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:129)
        at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:191)
        at org.eclipse.osgi.container.Module.publishEvent(Module.java:476)
        at org.eclipse.osgi.container.Module.doStart(Module.java:578)
        at org.eclipse.osgi.container.Module.start(Module.java:449)
        at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:468)
        at org.eclipse.osgi.container.ModuleContainer.start(ModuleContainer.java:777)
        at org.eclipse.osgi.container.ModuleContainer.applyDelta(ModuleContainer.java:768)
        at org.eclipse.osgi.container.ModuleContainer.resolveAndApply(ModuleContainer.java:538)
        at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:484)
        at org.eclipse.osgi.container.ModuleContainer.refresh(ModuleContainer.java:1028)
        at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.dispatchEvent(ModuleContainer.java:1409)
        at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.dispatchEvent(ModuleContainer.java:1)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
2020-06-30 14:54:08.934 ERROR [Refresh Thread: Equinox Container: 402a09bd-b355-472a-9a4e-609d3120ea9d][PortletBagFactory:214] java.lang.NullPointerException
java.lang.NullPointerException
        at javax.portlet.faces.GenericFacesPortlet.getBridgeClassName(GenericFacesPortlet.java:193)
        at javax.portlet.faces.GenericFacesPortlet.getBridge(GenericFacesPortlet.java:762)
        at javax.portlet.faces.GenericFacesPortlet.init(GenericFacesPortlet.java:448)
        at com.liferay.portlet.internal.InvokerPortletImpl.init(InvokerPortletImpl.java:248)
        at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet.init(MonitoringInvokerPortlet.java:151)
        at com.liferay.portlet.internal.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:278)
        at com.liferay.portlet.internal.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:181)
        at com.liferay.portal.kernel.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:48)
        at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:210)
        at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:108)
        at com.liferay.portal.service.impl.PortletLocalServiceImpl.initWAR(PortletLocalServiceImpl.java:923)
        at jdk.internal.reflect.GeneratedMethodAccessor828.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
        at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
        at com.sun.proxy.$Proxy54.initWAR(Unknown Source)
        at com.liferay.portal.kernel.service.PortletLocalServiceUtil.initWAR(PortletLocalServiceUtil.java:457)
        at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:232)
        at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:97)
        at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:229)
        at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
        at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)
        at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:189)
        at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:179)
        at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:44)
        at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:75)
        at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:57)
        at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:55)
        at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:141)
        at com.liferay.portal.kernel.servlet.SecurePluginContextListener.contextInitialized(SecurePluginContextListener.java:152)
        at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletContextListenerExceptionAdapter._initializeContext(ServletContextListenerExceptionAdapter.java:119)
        at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletContextListenerExceptionAdapter.contextInitialized(ServletContextListenerExceptionAdapter.java:99)
        at jdk.internal.reflect.GeneratedMethodAccessor170.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.eclipse.equinox.http.servlet.internal.registration.ListenerRegistration$EventListenerInvocationHandler.invoke(ListenerRegistration.java:143)
        at com.sun.proxy.$Proxy433.contextInitialized(Unknown Source)
        at org.eclipse.equinox.http.servlet.internal.context.ContextController.doAddListenerRegistration(ContextController.java:350)
        at org.eclipse.equinox.http.servlet.internal.context.ContextController.addListenerRegistration(ContextController.java:303)
        at org.eclipse.equinox.http.servlet.internal.customizer.ContextListenerTrackerCustomizer.addingService(ContextListenerTrackerCustomizer.java:71)
        at org.eclipse.equinox.http.servlet.internal.customizer.ContextListenerTrackerCustomizer.addingService(ContextListenerTrackerCustomizer.java:1)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
        at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903)
        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:891)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:804)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:228)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:487)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:1004)
        at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.initListeners(WabBundleProcessor.java:625)
        at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.init(WabBundleProcessor.java:231)
        at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer._initWabBundle(WebBundleDeployer.java:159)
        at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer.doStart(WebBundleDeployer.java:88)
        at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory$WABExtension.start(WabFactory.java:113)
        at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:66)
        at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:48)
        at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:475)
        at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:1)
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
        at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:230)
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:137)
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:129)
        at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:191)
        at org.eclipse.osgi.container.Module.publishEvent(Module.java:476)
        at org.eclipse.osgi.container.Module.doStart(Module.java:578)
        at org.eclipse.osgi.container.Module.start(Module.java:449)
        at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:468)
        at org.eclipse.osgi.container.ModuleContainer.start(ModuleContainer.java:777)
        at org.eclipse.osgi.container.ModuleContainer.applyDelta(ModuleContainer.java:768)
        at org.eclipse.osgi.container.ModuleContainer.resolveAndApply(ModuleContainer.java:538)
        at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:484)
        at org.eclipse.osgi.container.ModuleContainer.refresh(ModuleContainer.java:1028)
        at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.dispatchEvent(ModuleContainer.java:1409)
        at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.dispatchEvent(ModuleContainer.java:1)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

Here are the dependencies in our pom file:
<javax.faces.faces-api.version>2.2</javax.faces.faces-api.version>
<org.glassfish.javax.faces.version>2.2.20</org.glassfish.javax.faces.version>
<com.liferay.faces.bridge.ext.version>5.0.5</com.liferay.faces.bridge.ext.version>
<!-- Not needed, but still in our pom - should we remove these? -->
<com.sun.faces.version>2.2.20</com.sun.faces.version>
<com.liferay.faces.bridge.api.version>4.1.0</com.liferay.faces.bridge.api.version>
<com.liferay.faces.portal.version>4.0.0</com.liferay.faces.portal.version>
I looked at the source, here: https://github.com/liferay/liferay-faces-bridge-api/blob/master/bridge-api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java and I see this comment above  getBridgeClassName()
/**
* Returns the className of the bridge implementation this portlet uses. Subclasses override to alter the default
* behavior. Default implementation first checks for a portlet context init parameter:
* javax.portlet.faces.BridgeImplClass. If it doesn't exist then it looks for the resource file
* "META-INF/services/javax.portlet.faces.Bridge" using the current threads classloader and extracts the classname
* from the first line in that file.
*
* @return the class name of the Bridge class the GenericFacesPortlet uses. <code>null</code> if it can't be
* determined.
*/
public String getBridgeClassName() {

So it appears we need to set up the className in a config file.  Unfortunately, I don't know what class name it should have.  Also, can you point me to some documentation that explains how to set that up? 

Thanks,
Clint
thumbnail
Neil Griffin, modified 5 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
Hi Clint,
In these types of circumstances I typically recommend that you start with something that works and then compare that with what is not working.
To that end, I would recommend that you visit liferayfaces.org and after selecting Liferay Version, JSF Version, and Component Suite from the dropdowns, copy the corresponding Maven archetype:generate command to your clipboard and then paste the command into a terminal window on your local.
Then, build the generated archetype with "mvn clean package" and copy the resulting WAR to $LIFERAY_HOME/deploy
If that works, then you can examine the pom.xml descriptor of the generated project and compare it with your existing pom.xml descriptor.
Kind Regards,
Neil
thumbnail
Clint Wilde, modified 5 Years ago. Junior Member Posts: 39 Join Date: 3/5/13 Recent Posts
Thanks Neil. I found that I had some old dependencies in the pom which were causing problems.  It appears to be working  now. 
thumbnail
Neil Griffin, modified 5 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
Thanks for letting me know Clint. And thanks for using Liferay Faces! :-)