org.osgi.framework.BundleException: Invalid manifest header Import-Package: "java.lang.Boolean" : Cannot specify java.* packages in Import/Export headers "java.lang.Boolean"

Liferay Issues | Neil Griffin | 1 year ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    h3. Steps to Reproduce: 1. Start Liferay Portal 7.0.0 B8 2. Clone the [blade|https://github.com/rotty3000/blade] Git repository. 3. Navigate to the blade.portlet.jsp Maven project: {code}cd blade/maven/blade.portlet.jsp{code} 4. Create the following package: {code}mkdir src/main/java/blade/portlet/jsp/stuff{code} 5. Create the following Java classes in the package; {code:java} package blade.portlet.jsp.stuff; public class Foo { } {code} {code:java} package blade.portlet.jsp.stuff; public class Bar { } {code} 6. Replace src/main/resources/META-INF/resources/view.jsp with the following contents: {code:html} <%@ include file="/init.jsp" %> <%@ page import="blade.portlet.jsp.stuff.*, java.lang.Boolean, java.util.ArrayList" %> <% Foo foo = new Foo(); ArrayList<String> myList = new ArrayList<String>(); %> <p>boolean=<%= Boolean.TRUE.toString() %></p> <p>myList=<%= myList.toString() %></p> {code} 7. Build the OSGi bundle: {code}mvn clean package{code} 8. Deploy the OSGi bundle: {code}cp target/blade.portlet.jsp-1.0.0.jar $LIFERAY_HOME/osgi/modules{code} If the bug is fixed, then the OSGi bundle will deploy properly. Otherwise, if the bug still exists, then the following stacktrace will appear in the server log: {noformat} 22:50:22,018 WARN [fileinstall-/Users/ngriffin/Portals/liferay.com/liferay-portal-7.0.0-SNAPSHOT-jsf-2.2/osgi/modules][org_apache_felix_fileinstall:102] Failed to update artifact /Users/ngriffin/Portals/liferay.com/liferay-portal-7.0.0-SNAPSHOT-jsf-2.2/osgi/modules/blade.portlet.jsp-1.0.0.jar org.osgi.framework.BundleException: Invalid manifest header Import-Package: "java.lang.Boolean" : Cannot specify java.* packages in Import/Export headers "java.lang.Boolean" at org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory.checkImportExportSyntax(OSGiManifestBuilderFactory.java:147) at org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory.validateHeaders(OSGiManifestBuilderFactory.java:118) at org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory.createBuilder(OSGiManifestBuilderFactory.java:78) at org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory.createBuilder(OSGiManifestBuilderFactory.java:56) at org.eclipse.osgi.storage.Storage.getBuilder(Storage.java:589) at org.eclipse.osgi.storage.Storage.update(Storage.java:714) at org.eclipse.osgi.internal.framework.EquinoxBundle.update(EquinoxBundle.java:448) at org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:1133) at org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:905) at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:484) at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361) at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:313) {noformat} h3. Workaround: - Do not use comma-delimited lists of imports - Instead, use one {{<%@ page import="..." %>}} per line - Do not use wildcards, but instead specify each class individually h3. Observations: 1. In the JSP from step#6, the {{blade.portlet.jsp.stuff.*}} import is not actually necessary, since Bar.java is not used anywhere in the JSP. However, placing it in its own page directive makes the error go away: {code:html} <%@ page import="blade.portlet.jsp.stuff.*" %> <%@ page import="java.lang.Boolean, java.util.ArrayList" %> {code} 2. In the JSP from step#6, if the {{blade.portlet.jsp.stuff.\*}} import is replaced by {{java.net.\*}} then it works. Why does the first unused wildcard cause a problem, and the second does not? 3. The following JSP *should* work fine because Foo.java is used in the JSP, but it fails: {code:html} <%@ page import="blade.portlet.jsp.stuff.Foo, java.util.*, java.lang.Boolean" %> <% Foo foo = new Foo(); ArrayList<String> myList = new ArrayList<String>(); %> <p>boolean=<%= Boolean.TRUE.toString() %></p> <p>myList=<%= myList.toString() %></p> {code} ... error message is: {noformat} Invalid manifest header Import-Package: "java.util.*" : Cannot specify java.* packages in Import/Export headers "java.util.*" {noformat}

    Liferay Issues | 1 year ago | Neil Griffin
    org.osgi.framework.BundleException: Invalid manifest header Import-Package: "java.lang.Boolean" : Cannot specify java.* packages in Import/Export headers "java.lang.Boolean"
  2. 0

    OpenHab 2 startup Could not resolved module ui.paper

    GitHub | 9 months ago | bsutton
    org.osgi.framework.BundleException: Could not resolve module: org.eclipse.smarthome.ui.paper [180] Another singleton bundle selected: osgi.identity; osgi.identity="org.eclipse.smarthome.ui.paper"; type="osgi.bundle"; version:Version="0.9.0.201608031951"; singleton:="true" ```

    Root Cause Analysis

    1. org.osgi.framework.BundleException

      Invalid manifest header Import-Package: "java.lang.Boolean" : Cannot specify java.* packages in Import/Export headers "java.lang.Boolean"

      at org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory.checkImportExportSyntax()
    2. Eclipse OSGi
      EquinoxBundle.update
      1. org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory.checkImportExportSyntax(OSGiManifestBuilderFactory.java:147)
      2. org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory.validateHeaders(OSGiManifestBuilderFactory.java:118)
      3. org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory.createBuilder(OSGiManifestBuilderFactory.java:78)
      4. org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory.createBuilder(OSGiManifestBuilderFactory.java:56)
      5. org.eclipse.osgi.storage.Storage.getBuilder(Storage.java:589)
      6. org.eclipse.osgi.storage.Storage.update(Storage.java:714)
      7. org.eclipse.osgi.internal.framework.EquinoxBundle.update(EquinoxBundle.java:448)
      7 frames
    3. Apache Felix File Install
      DirectoryWatcher.run
      1. org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:1133)
      2. org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:905)
      3. org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:484)
      4. org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)
      5. org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:313)
      5 frames