Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-67440

Wrong Java EE version (1.7) assumed/imposed on LPKG validation

    Details

    • Type: Bug
    • Status: Verified
    • Resolution: Unresolved
    • Affects Version/s: 7.0.1 CE GA2
    • Fix Version/s: None
    • Component/s: App Management
    • Labels:
      None
    • Fix Priority:
      3

      Description

      To test the quality of an LPKG a reference, fictitious environment is used, instead of the running one. While this makes the validation predictable and reproducible, keeping this environment aligned with current specs can be troublesome.

      The issue

      In fact, in Liferay 7.0 (and currently on master too) the environment is assumed to use Java EE 1.7 and tests for compatibility for that JRE, but:

      • Liferay 7 officially targets a Java 8 runtime (please refer to "Target the Appropriate Java JRE" paragraph in this documentation page);
      • Liferay IDE requires Java 8;
      • Liferay Workspaces built with Blade create modules with Java 8 by default.

      The faulty implementation is in DefaultIndexValidator in the portal-target-platform-indexer bundle, where EE.JavaSE_1_7 is set as resourceBuilder.addEE(...).

      Impact

      The problem is that this issue prevents bundles to be submitted as-is to the Marketplace, where an automatic conversion to an LPKG is done.

      Also there's no way (clean) to use Java 8 features in a bundle submitted to the Marketplace.

      Workaround

      Dirty trick

      Change the osgi.ee version requirements in your bnd.bnd file. This fakes a lower dependency while your code and compiled bytecode can use and depend upon Java 1.8.
      This is a dirty trick and I wont explain it any further.

      Clean solution

      The actual solution is to downgrade to Java 1.7. To do so add the following line to your build.gradle file:

      sourceCompatibility = '1.7'
      

      This will:

      1. set the right osgi.ee in the final bundle META-INF/MANIFEST.MF;
      2. correctly compile your source to 1.7 bytecode;
      3. force you to use only 1.7 compatible features (no arrows ladies and gents).

      Stacktrace for some SEO. Let's bring here who catches this issue.

      
      	ERROR [fileinstall-D:/Portal/7.0.1/tomcat-7.0.1/liferay-ce-portal-7.0-ga2/osgi/marketplace][org_apache_felix_fileinstall:97] Failed to install artifact: D:\Portal\7.0.1\tomcat-7.0.1\liferay-ce-portal-7.0-ga2\osgi\marketplace\EU Cookie Agreement unlicensed.lpkg
      	com.liferay.portal.lpkg.deployer.LPKGVerifyException: com.liferay.portal.lpkg.deployer.LPKGVerifyException: LPKG validation failed with {[missing requirement it.smc.liferay.privacy.web; version=1.1.0; type=osgi.bundle [caused by: Unable to resolve it.smc.liferay.privacy.web version=1.1.0: missing requirement &(osgi.ee=JavaSE)(version=1.8)]]}
      	        at com.liferay.portal.lpkg.deployer.internal.DefaultLPKGVerifier.verify(DefaultLPKGVerifier.java:128)
      	        at com.liferay.portal.lpkg.deployer.internal.DefaultLPKGDeployer.deploy(DefaultLPKGDeployer.java:104)
      	        at com.liferay.marketplace.deployer.LPKGArtifactInstaller.install(LPKGArtifactInstaller.java:70)
      	        at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:936)
      	        at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:870)
      	        at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:485)
      	        at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)
      	        at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:313)
      	Caused by: com.liferay.portal.lpkg.deployer.LPKGVerifyException: LPKG validation failed with {[missing requirement it.smc.liferay.privacy.web; version=1.1.0; type=osgi.bundle [caused by: Unable to resolve it.smc.liferay.privacy.web version=1.1.0: missing requirement &(osgi.ee=JavaSE)(version=1.8)]]}
      	        at com.liferay.portal.lpkg.deployer.internal.LPKGIndexValidator.validate(LPKGIndexValidator.java:255)
      	        at com.liferay.portal.lpkg.deployer.internal.DefaultLPKGVerifier.verify(DefaultLPKGVerifier.java:90)
      	        ... 7 more
      

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                3 years, 25 weeks, 1 day ago

                Packages

                Version Package