Foren

Liferay 6.2 CDI on Tomcat ViewScoped Bean causes WELD-001414 error

René Hengstermann, geändert vor 7 Jahren.

Liferay 6.2 CDI on Tomcat ViewScoped Bean causes WELD-001414 error

New Member Beiträge: 8 Beitrittsdatum: 29.08.15 Neueste Beiträge
Hello Faces Experts,

currently we are facing some Problems with deployment of portlets, which use the same name for a bean.

Our scenario is the following:
  • Liferay 6.2 on Tomcat
  • Liferay Faces 4.2.5-ga6
  • Portlets in Seperate .war
  • weld-servlet.jar deployed with each Portlet
  • Both portlets contain this bean:
    @Named
    @ViewScoped 
    public class ViewBackingBean implements Serializable {
  • On deployment the following error occures:
    Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001414 Bean name is ambiguous. Name viewBackingBean resolves to beans [Managed Bean [class de.liferay.portlet.cdi_named_b_portlet.ui.ViewBackingBean] with qualifiers [@Default @Any @Named], Managed Bean [class de.liferay.portlet.cdi_named_a_portlet.ui.ViewBackingBean] with qualifiers [@Default @Any @Named]]
            at org.jboss.weld.bootstrap.Validator.validateBeanNames(Validator.java:476)
            at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:373)
            at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
            at org.jboss.weld.environment.servlet.Listener.contextInitialized(Listener.java:182)
            at com.liferay.portal.kernel.servlet.SecurePluginContextListener.instantiatingListener(SecurePluginContextListener.java:360)
            at com.liferay.portal.kernel.servlet.SecurePluginContextListener.instantiatingListeners(SecurePluginContextListener.java:163)
            ... 30 more


Is this a expected behavior or do i miss some configuration?

Best regards,
René
thumbnail
Neil Griffin, geändert vor 7 Jahren.

RE: Liferay 6.2 CDI on Tomcat ViewScoped Bean causes WELD-001414 error

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

Your scenario description indicates that you designed things correctly. But there might be a configuration problem.

What is the contents of your WEB-INF/liferay-portlet.xml descriptor? Perhaps you have the following?
<private-session-attributes>false</private-session-attributes>


Kind Regards,

Neil
René Hengstermann, geändert vor 7 Jahren.

RE: Liferay 6.2 CDI on Tomcat ViewScoped Bean causes WELD-001414 error

New Member Beiträge: 8 Beitrittsdatum: 29.08.15 Neueste Beiträge
Hello Neil,

currently we dont have added that parameter to our portlet descriptor.

But i've seen that weld itself is static by default, maybe that causes my problems (weld documentation,chp. 18.3. Servlet containers (such as Tomcat or Jetty)):

When working with multiple deployments in servlet environment, Weld Servlet allows to define context identifier per application deployed. Each different context identifier will create a new Weld container instance. If not specified, Weld falls back to the default value - STATIC_INSTANCE. While using custom identifiers is neither required nor commonly used, it certainly has some use-cases. For instance managing several deployments with Arquillian Tomcat container. Setting the identifier is as simple as adding one context parameter into web.xml:

<context-param>
<param-name>WELD_CONTEXT_ID_KEY</param-name>
<param-value>customValue</param-value>
</context-param>

thumbnail
Neil Griffin, geändert vor 7 Jahren.

RE: Liferay 6.2 CDI on Tomcat ViewScoped Bean causes WELD-001414 error

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

After you set WELD_CONTEXT_ID_KEY in your WEB-INF/web.xml descriptor, did the problem go away?

Thank you,

Neil
René Hengstermann, geändert vor 7 Jahren.

RE: Liferay 6.2 CDI on Tomcat ViewScoped Bean causes WELD-001414 error (Antwort)

New Member Beiträge: 8 Beitrittsdatum: 29.08.15 Neueste Beiträge
Hello Neil,

the parameter had nothing to do with the CDI scoping.
At least if i set it to the same value in both portlets...

But I reproduced this exception with a portlet hot deployment after the package of the bean was renamed.
I think the "old" bean was still active and therefore the coliision happened.

Thanks for your Time!

Best regards,
René