Foren

jsf cdi portlets with openWebBeans

mariateresa piselli, geändert vor 10 Jahren.

jsf cdi portlets with openWebBeans

New Member Beiträge: 2 Beitrittsdatum: 03.10.13 Neueste Beiträge
Hi all,

I tried out a liferay jsf cdi portlet using weld and it works properly (I configured the filter com.liferay.cdi.portlet.bridge.CDIPortletFilter in the portlet.xml and all the other stuff.), but I can't figure out a way to use openWebBeans since the container I have to use is tomee.

Any help will be appreciate.
Thank you.
Mariateresa
thumbnail
Neil Griffin, geändert vor 10 Jahren.

RE: jsf cdi portlets with openWebBeans

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Mariateresa,

Liferay, Inc. only provides a Tomcat bundle at this time, and not a TomEE bundle. Consequently we haven't done any testing with OpenWebBeans. However I think it is worth a try, since the Liferay CDI Portlet Bridge is working well with Resin CanDI.

I would recommend that you follow the steps outlined in Building Liferay Faces From Source, then follow these additional steps:

1. cd liferay-faces/demos/bridge/jsf2-cdi-portlet/src/main/webapp/WEB-INF
2. Copy the web-tomcat.xml file to a new file named web-tomee.xml
3. Remove the following references that are specific to JBoss Weld:
<filter>
                <filter-name>WeldCrossContextFilter</filter-name>
                <filter-class>org.jboss.weld.servlet.WeldCrossContextFilter</filter-class>
        </filter>
        <filter-mapping>
                <filter-name>WeldCrossContextFilter</filter-name>
                <url-pattern>/*</url-pattern>
                <dispatcher>INCLUDE</dispatcher>
                <dispatcher>FORWARD</dispatcher>
                <dispatcher>ERROR</dispatcher>
        </filter-mapping>
        <listener>
                <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
        </listener>

4. cd liferay-faces/demos/bridge/jsf2-cdi-portlet
5. Add a "tomee" maven profile to the pom.xml descriptor, and specify openwebbeans as a dependency.
6. mvn -P liferay,tomee clean package
7. Copy the resulting target/jsf2-cdi-portlet.war to the Liferay+TomEE /deploy folder

Kind Regards,

Neil
thumbnail
Vernon Singleton, geändert vor 10 Jahren.

RE: jsf cdi portlets with openWebBeans

Expert Beiträge: 315 Beitrittsdatum: 14.01.13 Neueste Beiträge
Hi Mariateresa,

You might also need to add something like this:
<listener>
        <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
</listener>

to your web.xml

Please let us know if you get this working, and how you configure it, I have not had time to work with openwebbeans yet.

- Vernon
mariateresa piselli, geändert vor 10 Jahren.

RE: jsf cdi portlets with openWebBeans

New Member Beiträge: 2 Beitrittsdatum: 03.10.13 Neueste Beiträge
Thank you for answering!

I tried using the following snippet of code in the web.xml

<filter>
                <filter-name>WebBeansConfigurationFilter</filter-name>
                <filter-class>org.apache.webbeans.servlet.WebBeansConfigurationFilter</filter-class>
        </filter>
        <filter-mapping>
                <filter-name>WebBeansConfigurationFilter</filter-name>
                <url-pattern>/*</url-pattern>
                <dispatcher>INCLUDE</dispatcher>
                <dispatcher>FORWARD</dispatcher>
                <dispatcher>ERROR</dispatcher>
        </filter-mapping>
	<listener>
        <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
	</listener>


and I got the following exception

SEVERE: Servlet.service() for servlet users Servlet threw exception
javax.portlet.faces.BridgeException: java.lang.ClassCastException: com.liferay.portlet.PortletSessionImpl cannot be cast to javax.servlet.http.HttpSession
	at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:193)
	at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:85)
	at com.liferay.faces.bridge.BridgeImpl.doFacesRequest(BridgeImpl.java:112)
	at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:255)
	at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
	at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:204)
	at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:103)
	at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:55)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
	at $Proxy933.doFilter(Unknown Source)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
	at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
	at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:73)
	at org.apache.webbeans.servlet.WebBeansConfigurationFilter.doFilter(WebBeansConfigurationFilter.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:79)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
	at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:602)
	at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:675)
	at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:382)
	at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1222)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:99)
	at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:78)
	at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
	at com.liferay.portal.util.PortalImpl.renderPortlet(PortalImpl.java:5749)
	at sun.reflect.GeneratedMethodAccessor481.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at com.liferay.portal.security.lang.DoPrivilegedHandler.doInvoke(DoPrivilegedHandler.java:88)
	at com.liferay.portal.security.lang.DoPrivilegedHandler.invoke(DoPrivilegedHandler.java:56)
	at $Proxy477.renderPortlet(Unknown Source)
	at com.liferay.portal.util.PortalUtil.renderPortlet(PortalUtil.java:1631)
	at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processPortlet(RuntimePortletImpl.java:181)
	at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processPortlet(RuntimePortletImpl.java:112)
	at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.doProcessTemplate(RuntimePortletImpl.java:536)
	at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.doDispatch(RuntimePortletImpl.java:401)
	at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processTemplate(RuntimePortletImpl.java:248)
	at com.liferay.portlet.layoutconfiguration.util.RuntimePortletImpl.processTemplate(RuntimePortletImpl.java:235)
	at sun.reflect.GeneratedMethodAccessor728.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at com.liferay.portal.security.lang.DoPrivilegedHandler.doInvoke(DoPrivilegedHandler.java:88)
	at com.liferay.portal.security.lang.DoPrivilegedHandler.invoke(DoPrivilegedHandler.java:56)
	at $Proxy485.processTemplate(Unknown Source)
	at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processTemplate(RuntimePortletUtil.java:126)
	at org.apache.jsp.html.portal.layout.view.portlet_jsp._jspService(portlet_jsp.java:507)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:73)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:79)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
	at com.liferay.portal.action.LayoutAction.includeLayoutContent(LayoutAction.java:471)
	at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:728)
	at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:243)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
	at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:176)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:559)
	at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:536)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:73)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
	at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:314)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
	at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:79)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
	at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:137)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:73)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
	at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:355)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
	at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:123)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
	at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:314)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
	at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:260)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
	at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
	at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:238)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:117)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at org.fao.psms.filter.PsmsLoginFilter.doFilter(PsmsLoginFilter.java:135)
	at sun.reflect.GeneratedMethodAccessor626.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
	at $Proxy857.doFilter(Unknown Source)


If I remove the openwebbeans configuration and I still keep CDI in the portlet, tomEE launch the usual exception
Caused by: javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread
	at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:351)
	at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualCreationalContext(NormalScopedBeanInterceptorHandler.java:169)
	at org.apache.webbeans.web.intercept.RequestScopedBeanInterceptorHandler.getContextualInstance(RequestScopedBeanInterceptorHandler.java:79)
	at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:114)
	at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:108)
	at org.apache.webbeans.conversation.ConversationImpl_$$_javassist_4.isTransient(ConversationImpl_$$_javassist_4.java)
	at org.apache.webbeans.jsf.WebBeansPhaseListener.beforePhase(WebBeansPhaseListener.java:106)
	at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:77)
	at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:158)
	at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
	at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:185)
	... 205 more


So I'm still not able to make it work.
Thank you for helping me.
thumbnail
Neil Griffin, geändert vor 10 Jahren.

RE: jsf cdi portlets with openWebBeans

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Mariateresa,

Regarding this error:

javax.portlet.faces.BridgeException: java.lang.ClassCastException: com.liferay.portlet.PortletSessionImpl cannot be cast to javax.servlet.http.HttpSession


It makes me think that perhaps the CDIPortletFilter is not being invoked. Please verify that it is present inside your WEB-INF/portlet.xml descriptor, like this:
https://github.com/liferay/liferay-faces/blob/master/demos/bridge/jsf2-cdi-portlet/src/main/webapp/WEB-INF/portlet.xml#L56

Kind Regards,

Neil
Martin Jonik, geändert vor 9 Jahren.

RE: jsf cdi portlets with openWebBeans

Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
Followed all the previous steps and the result is this:
_httpSession in HttpSessionWrapper is null. Error occurs when the portlet is accessed. Deployment process works without errors.

15:13:01,326 ERROR [ajp-bio-8109-exec-3][render_portlet_jsp:132] null
java.lang.NullPointerException
        at com.liferay.cdi.portlet.bridge.HttpSessionWrapper.getId(HttpSessionWrapper.java:52)
        at org.apache.openejb.cdi.CdiAppContextsService.initSessionContext(CdiAppContextsService.java:330)
        at org.apache.openejb.cdi.CdiAppContextsService.initRequestContext(CdiAppContextsService.java:260)
        at org.apache.openejb.cdi.CdiAppContextsService.startContext(CdiAppContextsService.java:206)
        at org.apache.webbeans.servlet.WebBeansConfigurationFilter.requestInitialized(WebBeansConfigurationFilter.java:159)
        at org.apache.webbeans.servlet.WebBeansConfigurationFilter.doFilter(WebBeansConfigurationFilter.java:115)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
        at com.liferay.cdi.portlet.bridge.CDICrossContextFilter.doFilter(CDICrossContextFilter.java:49)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:604)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:543)
        at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:604)
        at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:677)
        at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:379)
Martin Jonik, geändert vor 9 Jahren.

RE: jsf cdi portlets with openWebBeans

Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
one step further: this error ^^ happend because
CDICrossContextRequestImpl.getSession(boolean create)

was called with false, by whomever.

Now I got stuck at the same point like Maria with the ClassCastException.

CDIPortletListener is definitely invoked.

btw, the ClassCastException occurs here:

java.lang.ClassCastException: com.liferay.portlet.PortletSessionImpl cannot be cast to javax.servlet.http.HttpSession
        at org.apache.webbeans.jsf.JSFUtil.getSession(JSFUtil.java:59)
        at org.apache.webbeans.jsf.DefaultConversationService.getConversationSessionId(DefaultConversationService.java:37)
        at org.apache.webbeans.portable.ConversationProducer.newInstance(ConversationProducer.java:54)
        at org.apache.webbeans.portable.ConversationProducer.newInstance(ConversationProducer.java:31)
        at org.apache.webbeans.portable.InjectionTargetImpl.produce(InjectionTargetImpl.java:161)
        at org.apache.webbeans.portable.AbstractProducer.produce(AbstractProducer.java:182)
        at org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:121)
        at org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
        at org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:160)
        at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
        at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:100)
        at org.apache.webbeans.web.intercept.RequestScopedBeanInterceptorHandler.getContextualInstance(RequestScopedBeanInterceptorHandler.java:78)
        at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:70)
        at org.apache.webbeans.jsf.WebBeansPhaseListener.beforePhase(WebBeansPhaseListener.java:108)
        at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:185)
        at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:85)


OpenWebBeans is expecting a HttpSession to be returned from ExternalContext.getSession(), which in fact is allowed to return an Object and the portlet bridge returns a PortletSession.

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.openwebbeans/openwebbeans-jsf/1.2.5/org/apache/webbeans/jsf/JSFUtil.java?av=f
https://github.com/liferay/liferay-faces/blob/master/bridge-impl/src/main/java/com/liferay/faces/bridge/context/ExternalContextImpl.java

Neil, do you think the bridge will still work when I change the code that the HttpSession is returned and add a new method ExternalContext.getPortletSession() just for the bridges internal usage? Is anyone else from "outside" accessing the ExternalContext.getSession() method and expecting a PortletSession?
How do I get the HttpSession from PortletSession?
Martin Jonik, geändert vor 9 Jahren.

RE: jsf cdi portlets with openWebBeans

Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
it's me again. it took me almost 8 hours, but its finally working as I described in my previous post, at least at the first glance : )
thumbnail
Neil Griffin, geändert vor 9 Jahren.

RE: jsf cdi portlets with openWebBeans

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Martin

Just to clarify, are you saying that all is well?

Kind Regards,

Neil
Martin Jonik, geändert vor 9 Jahren.

RE: jsf cdi portlets with openWebBeans

Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
yes.. looks good so far.
I got a Primefaces 5, JSF2.1, CDI, EJB3 sample application running in Liferay 6.2.1 CE on TomEE 1.7.0 plume.

There are some minor frontend issues, but no error messages on the console. Since I have changed the return value of the getSession() method there should have already been some critical errors on it, am I right?
Maybe my application is too simple to run into all the issues that might occur with a more complex application.
What do you think could cause problems?
Martin Jonik, geändert vor 9 Jahren.

RE: jsf cdi portlets with openWebBeans

Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
I can confirm now: it's working perfectly that way.

Are there any plans to support OpenWebBeans in the future?
thumbnail
Neil Griffin, geändert vor 9 Jahren.

RE: jsf cdi portlets with openWebBeans

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Martin,

We don't have a Liferay+TomEE bundle, so OpenWebBeans is not supported at this time. This might change in the future for Liferay 7 though.

Kind Regards,

Neil
Eduard Korenschi, geändert vor 9 Jahren.

RE: jsf cdi portlets with openWebBeans

New Member Beiträge: 10 Beitrittsdatum: 24.02.10 Neueste Beiträge
Just to make a summary, I managed to start an average-size portlet with a similar configuration

1. Tomee 1.7.1 - plume (with JSF instead of MyFaces)
2. JSF 2.2.8-02 (upgraded from 2.1 that's defualt in Tomee)
3. Primefaces 5.1.1 (met a bug in 5.1.2 that uses a mobile render kit for a datatable and totally fails if you have a paginator)
4. Liferay faces 4.2.0-beta1-SNAPSHOT5
5. Liferay 6.2.1

Steps involved:

A. Create a Liferay - Tomee distribution

1. Create a folder LIFERAY. In the end we will have
LIFERAY/data
LIFERAY/deploy
LIFERAY/tomee
2. Unzip tomee inside LIFERAY
3. Get a Liferay 6.2.1 packaged with tomcat (http://sourceforge.net/projects/lportal/files/Liferay%20Portal/6.2.1%20GA2/) and unzip it somehere.
4. From tomcat's lib/ext folder copy: portlet.jar, portal-service.jar, ccpp.jar and the db driver according to your need into tomee/lib
5. Copy tomcat/conf/Catalina to tomee/conf
6. Copy tomcat/webapps/* to tomee/webapps (removing anything in there)

I think now you can start the liferay portal

B. Upgrade tomee components
You can (it seems safely) upgrade JSF in tomee by replacing the existing javax.faces.jar 2.1.29 to 2.2.8-02

C. Create a build of Liferay-Faces 4.2.0-beta1-SNAPSHOT by cloning the repository (you'll need to add some repository to your settings.xml as Liferay Faces for some reason depends on jboss-seam-el). Then locally install (with maven install:install-file using the -DlocalRepositoryPath parameter:
a. liferay-faces-bridge-api
b. liferay-faces-bridge-impl
c. liferay-faces-init
d. liferay-faces-portal
e. liferay-faces-util
f. primefaces-5.1.1

D. You'll have to patch your openwebbeans-jsf.jar (by cloning the git sources) and replace the method getSession() from JSFUtil with
public static HttpSession getSession()
    {
        ExternalContext externalContext = getExternalContext();

        if(externalContext != null)
        {
            Object request = externalContext.getRequest();
            if (request instanceof PortletRequest) { // Portlet Environment
                return PortalUtil.getHttpServletRequest((PortletRequest) request).getSession(true);
            } else { // assume it's HttpServlet environment
                return (HttpSession) externalContext.getSession(true);
            }
        }

        return null;
    }


E. I will post my pom.xml web.xml and portlet.xml for my portlet, for reference:
pom.xml
<!--?xml version="1.0" encoding="UTF-8"?-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelversion>4.0.0</modelversion>

    <groupid>com.computas.uefiscdi</groupid>
    <artifactid>uefiscdi-portlets</artifactid>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <project.build.sourceencoding>UTF-8</project.build.sourceencoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <org.primefaces.version>5.1.1</org.primefaces.version>
        <com.google.guava.version>18.0</com.google.guava.version>
        <com.liferay.faces>4.2.0-beta1-SNAPSHOT</com.liferay.faces>
        <com.liferay.portal>6.2.1</com.liferay.portal>
    </properties>


    <repositories>
        <repository>
            <id>lib</id>
            <name>lib</name>
            <url>file://${project.basedir}\lib</url>
        </repository>
    </repositories>

    <dependencies>

        <dependency>
            <groupid>javax</groupid>
            <artifactid>javaee-api</artifactid>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupid>org.primefaces</groupid>
            <artifactid>primefaces</artifactid>
            <version>${org.primefaces.version}</version>
        </dependency>

        <dependency>
            <groupid>commons-fileupload</groupid>
            <artifactid>commons-fileupload</artifactid>
            <version>1.3</version>
        </dependency>

        <dependency>
            <groupid>commons-io</groupid>
            <artifactid>commons-io</artifactid>
            <version>2.2</version>
        </dependency>

        <dependency>
            <groupid>com.google.guava</groupid>
            <artifactid>guava</artifactid>
            <version>${com.google.guava.version}</version>
        </dependency>

        <dependency>
            <groupid>org.hibernate</groupid>
            <artifactid>hibernate-entitymanager</artifactid>
            <version>4.3.5.Final</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupid>com.liferay.faces</groupid>
            <artifactid>liferay-faces-bridge-impl</artifactid>
            <version>${com.liferay.faces}</version>
        </dependency>
        <dependency>
            <groupid>com.liferay.faces</groupid>
            <artifactid>liferay-faces-bridge-api</artifactid>
            <version>${com.liferay.faces}</version>
        </dependency>
        <dependency>
            <groupid>com.liferay.faces</groupid>
            <artifactid>liferay-faces-portal</artifactid>
            <version>${com.liferay.faces}</version>
        </dependency>
        <dependency>
            <groupid>com.liferay.faces</groupid>
            <artifactid>liferay-faces-util</artifactid>
            <version>${com.liferay.faces}</version>
        </dependency>
        <dependency>
            <groupid>com.liferay.cdi</groupid>
            <artifactid>cdi-portlet-bridge-shared</artifactid>
            <version>6.2.0.2</version>
        </dependency>

        <dependency>
            <groupid>com.liferay.portal</groupid>
            <artifactid>portal-service</artifactid>
            <version>${com.liferay.portal}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupid>com.liferay.portal</groupid>
            <artifactid>util-java</artifactid>
            <version>${com.liferay.portal}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupid>javax.portlet</groupid>
            <artifactid>portlet-api</artifactid>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>


web.xml
<!--?xml version="1.0" encoding="UTF-8" standalone="yes"?-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

    <display-name>uefiscdi-portlets</display-name>

    <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/functions.taglib.xml</param-value>
    </context-param>

    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>

    <context-param>
        <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>

    <filter>
        <filter-name>WebBeansConfigurationFilter</filter-name>
        <filter-class>org.apache.webbeans.servlet.WebBeansConfigurationFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>WebBeansConfigurationFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <filter>
        <filter-name>CDICrossContextFilter</filter-name>
        <filter-class>com.liferay.cdi.portlet.bridge.CDICrossContextFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>CDICrossContextFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <listener>
        <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
    </listener>

    <listener>
        <listener-class>com.liferay.cdi.portlet.bridge.CDIContextListener</listener-class>
    </listener>


    <!-- Although the FacesServlet will not be invoked by any portlet requests, it is required to initialize JSF. -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <!-- MyFaces will not initialize unless a servlet-mapping to the Faces Servlet is present. -->

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

    <!-- Prevent direct access to Facelet view XHTML by the userAgent (browser). -->
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Facelet View XHTML</web-resource-name>
            <url-pattern>*.xhtml</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>nobody</role-name>
        </auth-constraint>
    </security-constraint>
    <security-role>
        <role-name>nobody</role-name>
    </security-role>

</web-app>


portlet.xml
<!--?xml version="1.0"?-->

<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">

    <portlet>
        <portlet-name>case-study-manager</portlet-name>
        <display-name>Case Study Manager</display-name>
        <portlet-class>
            javax.portlet.faces.GenericFacesPortlet
        </portlet-class>
        <init-param>
            <name>javax.portlet.faces.defaultViewId.view</name>
            <value>/case-study-manager.xhtml</value>
        </init-param>
        <expiration-cache>0</expiration-cache>
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>view</portlet-mode>
        </supports>
        <portlet-info>
            <title>Case Study Manager</title>
            <short-title>Case Study Manager</short-title>
            <keywords></keywords>
        </portlet-info>
        <security-role-ref>
            <role-name>administrator</role-name>
        </security-role-ref>
        <security-role-ref>
            <role-name>guest</role-name>
        </security-role-ref>
        <security-role-ref>
            <role-name>power-user</role-name>
        </security-role-ref>
        <security-role-ref>
            <role-name>user</role-name>
        </security-role-ref>
    </portlet>

    <filter>
        <filter-name>CDIPortletFilter</filter-name>
        <filter-class>com.liferay.cdi.portlet.bridge.CDIPortletFilter</filter-class>
        <lifecycle>ACTION_PHASE</lifecycle>
        <lifecycle>RENDER_PHASE</lifecycle>
        <lifecycle>RESOURCE_PHASE</lifecycle>
    </filter>
    <filter-mapping>
        <filter-name>CDIPortletFilter</filter-name>
        <portlet-name>case-study-manager</portlet-name>
    </filter-mapping>
</portlet-app>


Good luck everyone.
thumbnail
Neil Griffin, geändert vor 9 Jahren.

RE: jsf cdi portlets with openWebBeans

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Eduard,

Thanks so much for posting this helpful information! emoticon

Quick question for you -- did you get a chance to create a bug in the OpenWebBeans issue tracker for the getSession() patch you provided?

Kind Regards,

Neil
Martin Jonik, geändert vor 9 Jahren.

RE: jsf cdi portlets with openWebBeans

Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
Hey guys,

first, do you think it is OWB that is to be patched or is it the portlet bridge?

Second, I have noticed a strange behaviour on Tomee with OWB..
I have successfully deployed my Application and now I am restarting the server.

During the restart I receive the following error message:

a-jsf-shop]
Nov 11, 2014 9:37:18 AM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFO: Running on PrimeFaces 5.1
2014-11-11 09:37:18,685 [localhost-startStop-1] ERROR com.liferay.faces.portal.component.inputrichtext.InputRichTextRenderer - processEvent -
java.lang.NullPointerException
        at com.liferay.faces.portal.component.inputrichtext.internal.WYSIWYGTemplate.<init>(WYSIWYGTemplate.java:37)
        at com.liferay.faces.portal.component.inputrichtext.InputRichTextRenderer.processEvent(InputRichTextRenderer.java:260)
        at javax.faces.event.SystemEvent.processListener(SystemEvent.java:108)
        at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2190)
        at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2163)
        at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:303)
        at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:739)
        at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:739)
        at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:739)
        at com.sun.faces.config.ConfigManager.publishPostConfigEvent(ConfigManager.java:692)
        at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:260)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4990)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5490)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Nov 11, 2014 9:37:18 AM org.apache.catalina.start</init>


When I access the application I receive this error message:
java.lang.NullPointerException
        at com.liferay.faces.util.config.ApplicationConfigInitializerImpl.newResourceReader(ApplicationConfigInitializerImpl.java:90)
        at com.liferay.faces.util.config.ApplicationConfigInitializerImpl.initialize(ApplicationConfigInitializerImpl.java:48)
        at com.liferay.faces.util.config.ApplicationConfigUtil.initializeApplicationConfig(ApplicationConfigUtil.java:38)
        at com.liferay.faces.bridge.BridgeImpl.init(BridgeImpl.java:168)
        at javax.portlet.faces.GenericFacesPortlet.init(GenericFacesPortlet.java:92)
        at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:269)
        at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:228)
        at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:145)
        at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:41)
        at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:639)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:57)
        at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:78)
        at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
        at com.liferay.portlet.PortletContainerImpl._doRender(PortletContainerImpl.java:655)
        at com.liferay.portlet.PortletContainerImpl.render(PortletContainerImpl.java:138)
        at com.liferay.portlet.SecurityPortletContainerWrapper.render(SecurityPortletContainerWrapper.java:141)
        at com.liferay.portlet.RestrictPortletContainerWrapper.render(RestrictPortletContainerWrapper.java:126)
        at com.liferay.portal.kernel.portlet.PortletContainerUtil.render(PortletContainerUtil.java:156)
        at com.liferay.portal.layoutconfiguration.util.PortletRenderer._render(PortletRenderer.java:120)
        at com.liferay.portal.layoutconfiguration.util.PortletRenderer.render(PortletRenderer.java:72)
        at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.doProcessTemplate(RuntimePageImpl.java:460)
        at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.doDispatch(RuntimePageImpl.java:284)
        at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.processTemplate(RuntimePageImpl.java:113)
        at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.processTemplate(RuntimePageImpl.java:124)
        at com.liferay.portal.layoutconfiguration.util.RuntimePageUtil.processTemplate(RuntimePageUtil.java:69)
        at org.apache.jsp.html.portal.layout.view.portlet_jsp._jspService(portlet_jsp.java:548)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:604)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:543)
        at com.liferay.portal.action.LayoutAction.includeLayoutContent(LayoutAction.java:280)
        at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:383)
        at com.liferay.portal.action.LayoutAction.doExecute(LayoutAction.java:178)
        at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:79)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:173)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
        at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:546)
        at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:523)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)


I redeploy the application which works well, try to access it and I receive this error message:

09:42:31,849 ERROR [ajp-bio-8109-exec-4][render_portlet_jsp:132] null
java.util.NoSuchElementException
        at java.util.HashMap$HashIterator.nextEntry(HashMap.java:929)
        at java.util.HashMap$KeyIterator.next(HashMap.java:960)
        at com.liferay.cdi.portlet.bridge.CDIBeanManagerUtil.getManagedBeanReference(CDIBeanManagerUtil.java:38)
        at com.liferay.cdi.portlet.bridge.CDIPortletFilter.getCDIRequestFactory(CDIPortletFilter.java:136)
        at com.liferay.cdi.portlet.bridge.CDIPortletFilter.doFilter(CDIPortletFilter.java:98)
        at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
        at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
        at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
        at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:112)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at org.apache.webbeans.servlet.WebBeansConfigurationFilter.doFilter(WebBeansConfigurationFilter.java:118)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
        at com.liferay.cdi.portlet.bridge.CDICrossContextFilter.doFilter(CDICrossContextFilter.java:49)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:96)


I redeploy the application the second time, and now everything works fine. No more error message, I can redeploy as many times as I want, but when I restart the server, all the errors come back until I have reployed the application twice...
Do you face the same problem like me?

I am running on Tomee 1.7.1 Plume with JSF 2.2 and Primefaces 5.1, jsf-portlet-bridge 4.20-m2, almost the same setup like Eduard, but I patched the Portlet Bridge instead of OWB.
thumbnail
Neil Griffin, geändert vor 9 Jahren.

RE: jsf cdi portlets with openWebBeans

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Martin,

I think that the NullPointerException in com.liferay.faces.portal.component.inputrichtext.internal.WYSIWYGTemplate is caused by [FACES-2036|https://issues.liferay.com/browse/FACES-2036] which was just fixed in the master branch and 3.2.x branch today.

Kind Regards,

Neil
thumbnail
arun vc, geändert vor 8 Jahren.

RE: jsf cdi portlets with openWebBeans

New Member Beiträge: 5 Beitrittsdatum: 24.06.14 Neueste Beiträge
when are you planning to release 4.2.0-m3 jar
thumbnail
Neil Griffin, geändert vor 8 Jahren.

RE: jsf cdi portlets with openWebBeans

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Our goal is to release Liferay Faces 4.2.0-m3 by Friday April 17. Our original goal was to have the production release ready by the end of Q1 2015 but we needed some more time to finish some of the components (alloy:dataTable, alloy:paginator, portal:captcha) and to improve the overall quality of the release.
Michael Rohleder, geändert vor 8 Jahren.

RE: jsf cdi portlets with openWebBeans

New Member Beiträge: 19 Beitrittsdatum: 31.07.13 Neueste Beiträge
Iam playing around with tomee the last couple of days, and iam really impressed how nice, good and easy lr runs.
(esp. compared to some wildfly experience i had some month ago, trying to get lr running...).

Now Iam facing the some problem Martin and Eduard had, tryin to use cdi and jsf (2.1):

java.lang.ClassCastException: com.liferay.portlet.PortletSessionImpl cannot be cast to javax.servlet.http.HttpSession
at org.apache.webbeans.jsf.JSFUtil.getSession(JSFUtil.java:59)
at org.apache.webbeans.jsf.DefaultConversationService.getConversationSessionId(DefaultConversationService.java:37)
at org.apache.webbeans.portable.ConversationProducer.newInstance(ConversationProducer.java:54)
at org.apache.webbeans.portable.ConversationProducer.newInstance(ConversationProducer.java:31)
at org.apache.webbeans.portable.InjectionTargetImpl.produce(InjectionTargetImpl.java:161)
at org.apache.webbeans.portable.AbstractProducer.produce(AbstractProducer.java:182)
at org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:121)
at org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
at org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:160)
at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:100)
at org.apache.webbeans.web.intercept.RequestScopedBeanInterceptorHandler.getContextualInstance(RequestScopedBeanInterceptorHandler.java:78)
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:70)
at org.apache.webbeans.jsf.WebBeansPhaseListener.beforePhase(WebBeansPhaseListener.java:108)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:185)
at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:85)

Eduard patched the openwebbeans JSFUtil with a call to PortalUtil and I think thats a bad idea (but hey, nice hack to get it running ^^).

Martin, you said, you patched the portal-bridge. Do you have a patch (or a pull request to neil ^^) ?


regards
mike
Martin Jonik, geändert vor 8 Jahren.

RE: jsf cdi portlets with openWebBeans

Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
Hi Mike,
this is the patch for the liferay-faces-bridge-impl-4.2.0-m2 which is the cause of the stacktrace you have posted.

diff --git a/bridge-impl/src/main/java/com/liferay/faces/bridge/context/ExternalContextImpl.java b/bridge-impl/src/main/java/com/liferay/faces/bridge/context/ExternalContextImpl.java
index 1c40b61..6586868 100644
--- a/bridge-impl/src/main/java/com/liferay/faces/bridge/context/ExternalContextImpl.java
+++ b/bridge-impl/src/main/java/com/liferay/faces/bridge/context/ExternalContextImpl.java
@@ -35,6 +35,7 @@
 import javax.portlet.StateAwareResponse;
 import javax.portlet.faces.BridgeWriteBehindResponse;
 import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponseWrapper;
 
 import com.liferay.faces.bridge.application.ViewHandlerImpl;
@@ -48,6 +49,7 @@
 import com.liferay.faces.util.logging.LoggerFactory;
 import com.liferay.faces.util.product.ProductConstants;
 import com.liferay.faces.util.product.ProductMap;
+import com.liferay.portal.util.PortalUtil;
 
 
 /**
@@ -691,7 +693,9 @@
 	 */
 	@Override
 	public Object getSession(boolean create) {
-		return portletRequest.getPortletSession(create);
+		PortletSession ps = portletRequest.getPortletSession(create);
+		HttpServletRequest httpreq1 = PortalUtil.getHttpServletRequest(portletRequest);
+		return httpreq1.getSession();
 	}
 


