如何修复 org.osgi.framework.BundleException:导入的包名称长度不能为零

问题描述 投票:0回答:2

我有包含许多使用 OSGI 捆绑包的模块的整体代码,我需要从 jdk8 升级到 jdk11,在部署中我收到了很多与以下内容相关的错误和警告 OSGI 和 apache.felix:像:

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

所以我将 felix.framework 更新到版本 7+,将 OSGI 更新到最新版本 1.4.0。 现在我在将映像部署到 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)

还有未解决的捆绑包。 如何解决这些问题?

java maven osgi java-11 apache-felix
2个回答
0
投票

就我而言,此错误是由于 java 版本问题而发生的。可能是你的代码不支持jdk11


0
投票

在WSL2 Ubuntu(版本22.04.2 LTS)中运行pan.sh时,我们在Pentaho社区版(版本9.3.0.0-428)中遇到了完全相同的问题,但感谢srihitha的线索,我们能够解决它:

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)

我们删除了openjdk 17,然后删除了openjdk 11,最后加载了openJdk 8。

© www.soinside.com 2019 - 2024. All rights reserved.