Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Timothy Esposito
Liferay Faces 3.2.4-ga5 on TomEE+ 1.6.2 NPE in LiferayLocalePhaseListener
14 janvier 2014 14:03
Réponse

Timothy Esposito

Rang: New Member

Publications: 6

Date d'inscription: 7 octobre 2012

Publications Récentes

I have a Liferay Portlet app that was broken on JBoss AS 7.1.1 with an older version of Liferay for other reasons, but I've recently migrated to TomEE+ 1.6.2 on Tomcat 7.0.47 and have Liferay Faces 3.2.4-ga5 snapshot integrated 2.1.13. TomEE+ is using MyFaces 2.1.13. The JSF pages are rendering, but I can not resolve the following exception.

 1
 221:12:53,578 ERROR [LiferayFacesContext:41] Instance not initialized -- caller might be static
 321:12:53,578 ERROR [LiferayLocalePhaseListener:87]
 4java.lang.NullPointerException
 5    at com.liferay.faces.portal.lifecycle.LiferayLocalePhaseListener.setLocale(LiferayLocalePhaseListener.java:67)
 6    at com.liferay.faces.portal.lifecycle.LiferayLocalePhaseListener.beforePhase(LiferayLocalePhaseListener.java:55)
 7    at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:77)
 8    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:234)
 9    at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:227)
10    at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:85)
11    at com.liferay.faces.bridge.BridgeImpl.doFacesRequest(BridgeImpl.java:112)
12    at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:255)
13    at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
14    at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:204)
15    at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
16    at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:103)
17    at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:55)
18    at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
19    at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
20    at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:112)
21    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
22    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
23    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
24    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
25    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:96)
26    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
27    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
28    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
29    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
30    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
31    at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:604)
32    at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:677)
33    at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:379)
34    at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1237)
35    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
36    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
37    at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:57)
38    at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:78)
39    at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
40    at com.liferay.portlet.PortletContainerImpl._doRender(PortletContainerImpl.java:655)
41    at com.liferay.portlet.PortletContainerImpl.render(PortletContainerImpl.java:138)
42    at com.liferay.portlet.SecurityPortletContainerWrapper.render(SecurityPortletContainerWrapper.java:141)
43    at com.liferay.portlet.RestrictPortletContainerWrapper.render(RestrictPortletContainerWrapper.java:126)
44    at com.liferay.portal.kernel.portlet.PortletContainerUtil.render(PortletContainerUtil.java:156)
45    at com.liferay.portal.layoutconfiguration.util.PortletRenderer._render(PortletRenderer.java:120)
46    at com.liferay.portal.layoutconfiguration.util.PortletRenderer.access$4(PortletRenderer.java:107)
47    at com.liferay.portal.layoutconfiguration.util.PortletRenderer$PortletRendererCallable.doCall(PortletRenderer.java:174)
48    at com.liferay.portal.layoutconfiguration.util.PortletRenderer$PortletRendererCallable.doCall(PortletRenderer.java:1)
49    at com.liferay.portal.kernel.executor.CopyThreadLocalCallable.call(CopyThreadLocalCallable.java:69)
50    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
51    at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:682)
52    at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:593)
53    at java.lang.Thread.run(Thread.java:744)


I tried setting the Locale manually using what is suggested at http://wiki.apache.org/myfaces/Liferay. Nothing seems to get rid of it. Below is an ugly version of my code if anyone wants to see it.

 1
 2package com.emergentspace.gems.web;
 3
 4import java.util.Locale;
 5import javax.faces.component.UIViewRoot;
 6import javax.faces.context.FacesContext;
 7import javax.faces.event.PhaseEvent;
 8import javax.faces.event.PhaseId;
 9import javax.faces.event.PhaseListener;