... and I also had to patch the cdi-portlet-bridge-shared-6.2.x, otherwise the "create session flag" was always false, so what I simply do is passing true with every call.

diff --git a/shared/cdi-portlet-bridge-shared/src/com/liferay/cdi/portlet/bridge/CDICrossContextRequestImpl.java b/shared/cdi-portlet-bridge-shared/src/com/liferay/cdi/portlet/bridge/CDICrossContextRequestImpl.java
index 70a0d3d..7602194 100644
--- a/shared/cdi-portlet-bridge-shared/src/com/liferay/cdi/portlet/bridge/CDICrossContextRequestImpl.java
+++ b/shared/cdi-portlet-bridge-shared/src/com/liferay/cdi/portlet/bridge/CDICrossContextRequestImpl.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the Free
@@ -32,11 +32,9 @@
 			HttpServletRequest httpServletRequest = getRequest();
 
 			HttpSession httpSession = new CDICrossContextSessionImpl(
-				httpServletRequest.getSession(create));
+				httpServletRequest.getSession(true));
 
-			if (create) {
 				_httpSession = httpSession;
-			}
 
 			return httpSession;
 		}


Actually I have no idea if these changes will break the code under certain circumstances, but I am running productivly on tomee-plume-1.7.1 with JSF 2.2 and all kinds of fancy stuff.
It only works for me, when the libs (cdi-bridge and faces-bridge-impl) are within the WEB-INF/lib directory of the webapp. Otherwise I have experienced class loader issues.

