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: @RequestScoped JSF Bean exception
I tried using
<span style="">javax.enterprise.context.RequestScoped</span>
in
combination with javax.inject.Named
annotation on my
backing bean but I get the following exception:
WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped
There is no way I can get it to work. It works just fine
with javax.faces.view.ViewScoped
, but this scope is
unnecessary for most of my portlets and is only wasting memory. Could
it be that Liferay JSF doesn't support CDI RequestScoped beans at all?
I investigated and searched for this info, but couldn't find the answer.
Hi Pavle,
I'm the developer that is working on integration of CDI scopes within Liferay's portlet container implementation. What version of Liferay Portal are you using? Also, do you have WEB-INF/weld-servlet.jar embedded in your JSF portlet WAR?
Thanks,
Neil
thank you for replying and sorry for my late reply. I still have this problem.
I'm using Liferay v7.1, and yes, I do have weld-servlet dependency jar inside my generated.war/WEB-INF/lib. The maven dependency:
<dependency>
<groupid>org.jboss.weld.servlet</groupid>
<artifactid>weld-servlet</artifactid>
<version>2.3.3.Final</version>
</dependency>
Could it be the version, or do I need some additional configuration to make it work?
I got the same error, because I forgot to set the appropriate config in web.xml.
However ViewScoped beans were still working....
<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>
Cheers
Abraham
This solved the problem, and now I can use RequestScoped beans. Turns I had this configuration before in web.xml but I deleted it because I was thinking it was not necessary since my ViewScoped beans worked.
Powered by Liferay™