added a comment - - edited
I spent some time today testing JSF2 + CDI (Weld 1.1.7) in Liferay 6.1.0.
I wasn't able to get it working with Tomcat 7 because it caused the following stacktrace:
java.lang.IllegalStateException: Must call associate() before calling activate()
at org.jboss.weld.context.AbstractConversationContext.activate(AbstractConversationContext.java:277)
at org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:110)
at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:84)
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)
I wasn't able to get it working with GlassFish 3.1.1 either. It had the same stacktrace as Tomcat. It turns out that GlassFish bundles weld-osgi-bundle-1.1.1.Final.jar which doesn't contain the fix for WELD-510. When I tried to upgrade GlassFish to weld-osgi-bundle-1.1.7.Final.jar it started throwing NoClassDefFound exceptions:
org.jboss.weld.exceptions.WeldException: by java.lang.NoClassDefFoundError: org/jboss/weld/interceptor/proxy/LifecycleMixin
at org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:282)
at org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:236)
at org.jboss.weld.bean.builtin.ee.AbstractEEBean.<init>(AbstractEEBean.java:43)
at org.jboss.weld.bean.builtin.ee.UserTransactionBean.<init>(UserTransactionBean.java:52)
at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:190)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:350)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:170)
I tried to get it working in the Liferay+JBoss bundle, but it comes bundled with JBoss AS 7.0.2 which doesn't work with JSF 2.1. Finally I was only able to get it working in JBoss AS 7.1.1 – I had to install the Liferay Portal WAR into JBoss AS 7.1.1 manually. Although the portlet worked with @Inject on the initial render, I wasn't able to navigate from one Facelet view to another without getting an exception thrown by Weld:
16:11:34,534 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-4) Error Rendering View[/views/portletViewMode.xhtml]: javax.enterprise.context.ContextNotActiveException: Conversation Context not active when method called on conversation Transient conversation
at org.jboss.weld.context.conversation.ConversationImpl.verifyConversationContextActive(ConversationImpl.java:197) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.context.conversation.ConversationImpl.isTransient(ConversationImpl.java:149) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.jsf.ConversationAwareViewHandler.getActionURL(ConversationAwareViewHandler.java:102) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at com.sun.faces.renderkit.html_basic.FormRenderer.getActionStr(FormRenderer.java:232) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.renderkit.html_basic.FormRenderer.encodeBegin(FormRenderer.java:135) [jsf-impl-2.1.7-jbossorg-2.jar:]
As a part of this issue, I would think that testing the Seam Faces module is also required. This is because if you want to use JSF2 @ViewScoped in combination with Weld, you would need to add the Seam Faces module. Unfortunately SEAMFACES-222 is preventing Seam Faces from working in portlet environments.
I spent some time today testing JSF2 + CDI (Weld 1.1.7) in Liferay 6.1.0.
I wasn't able to get it working with Tomcat 7 because it caused the following stacktrace:
I wasn't able to get it working with GlassFish 3.1.1 either. It had the same stacktrace as Tomcat. It turns out that GlassFish bundles weld-osgi-bundle-1.1.1.Final.jar which doesn't contain the fix for WELD-510. When I tried to upgrade GlassFish to weld-osgi-bundle-1.1.7.Final.jar it started throwing NoClassDefFound exceptions:
I tried to get it working in the Liferay+JBoss bundle, but it comes bundled with JBoss AS 7.0.2 which doesn't work with JSF 2.1. Finally I was only able to get it working in JBoss AS 7.1.1 – I had to install the Liferay Portal WAR into JBoss AS 7.1.1 manually. Although the portlet worked with @Inject on the initial render, I wasn't able to navigate from one Facelet view to another without getting an exception thrown by Weld:
As a part of this issue, I would think that testing the Seam Faces module is also required. This is because if you want to use JSF2 @ViewScoped in combination with Weld, you would need to add the Seam Faces module. Unfortunately SEAMFACES-222 is preventing Seam Faces from working in portlet environments.