Cheers,
Martin
Michael Rohleder, geändert vor 8 Jahren.

RE: jsf cdi portlets with openWebBeans

New Member Beiträge: 19 Beitrittsdatum: 31.07.13 Neueste Beiträge
Hi Martin,

wow, thank you very, very much for your work!

Iam runnning plume 1.7.1 with faces-bridge 3.2.4ga5 on our test/integration/staging machine for some days
and everything looks good, so I will also go productive with it...

A question about the second patch you posted (cdi-bridge):
What is the result/consequence if the "session flag" is always false?

Also, a question to Neil:
Do you have an idea, if these patches will break something?
Does the spec say something about what kind of Object the result from getSession() is supposed to be?


regards
mike
Martin Jonik, geändert vor 8 Jahren.

RE: jsf cdi portlets with openWebBeans

Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
I am using JSF together with CDI. This requires the cdi-portlet-bridge.
I got a NullPointerException with every request because the CDICrossContextRequestImpl.getSession(boolean create) method returned null.
This method will only create a session if it is called with true and otherwise it will return the existing session or null, if the session has not yet been created.
On TomEE this method has never been invoked with true, therefore the session has never been created which caused the NPE.
The problem seems to be somewhere else. The method should be called with true at least once per session, but this was the easiest way for me to fix it.
thumbnail
Neil Griffin, geändert vor 8 Jahren.