10
11/**
12 * Set the locale to solve NPE at com.liferay.faces.portal.lifecycle.LiferayLocalePhaseListener.setLocale(LiferayLocalePhaseListener.java:67)
13 * Parts copied from http://wiki.apache.org/myfaces/Liferay
14 */
15public class LocaleFixPhaseListener implements PhaseListener {
16
17    public PhaseId getPhaseId() {
18        return PhaseId.ANY_PHASE;
19    }
20
21    /**
22     * Called to update within Portlet environment the language of Portal.
23     *
24     * @see PhaseListener#beforePhase(javax.faces.event.PhaseEvent)
25     */
26    public void beforePhase(final PhaseEvent evt) {
27        //System.out.println("SETTING LOCALE IN FACES CONTEXT TO " + Locale.getDefault() + "; PhaseId=" + PhaseId.RENDER_RESPONSE);
28        //evt.getFacesContext().getViewRoot().setLocale(Locale.getDefault());
29       
30        //if (PhaseId.RENDER_RESPONSE.equals(evt.getPhaseId())) {
31            /*final Object request = evt.getFacesContext().getExternalContext().getRequest();
32            if (request instanceof RenderRequest) {
33                System.out.println("ACTUALLY SETTING LOCALE NOW!!!");
34                evt.getFacesContext().getViewRoot().setLocale(Locale.getDefault());
35                LocalizationUtil.getLocalization();
36            }*/
37        //}
38       
39        try {
40            FacesContext fc = evt.getFacesContext();
41            
42            if (fc == null) {
43                System.out.println("FACES CONTEXT IS NULL; " + evt);
44                return;
45            }
46            
47            System.out.println("renderResponse=" + fc.getRenderResponse() + ", renderComplete" + fc.getResponseComplete());
48            UIViewRoot view = fc.getViewRoot();
49            
50            if (view == null) {
51                System.out.println("FACES CONTEXT VIEW ROOT IS NULL; " + evt);
52                return;
53            }
54            
55            view.setLocale(Locale.getDefault());
56            System.out.println("SET LOCALE IN FACES CONTEXT TO " + Locale.getDefault() + "; PhaseId=" + PhaseId.RENDER_RESPONSE);
57        } catch (Exception e) {
58            System.out.println("FAILED TO SET LOCALE IN FACES CONTEXT TO " + Locale.getDefault() + "; PhaseId=" + PhaseId.RENDER_RESPONSE + "; " + e);
59            e.printStackTrace();
60        }
61    }
62
63    public void afterPhase(PhaseEvent event) {
64    }
65}


Is there any way to resolve this issue? Also, I see that there is only 1 open issue left on JIRA for 3.2.4. Is the planned release coming soon?

I was also looking at this issue: https://issues.liferay.com/browse/FACES-1252. Is there a way I can simply remove the LiferayLocalePhaseListener from the LifecycleFactoryImpl

Thanks,
Tim
Neil Griffin
RE: Liferay Faces 3.2.4-ga5 on TomEE+ 1.6.2 NPE in LiferayLocalePhaseListen
15 janvier 2014 07:32
Réponse

Neil Griffin

LIFERAY STAFF

Rang: Liferay Legend

Publications: 2350

Date d'inscription: 26 juillet 2005

Publications Récentes

Due to some portlet incompatibilities with MyFaces, we are currently not able to support MyFaces for JSF portlets.

I would recommend that you remove MyFaces from your TomEE installation and replace it with Mojarra. For more info, see the Upgrading Mojarra in Apache Tomcat wiki article.
Timothy Esposito
RE: Liferay Faces 3.2.4-ga5 on TomEE+ 1.6.2 NPE in LiferayLocalePhaseListen
15 janvier 2014 09:02
Réponse

Timothy Esposito

Rang: New Member

Publications: 6

Date d'inscription: 7 octobre 2012

Publications Récentes

Neil, Thanks for your response. I will give your suggestion a try. Ironically, my motivation for switching off of JBoss/Mojarra to TomEE+/MyFaces was that Mojarra seemed a bit flaky. We also have a similar setup on TomeEE+/MyFaces with Liferay 6.1 and it is running like a charm. It is also worth noting that I am using PrimeFaces 4.0.
Neil Griffin
RE: Liferay Faces 3.2.4-ga5 on TomEE+ 1.6.2 NPE in LiferayLocalePhaseListen
15 janvier 2014 09:28
Réponse

Neil Griffin

LIFERAY STAFF

Rang: Liferay Legend

Publications: 2350

Date d'inscription: 26 juillet 2005

Publications Récentes

Hi Timothy,

I just wanted to mention that Manfred Reim (one of the maintainers of Mojarra at Oracle) recently tweeted that the Mojarra bug count is down to zero. So if you run into any problems with Mojarra, please create a ticket. Since there are no open bugs left, any new bugs filed should get good visibility.

Kind Regards,

Neil
Timothy Esposito
RE: Liferay Faces 3.2.4-ga5 on TomEE+ 1.6.2 NPE in LiferayLocalePhaseListen
27 janvier 2014 11:27
Réponse

Timothy Esposito

Rang: New Member

Publications: 6

Date d'inscription: 7 octobre 2012

Publications Récentes

For reference, switching to Mojarra 2.1.27 with the suggested edits from the Liferay wiki page fixed the issue. Thank you for your help Neil.
Neil Griffin
RE: Liferay Faces 3.2.4-ga5 on TomEE+ 1.6.2 NPE in LiferayLocalePhaseListen
27 janvier 2014 12:25
Réponse

Neil Griffin

LIFERAY STAFF

Rang: Liferay Legend

Publications: 2350

Date d'inscription: 26 juillet 2005

Publications Récentes

It was my pleasure Timothy. Glad to hear that it is working for you now, and thanks for using Liferay Faces emoticon