Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Nullpointer exception in JSF with primefaces in liferay 7.2
Sudhanshu Kumar Shukla, modified 5 Years ago.
Junior Member
Posts: 35
Join Date: 8/29/16
Recent Posts
Hi I am creating JSF portlet with primefaces in Liferay 7.2 but i am getting nullpointer exception during deployment(Local).i have used Liferay 7.2 ,JSF 2.2 with primefaces.Below is my pom.xml and stacktrace for reference .pom.xml
Exception stracktrace
Is Liferay 7.2 has support for JSF portlet with primefaces.
Catastrophic initialization failure! Shutting down com.ncrowd.scrum.portlet WAB due to: java.lang.NullPointerException
is anyone have faced any issue or am i doing something working.Please find the faces-config and web.xml file for reference.Thanks in advance for help.
<dependencies>
<dependency>
<groupid>javax.faces</groupid>
<artifactid>javax.faces-api</artifactid>
<version>2.2</version>
</dependency>
<dependency>
<groupid>org.glassfish</groupid>
<artifactid>javax.faces</artifactid>
<version>2.2.19</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>com.ncrowd</groupid>
<artifactid>com.ncrowd.api</artifactid>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>com.ncrowd</groupid>
<artifactid>com.ncrowd.service</artifactid>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>com.liferay.faces</groupid>
<artifactid>com.liferay.faces.bridge.api</artifactid>
<version>4.1.0</version>
</dependency>
<dependency>
<groupid>com.liferay.faces</groupid>
<artifactid>com.liferay.faces.bridge.ext</artifactid>
<version>5.0.4</version>
</dependency>
<dependency>
<groupid>com.liferay.faces</groupid>
<artifactid>com.liferay.faces.bridge.impl</artifactid>
<version>4.1.3</version>
</dependency>
<dependency>
<groupid>javax.portlet</groupid>
<artifactid>portlet-api</artifactid>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>log4j</groupid>
<artifactid>log4j</artifactid>
<version>1.2.14</version>
</dependency>
<dependency>
<groupid>com.liferay</groupid>
<artifactid>com.liferay.osgi.service.tracker.collections</artifactid>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>org.osgi</groupid>
<artifactid>org.osgi.core</artifactid>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>com.liferay.portal</groupid>
<artifactid>com.liferay.portal.kernel</artifactid>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>javax.servlet</groupid>
<artifactid>servlet-api</artifactid>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>com.liferay.faces</groupid>
<artifactid>liferay-faces-util</artifactid>
<version>4.2.5-ga6</version>
</dependency>
<dependency>
<groupid>com.liferay</groupid>
<artifactid>com.liferay.message.boards.web</artifactid>
<version>3.0.34</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>com.liferay</groupid>
<artifactid>com.liferay.message.boards.api</artifactid>
<version>5.2.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>jsf.commentbox</groupid>
<artifactid>jsf.comment.box</artifactid>
<version>1.0.0</version>
</dependency>
<dependency>
<groupid>org.primefaces</groupid>
<artifactid>primefaces</artifactid>
<version>6.2</version>
</dependency>
<dependency>
<groupid>org.atmosphere</groupid>
<artifactid>atmosphere-runtime</artifactid>
<version>2.5.3</version>
</dependency>
<dependency>
<groupid>org.atmosphere</groupid>
<artifactid>atmosphere-jersey</artifactid>
<version>2.5.3</version>
</dependency>
<!-- <dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>liferay-faces-bridge-impl</artifactId>
<version>4.2.5-ga6</version>
</dependency> -->
<!-- <dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.2-20</version>
</dependency> -->
<!-- <dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
</dependency> -->
<dependency>
<groupid>com.sun.faces</groupid>
<artifactid>jsf-impl</artifactid>
<version>2.2.9</version>
</dependency>
<dependency>
<groupid>javax.servlet.jsp</groupid>
<artifactid>jsp-api</artifactid>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>org.ocpsoft.prettytime</groupid>
<artifactid>prettytime</artifactid>
<version>4.0.2.Final</version>
</dependency>
<dependency>
<groupid>org.ocpsoft.prettytime</groupid>
<artifactid>prettytime-integration-jsf</artifactid>
<version>4.0.2.Final</version>
</dependency>
</dependencies>
Exception stracktrace
2019-12-18 12:35:49.379 ERROR [Refresh Thread: Equinox Container: 8c49123b-7e26-4a14-ab1f-753d9fa9edda][WabBundleProcessor:229] Catastrophic initialization failure! Shutting down com.ncrowd.scrum.portlet WAB due to: java.lang.NullPointerException
java.lang.RuntimeException: java.lang.NullPointerException
at com.sun.faces.config.ConfigureListener.contextInitialized(Unknown Source)
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 sun.reflect.GeneratedMethodAccessor186.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.http.servlet.internal.registration.ListenerRegistration$EventListenerInvocationHandler.invoke(ListenerRegistration.java:143)
at com.sun.proxy.$Proxy953.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:67)
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:623)
at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.init(WabBundleProcessor.java:216)
at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer._initWabBundle(WebBundleDeployer.java:179)
at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer.doStart(WebBundleDeployer.java:101)
at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory$WABExtension.start(WabFactory.java:114)
at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:67)
at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:49)
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)
Caused by: java.lang.NullPointerException
at com.liferay.faces.util.product.ProductFactory.getProductInstance(ProductFactory.java:76)
at com.liferay.faces.util.event.internal.UtilDependencyVerifier.verify(UtilDependencyVerifier.java:36)
at com.liferay.faces.util.event.internal.ApplicationStartupListener.processSystemEvent(ApplicationStartupListener.java:82)
at com.liferay.faces.util.event.internal.ApplicationStartupListenerCompat.processEvent(ApplicationStartupListenerCompat.java:44)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:108)
at com.sun.faces.application.ApplicationImpl.processListeners(Unknown Source)
at com.sun.faces.application.ApplicationImpl.invokeListenersFor(Unknown Source)
at com.sun.faces.application.ApplicationImpl.publishEvent(Unknown Source)
at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:739)
at com.sun.faces.config.ConfigManager.publishPostConfigEvent(Unknown Source)
... 57 mo
Is Liferay 7.2 has support for JSF portlet with primefaces.
Catastrophic initialization failure! Shutting down com.ncrowd.scrum.portlet WAB due to: java.lang.NullPointerException
is anyone have faced any issue or am i doing something working.Please find the faces-config and web.xml file for reference.Thanks in advance for help.
Attachments:
Hi Kumar,
I think that the NullPointerException is because you are using an incorrect dependency GroupId/ArtifactId/Version (GAV):
I think that the NullPointerException is because you are using an incorrect dependency GroupId/ArtifactId/Version (GAV):
Instead you should be using the com.liferay.faces.util-3.2.0.jar dependency. But rather than specifying it explicitly, I think it is better for it to be included transitively since other dependencies like Liferay Faces Bridge require it. In other words, Maven will include it automatically for you.I reorganized your pom.xml dependencies and came up with the following. Note that I think you should remove the Atmosphere dependencies since PrimeFaces no longer supports PrimePush:
|
Please give that a try and let me know how it works out. Kind Regards, Neil |
Sudhanshu Kumar Shukla, modified 5 Years ago.
Junior Member
Posts: 35
Join Date: 8/29/16
Recent Posts
Thanks Neil I followed your guided steps now no exception but now my bundle is starting state it is not coming on started or installed state.
have you any idea about that?
And once again thanks for quick reply.
have you any idea about that?
And once again thanks for quick reply.
It's my pleasure to help. Since you are aware of the state of the bundle, I am assuming that you are using the gogo shell. If not, then here is the documentation for how to access it:
https://portal.liferay.dev/docs/7-1/reference/-/knowledge_base/r/using-the-felix-gogo-shell
At the gogo shell prompt, type "lb" in order to list the bundles. Then identify the BundleId for the JSF portlet WAB.
Then type "start <BundleId>" and let me know if there are any errors printed in the portal's console log.
https://portal.liferay.dev/docs/7-1/reference/-/knowledge_base/r/using-the-felix-gogo-shell
At the gogo shell prompt, type "lb" in order to list the bundles. Then identify the BundleId for the JSF portlet WAB.
Then type "start <BundleId>" and let me know if there are any errors printed in the portal's console log.
Sudhanshu Kumar Shukla, modified 5 Years ago.
Junior Member
Posts: 35
Join Date: 8/29/16
Recent Posts
Neil Griffin:
It's my pleasure to help. Since you are aware of the state of the bundle, I am assuming that you are using the gogo shell. If not, then here is the documentation for how to access it:
https://portal.liferay.dev/docs/7-1/reference/-/knowledge_base/r/using-the-felix-gogo-shell
At the gogo shell prompt, type "lb" in order to list the bundles. Then identify the BundleId for the JSF portlet WAB.
Then type "start <BundleId>" and let me know if there are any errors printed in the portal's console log.
Hey Neil Now I am able to deploy and my bundle is starting also.
Thanks for your help.
Thanks for letting me know the good results, and thanks for using Liferay Faces