RE: jsf cdi portlets with openWebBeans

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Mike,

Michael Rohleder:
Also, a question to Neil:
Do you have an idea, if these patches will break something?
Does the spec say something about what kind of Object the result from getSession() is supposed to be?


First, many thanks to Martin for contributing his patches here in the forums.

While his fix to the bridge's ExternalContextImpl. getSession(boolean) method makes OpenWebBeans happy, I think it is (in a sense) masking a bug that exists in org.apache.webbeans.jsf.DefaultConversationService.getConversationSessionId() such that it should be calling ExternalContext.getSessionId(boolean create) instead of ((HttpSession)ExternalContext.getSession(create)).getId(). However, that method is new in JSF 2.2 and consequently won't work with JSF 2.1. Regardless, I am surprised that this is a problem, because CDICrossContextRequestImpl. getSession(boolean create) returns an instance of CDICrossContextSessionImpl which extends CDICrossContextSession which in turn extends HttpSessionWrapper and should avoid the ClassCastException.

Regarding his second fix to CDICrossContextRequestImpl.getSession(boolean create), I would like to know more as to why OpenWebBeans is always passing false. If it needs to get the sessionId, then shouldn't OpenWebBeans be passing true?

Kind Regards,

Neil
Martin Jonik, geändert vor 8 Jahren.

