3

I've been transitioning a portlet from Liferay 6.2 to a bundle for Liferay 7. When I deploy it, it can't load, because of a missing resource:

$ blade sh diag 1084
diag 1084
org.mycompany.caasd.portal-ldap-sync [1084]
  Unresolved requirement: Import-Package: com.liferay.portal.kernel.service; 
version="[1.20.0,2.0.0)"

When I use Felix Gogo shell to see what's available, I don't see any kernel bundles. Is that a bundle I should be expecting to be installed, install myself, include in my bundle, or am I just not thinking about this the right way?

Sechanris
  • 232
  • 1
  • 9
  • This is an excellent question, I was wondering the same thing myself. – Yoshiya Aug 10 '17 at 16:02
  • havent confirmed that, as i see in https://dev.liferay.com/develop/reference/-/knowledge_base/7-0/breaking-changes , the subpackages exist, what about declaring the import like that 'com.liferay.portal.kernel.service.*', could you check whether it is a problem about the requested version ? – André Aug 11 '17 at 09:10

2 Answers2

1

The com.liferay.portal.kernel version for CE GA4 is 2.32.1. So if you were developing for CEGA4, with a gradle project, you'd configure the dependency in your project's build.gradle like this:

dependencies {
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.32.1"
}

You can find this by looking in the portal-kernel.jar file's MANIFEST/MANIFEST.MF or if you have the liferay src for your version, in any of its own modules build.gradle files. In my tomcat bundle, the portal-kernel.jar if in tomcat/lib/ext.

Unless I've misunderstood your question, that should get you what you want.

See the docs here for more information

Russ Bohl
  • 211
  • 1
  • 5
0

When you build your bundle, bnd will either

  • inspect your classpath and detect the package versions for you
  • use whatever versions you manually provide in Import-Package

In your case, it seams it somehow detected that the version of com.liferay.portal.kernel.service package is 1.20.0. It therefore generated the range "equal to or greater than current version but lower than next major version" which in your case is expressed as [1.20.0,2.0.0). That may have been because you had old jar on claspath or behacause you had wrong Import-Package statement.

This may compile just fine as long as you are nor using functionality that was added/changed in the newer version. At runtime though, the actual package version is higher (something like 2.32.1) and therefore it does not meet your requirement. As OSGi runtime can not resolve your bundle requirement, the bundle is left in "istalled" state!

To solve that you have two options:

  • install your bundle on older Liferay version (where com.liferay.portal.kernel.service package is between 1.20.0 and 2.0.0)
  • recompile your bundle making sure the classpath contains only those jars in which com.liferay.portal.kernel.service package has version that will generate a version range in which you runtime package version fits.
Milen Dyankov
  • 2,972
  • 14
  • 25