How to fix org.osgi.framework.BundleException: Imported package names cannot be zero length

1.2k views Asked by At

I have monolith code that includes a lot of modules which using OSGI bundles, i need to upgrade from jdk8 to jdk11, in the deployment i got a lot of errors and warnings related to OSGI and apache.felix: like:

OSGI cant resolved dependency with version: xxx and warning like: 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender (file:/full-test/framework/org.apache.felix.framework-5.6.10.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

so i updated felix.framework to version 7+ and OSGI to latest version 1.4.0. now i got this error while deploying the image to docker:

 org.osgi.framework.BundleException: Imported package names cannot be zero length.
ngwi      |     at org.apache.felix.framework.util.manifestparser.ManifestParser.normalizeImportClauses(ManifestParser.java:361)
ngwi      |     at org.apache.felix.framework.util.manifestparser.ManifestParser.<init>(ManifestParser.java:186)
ngwi      |     at org.apache.felix.framework.BundleRevisionImpl.<init>(BundleRevisionImpl.java:117)
ngwi      |     at org.apache.felix.framework.BundleImpl.createRevision(BundleImpl.java:1290)
ngwi      |     at org.apache.felix.framework.BundleImpl.<init>(BundleImpl.java:114)
ngwi      |     at org.apache.felix.framework.Felix.installBundle(Felix.java:3287)
ngwi      |     at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:147)
ngwi      |     at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:120)
ngwi      |     at com.intuit.cto.wi.rest.osgi.listener.ProvisionActivator.start(ProvisionActivator.java:35)
ngwi      |     at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:849)
ngwi      |     at org.apache.felix.framework.Felix$SystemBundleActivator.start(Felix.java:5173)
ngwi      |     at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:849)
ngwi      |     at org.apache.felix.framework.Felix.init(Felix.java:899)
ngwi      |     at org.apache.felix.framework.Felix.init(Felix.java:648)
ngwi      |     at com.intuit.cto.wi.rest.osgi.ApacheFelix.start(ApacheFelix.java:56)
ngwi      |     at com.intuit.cto.wi.rest.osgi.listener.FrameworkService.doStart(FrameworkService.java:63)
ngwi      |     at com.intuit.cto.wi.rest.osgi.listener.FrameworkService.start(FrameworkService.java:41)
ngwi      |     at com.intuit.cto.wi.rest.osgi.listener.StartupListener.contextInitialized(StartupListener.java:24)
ngwi      |     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4763)
ngwi      |     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5232)
ngwi      |     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
ngwi      |     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
ngwi      |     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727)
ngwi      |     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
ngwi      |     at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1016)
ngwi      |     at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1903)
ngwi      |     at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
ngwi      |     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
ngwi      |     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
ngwi      |     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
ngwi      |     at java.base/java.lang.Thread.run(Thread.java:829)

and also the bundles not resolved. how to fix those issues?

2

There are 2 answers

1
srihitha On

In my case this error occurred due to java version issue. May be your code doesn't support jdk11

0
Tihamer On

We had exactly the same problem in Pentaho Community Edition (Version 9.3.0.0-428) when running pan.sh in WSL2 Ubuntu (version 22.04.2 LTS), but thanks to srihitha's clue, we were able to solve it:

org.osgi.framework.BundleException: Exported package names cannot be zero length.
    at org.apache.felix.framework.util.manifestparser.ManifestParser.normalizeExportClauses(ManifestParser.java:876)
    at org.apache.felix.framework.util.manifestparser.ManifestParser.<init>(ManifestParser.java:215)
    at org.apache.felix.framework.ExtensionManager.<init>(ExtensionManager.java:261)
    at org.apache.felix.framework.Felix.<init>(Felix.java:429)
    at org.apache.felix.framework.FrameworkFactory.newFramework(FrameworkFactory.java:28)
    at org.apache.karaf.main.Main.launch(Main.java:258)
    at org.pentaho.platform.osgi.KarafBoot$4.run(KarafBoot.java:263)
    at java.base/java.lang.Thread.run(Thread.java:833)
    at org.pentaho.platform.osgi.KarafBoot.startup(KarafBoot.java:272)
    at org.pentaho.di.osgi.registryExtension.OSGIPluginRegistryExtension.init(OSGIPluginRegistryExtension.java:107)
    at org.pentaho.di.core.plugins.PluginRegistry.init(PluginRegistry.java:565)
    at org.pentaho.di.core.plugins.PluginRegistry.init(PluginRegistry.java:545)
    at org.pentaho.di.core.KettleClientEnvironment.init(KettleClientEnvironment.java:117)
    at org.pentaho.di.core.KettleClientEnvironment.init(KettleClientEnvironment.java:80)
    at org.pentaho.di.core.KettleEnvironment.init(KettleEnvironment.java:134)
    at org.pentaho.di.core.KettleEnvironment.init(KettleEnvironment.java:101)
    at org.pentaho.di.core.KettleEnvironment.init(KettleEnvironment.java:82)
    at org.pentaho.di.pan.Pan.main(Pan.java:63)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.pentaho.commons.launcher.Launcher.main(Launcher.java:92)

We deleted openjdk 17, then deleted openjdk 11, and finally loaded openJdk 8.