RE: jsf cdi portlets with openWebBeans

Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
So... We are talking about two different problems, yes?

The first is just about the Portlet-Bridge (JSF 2.1 and 2.2). The problem also occurs when the Cdi-Bridge is not involved.
The Portlet-Bridge returns a PortletSession and OpenWebBeans tries to cast it to a HttpSession which is not possible, because PortletSession !(instanceof HttpSession)
The Interface's getSession() method allows to return a java.lang. Object. So who is right here?

The second problem is about the Cdi-Bridge. The getSession(boolean) method is called by whomsoever, but the Cdi-Bridge does not return the Session.
A session should already exist, because I am already logged into the Portal. Therefore "whomsoever" does not need to call the getSession(boolean) method with True. Why is the existing Session not been returned?
And why is it returned after the method has been "manually" (with the patch) called with true? Because Cdi does not open a new session. It will return the existing Session, that has been created by the Portal.
thumbnail
Neil Griffin, geändert vor 8 Jahren.

RE: jsf cdi portlets with openWebBeans

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Martin,

Martin Jonik:
The Interface's getSession() method allows to return a java.lang. Object. So who is right here?

The new JSF 2.2 ExternalContext.getSessionId(boolean) method should be used by OpenWebBeans in a Java EE 7 (JSF 2.2) environment. In a Java EE 6 (JSF 2.1/2.0) environment, OpenWebBeans would need to use reflection to find a "getId" no-arg method that returns a String. The method would either be HttpSession.getId() or PortletSession.getId().

Martin Jonik:
Why is the existing Session not been returned? And why is it returned after the method has been "manually" (with the patch) called with true? Because Cdi does not open a new session. It will return the existing Session, that has been created by the Portal.

Apologies, but don't know the answer because we don't test OpenWebBeans in our QA process and I don't have an environment setup to try this. If you have time, I recommend that you set a breakpoint in CDICrossContextRequestImpl.getSession(boolean) to see what the problem is. Perhaps we can implement a fix based on your findings.

Kind Regards,

Neil