Issue
I have downloaded Liferay 7.3.5 Community Edition from here and trying to deploy a HelloWorld portlet for testing purposes. It is bundled with Tomcat. I am using Liferay Developer Studio (the same old Eclipse on steroids) for developing and deploying the portlet. Version 3.8.1.202004240132-ga2 I have also created a Server like in this link - the server is using the tomcat 9.0.37 from the already downloaded bundle.
After steps above, I have followed steps from here to create a Module Project and to deploy it on the already started tomcat server. The portlet appears in the deployed section, but with a red "x" near it:
I went to add the portlet/widget in a widget page that I have created for this purpose, but I could not find the portlet:
Then, logged in with an admin user, I went to Control Panel -> App Manager and searched for my Portlet. It appears as "Installed" and I can activate it. After I hit "Activate", Eclipse logs start writing: ERROR [http-nio-8080-exec-8][PortletServlet:119] javax.portlet.PortletException: org.osgi.framework.BundleException: Could not resolve module: VictorTestPortlet [2716]_ Unresolved requirement: Import-Package: com.liferay.portal.kernel.portlet.bridges.mvc; version="[2.0.0,3.0.0)"_ [Sanitized]
The Question: what is causing this error ?
Solution
You found the complex solution yourself, there are two simpler ways:
Use the target platform. Assuming you're using Liferay Workspace, your gradle.properties in the root of your workspace has an entry
liferay.workspace.target.platform.version
. Set it to7.3.5
and the versions will be taken automagicallyHave even the required modules be detected automagically by setting the target platform, and declare your dependency as
dependencies { compileOnly group: "com.liferay.portal", name: "release.portal.api" }
This will even figure out the exact module (of more than 1000) that you need to depend on. Granted, it kind of works against the whole concept of modularization (to be aware of your dependencies), but it's soooo convenient.
Answered By - Olaf Kock