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: Contexts and Dependency Injection for JSF Portlets
I'm missing an updated article on contexts and dependency injection for JSF portlets using Liferay 7.x / DXP 7.x. I'm looking which version of weld-servlet I should use running Liferay DXP 7.1. The liferayfaces.org site is very helpful to find the correct versions for the Liferay Faces artifacts in this case: https://faces.liferay.dev/home/-/archetype-portlet/liferay-portal-version/7.1/jsf-version/2.2/component-suite/primefaces/build-tool/gradle (com.liferay.faces.bridge.impl version: 4.1.4)
At the github repository you will find a demo JSF CDI applicant portlet (https://github.com/liferay/liferay-faces-bridge-impl/tree/4.1.4/demo/jsf-cdi-applicant-portlet ) which uses weld-servlet-2.3.3.Final.jar if you build it using the Liferay and Tomcat profile.
Is there a reason in using version 2.3.3.Final? Is it also ok to use version 2.3.5.Final or the 2.4.x versions (see https://mvnrepository.com/artifact/org.jboss.weld.servlet/weld-servlet)?
At the github repository you will find a demo JSF CDI applicant portlet (https://github.com/liferay/liferay-faces-bridge-impl/tree/4.1.4/demo/jsf-cdi-applicant-portlet ) which uses weld-servlet-2.3.3.Final.jar if you build it using the Liferay and Tomcat profile.
Is there a reason in using version 2.3.3.Final? Is it also ok to use version 2.3.5.Final or the 2.4.x versions (see https://mvnrepository.com/artifact/org.jboss.weld.servlet/weld-servlet)?
Currently we are using Liferay DXP 7.1 with Tomcat 9.0.33. According to the weld documentation (https://weld.cdi-spec.org/documentation/) the older versions 2.3.x (see https://docs.jboss.org/weld/reference/2.3.5.Final/en-US/html/environments.html#_tomcat) and 2.4.x (see https://docs.jboss.org/weld/reference/2.4.8.Final/en-US/html/gettingstarted.html#_deploying_to_apache_tomcat) supports Tomcat 7 and 8. For Tomcat 9 the Weld 3.1.x seems to be the correct version (https://docs.jboss.org/weld/reference/latest-3.1/en-US/html/environments.html#_tomcat). Weld 3.1.x supports JSF 2.3, but the Liferay Faces implementation currently only JSF 2.2. My question is, if Weld 3.1.x can be used for JSF protlets running under Tomcat 9.0.33.
In general in the above environment (Liferay DXP 7.1 running under Tomcat 9.0.33 patch level dxp-18-7110) targeting JSF, CDI, Liferay Faces and Primefaces we use currently:
compile group: "org.glassfish", name: "javax.faces", version:"2.2.20"compile group: "org.jboss.weld.servlet", name: "weld-servlet", version: "2.4.8.Final"compile group: "com.liferay.faces", name: "com.liferay.faces.bridge.ext", version:"5.0.5"
compile group: "com.liferay.faces", name: "com.liferay.faces.bridge.impl", version:"4.1.4"
compile group: "com.liferay.faces", name: "com.liferay.faces.portal", version:"3.0.5"
compile group: "com.liferay.faces", name: "com.liferay.faces.util", version:"3.3.0"compile group: "org.primefaces", name: "primefaces", version:"7.0.14"
I run into some problems using different mojarra / weld version within different portlets all running within the same Liferay DXP instance. The problems are related to CDI and Dropdown menus using enum classes. After startup somtimes there were exceptions . This was the reason for me to spend some time to consolidate the JSF, CDI, Liferay Faces and Primefaces dependencies and versions. All dependencies are well documented in Liferayfaces.org (https://faces.liferay.dev/home/-/archetype-portlet/liferay-portal-version/7.1/jsf-version/2.2/component-suite/primefaces/build-tool/gradle) with the exemption of CDI (and com.liferay.faces.portal we use to get the site group).
compile group: "org.glassfish", name: "javax.faces", version:"2.2.20"compile group: "org.jboss.weld.servlet", name: "weld-servlet", version: "2.4.8.Final"compile group: "com.liferay.faces", name: "com.liferay.faces.bridge.ext", version:"5.0.5"
compile group: "com.liferay.faces", name: "com.liferay.faces.bridge.impl", version:"4.1.4"
compile group: "com.liferay.faces", name: "com.liferay.faces.portal", version:"3.0.5"
compile group: "com.liferay.faces", name: "com.liferay.faces.util", version:"3.3.0"compile group: "org.primefaces", name: "primefaces", version:"7.0.14"
I run into some problems using different mojarra / weld version within different portlets all running within the same Liferay DXP instance. The problems are related to CDI and Dropdown menus using enum classes. After startup somtimes there were exceptions . This was the reason for me to spend some time to consolidate the JSF, CDI, Liferay Faces and Primefaces dependencies and versions. All dependencies are well documented in Liferayfaces.org (https://faces.liferay.dev/home/-/archetype-portlet/liferay-portal-version/7.1/jsf-version/2.2/component-suite/primefaces/build-tool/gradle) with the exemption of CDI (and com.liferay.faces.portal we use to get the site group).
Hi Michael,
Liferay 7.1, 7.2, and 7.3 all ship with weld-osgi-bundle-3.0.5.jar so I think you are safe to use the equivalent version of weld-servlet.jar in WEB-INF/lib.
Did you happen to see my recent tweet about the good results I'm seeing with "thin" CDI + JSF portlets?
This will provide for the ability to rely on weld-osgi-bundle via CDI + OSGi Integration so that your portlets don't have to include WEB-INF/weld-servlet.jar anymore.
I hope to be pushing commits from my local to the various Liferay Faces git repos later this week. Hopefully we can get a release out the door by the end of July or by mid-August.
Best Regards,
Neil
Liferay 7.1, 7.2, and 7.3 all ship with weld-osgi-bundle-3.0.5.jar so I think you are safe to use the equivalent version of weld-servlet.jar in WEB-INF/lib.
Did you happen to see my recent tweet about the good results I'm seeing with "thin" CDI + JSF portlets?
This will provide for the ability to rely on weld-osgi-bundle via CDI + OSGi Integration so that your portlets don't have to include WEB-INF/weld-servlet.jar anymore.
I hope to be pushing commits from my local to the various Liferay Faces git repos later this week. Hopefully we can get a release out the door by the end of July or by mid-August.
Best Regards,
Neil
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™