Sudhanshu Kumar Shukla, modified 5 Years ago.
Junior Member
Posts: 35
Join Date: 8/29/16
Recent Posts
Now i am able to run the portlet but my service tracker object is empty it is not able to find the services. can you please help me in this i have tried many approaches but didn't got successBelow is my service tracker code
I am not able to figure put where i am going wrong and thanks for your guidance.
public class CounterServiceTracker extends ServiceTracker<counterlocalservice, counterlocalservice>{
public CounterServiceTracker(BundleContext bundleContext) {
super(bundleContext,CounterLocalService.class,null);
}
}</counterlocalservice,>
Here is my JSF bean class where i am trying to access services
[code]@ManagedBean(name = "sprintBean")
@ViewScoped
public class SprintBean implements Serializable {
[code]public SprintBean() {
[code] Bundle bundle=FrameworkUtil.getBundle(this.getClass());
BundleContext bundleContext=bundle.getBundleContext();
serviceTracker=new CounterServiceTracker(bundleContext);
[code]}
[code]@PostConstruct
public void init() {
this.sprintMap = new TreeMap<>();
LOG.info("Service tracker for sprint is : "+serviceTracker.isEmpty());
if(Validator.isNotNull(serviceTracker) && !serviceTracker.isEmpty()) {
sprintLocalService=serviceTracker.getService();
[code] }}}
I am not able to figure put where i am going wrong and thanks for your guidance.
I find that the best way to approach these types of problems is to start with something that works, and slowly introduce changes until it breaks. I would recommend that you study (or even start with) the source code for the primefaces-users-portlet demo that we have, and in particular study the usage of the ServiceTracker in UsersBackingBean.java:
https://github.com/liferay/liferay-faces-portal/blob/master/demo/primefaces-users-portlet/src/main/java/com/liferay/faces/demos/bean/UsersBackingBean.java#L109
One thing we hope to change in the future though, is that the @PostConstruct creation of the ServiceTracker would take place in an @ApplicationScoped bean. It's really only something that should happen once in the lifespan of a portlet application. No need to do it upon every request like we do in the demo. But again, I recommend that you start with the demo and see how that works in your environment.
Kind Regards,
Neil
https://github.com/liferay/liferay-faces-portal/blob/master/demo/primefaces-users-portlet/src/main/java/com/liferay/faces/demos/bean/UsersBackingBean.java#L109
One thing we hope to change in the future though, is that the @PostConstruct creation of the ServiceTracker would take place in an @ApplicationScoped bean. It's really only something that should happen once in the lifespan of a portlet application. No need to do it upon every request like we do in the demo. But again, I recommend that you start with the demo and see how that works in your environment.
Kind Regards,
Neil
BTW I recommend that you work with the 3.x branch since that is compatible with Portlet 2.0, JSF 2.2, and Liferay 7.2:
https://github.com/liferay/liferay-faces-portal/tree/3.x
Better yet, you might want to work with the newly-released tag for version 3.0.5:https://github.com/liferay/liferay-faces-portal/tree/3.0.5
https://github.com/liferay/liferay-faces-portal/tree/3.x
Better yet, you might want to work with the newly-released tag for version 3.0.5:https://github.com/liferay/liferay-faces-portal/tree/3.0.5
Sudhanshu Kumar Shukla, modified 5 Years ago.
Junior Member
Posts: 35
Join Date: 8/29/16
Recent Posts
It work's.Thanks for your help Neil.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™