Felix GoGo Shell 抛出 MalformedURLException:未知协议:Equinox 中的 bundleresource
Felix GoGo Shell throws MalformedURLException: unknown protocol: bundleresource in Equinox
我在写an extension to a Java application called ZAP. The extension is a fat/uber jar that has the Equinox bundle (org.eclipse.osgi
) inlined. Additional bundles are also included in this jar, within a sub-directory bundles
. The OSGi framework is being launched as outlined in How To Embed OSGi.
我正在尝试让 Felix GoGo shell 工作,遵循 the steps outlined 通过 Eclipse 的 "Console Shell" 文档。它指定了以下必需的包:
org.apache.felix.gogo.command
org.apache.felix.gogo.runtime
org.apache.felix.gogo.shell
org.eclipse.equinox.console
除了 Equinox / org.eclipse.osgi
。由于 Equinox 不在 class 路径上,我将 org.osgi.framework.system.packages.extra
配置设置为 Equinox 的包指定的 Export-Package
值,可见 here.
框架处于活动状态后,我在 Eclipse 中(或通过 Eclipse 外部的命令行)看到以下堆栈跟踪:
Starting OSGi framework...
OSGi framework state: 32
gogo: MalformedURLException: unknown protocol: bundleresource
java.net.MalformedURLException: unknown protocol: bundleresource
at java.net.URL.<init>(URL.java:593)
at java.net.URL.<init>(URL.java:483)
at java.net.URL.<init>(URL.java:432)
at java.net.URI.toURL(URI.java:1089)
at org.apache.felix.gogo.shell.Shell.readScript(Shell.java:209)
at org.apache.felix.gogo.shell.Shell.source(Shell.java:192)
at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
at java.lang.Thread.run(Thread.java:745)
GoGo 似乎没有使用 Equinox URL 处理程序。我注意到以下与它们相关的包不在 Equinox 的 Export-Package
:
org.eclipse.osgi.storage.url
org.eclipse.osgi.storage.url.bundleresource
org.eclipse.osgi.storage.url.bundleentry
所以我也将它们包含在 org.osgi.framework.system.packages.extra
包列表中。那没有帮助。
包已安装并启动,没有任何明显错误。
如何让 GoGo 使用 Equinox 的自定义 URL 处理程序?
更新 1:可能是红鲱鱼
在随机故障排除中,我想执行概述的最终着色 jar here。我在同一目录中复制了原始 org.eclipse.osgi
包和阴影 jar。有一个 configuration/config.ini
指定要加载的包。
执行库存包会调出控制台:
$ java -cp ~/.p2/pool/plugins/org.eclipse.osgi_3.11.0.v20160121-2005.jar org.eclipse.core.runtime.adaptor.EclipseStarter -console
osgi> ss
"Framework is launched."
id State Bundle
0 ACTIVE org.eclipse.osgi_3.11.0.v20160121-2005
1 ACTIVE org.apache.felix.gogo.runtime_0.10.0.v201209301036
2 ACTIVE org.apache.felix.gogo.command_0.10.0.v201209301215
3 ACTIVE org.apache.felix.gogo.shell_0.10.0.v201212101605
4 ACTIVE org.eclipse.equinox.console_1.1.200.v20150929-1405
osgi> exit
Really want to stop Equinox? (y/n; default=y)
正在执行阴影 jar,没那么多:
java -cp semiotics-alpha-1.zap org.eclipse.core.runtime.adaptor.EclipseStarter -console
java.lang.NullPointerException: A null service reference is not allowed.
at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:617)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:299)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:231)
at org.eclipse.core.runtime.adaptor.EclipseStarter.main(EclipseStarter.java:208)
这可能完全是在转移注意力...我对 OSGi 非常无知,这是我第一次 hands-on 使用它。但是,我希望阴影罐的执行方式与库存 Equinox 罐没有什么不同。由于我不明白为什么会有差异,我会在那里挖掘,因为没有更好的挖掘点......
更新 2:类路径上的 Equinox 解决问题
我通过其 lib
目录将 Equinox 包添加到 ZAP 的 class 路径,并将其从内联到扩展 jar 中删除。这样做并调整 ServiceLoader.load
调用以不包含 class 加载程序(默认为系统 class 加载程序)有效:
Starting bundle: org.apache.felix.gogo.shell_0.10.0.v201212101605 [1]
Starting bundle: org.eclipse.equinox.console_1.1.100.v20141023-1406 [2]
Starting bundle: org.apache.felix.gogo.command_0.10.0.v201209301215 [3]
Starting bundle: org.eclipse.emf.ecore_2.11.2.v20160208-0816 [4]
Starting bundle: org.eclipse.emf.common_2.11.1.v20160208-0816 [5]
Starting bundle: org.apache.felix.gogo.runtime_0.10.0.v201209301036 [6]
osgi> ss
"Framework is launched."
id State Bundle
0 ACTIVE org.eclipse.osgi_3.11.0.v20160121-2005
1 ACTIVE org.apache.felix.gogo.shell_0.10.0.v201212101605
2 ACTIVE org.eclipse.equinox.console_1.1.100.v20141023-1406
3 ACTIVE org.apache.felix.gogo.command_0.10.0.v201209301215
4 ACTIVE org.eclipse.emf.ecore_2.11.2.v20160208-0816
5 ACTIVE org.eclipse.emf.common_2.11.1.v20160208-0816
6 ACTIVE org.apache.felix.gogo.runtime_0.10.0.v201209301036
osgi>
根本问题可能是 jar 的内联方式,可能与 MANIFEST.MF
文件有关。可能相关,我现在不需要为 org.osgi.framework.system.packages.extra
.
提供值
我将不回答这个问题,因为最初的目的是将 OSGi 库作为阴影工件包含在内。也许 bndtools 可以提供帮助?
好的,似乎缺少描述性 META-INF/MANIFEST.MF
是罪魁祸首:
- 删除(
jar uM...
)然后更新(jar um...
)阴影罐的 MANIFEST.MF
成为 Equinox 清单的副本,修改 Bundle-Version
数字以 1766
与 1700
.
- 从 ZAP 的类路径中删除了 Equinox
然后我按原样加载了扩展程序。 GoGo shell 开始:
osgi> 13177 [AWT-EventQueue-0] INFO org.parosproxy.paros.control.Control - New Session
ss
"Framework is launched."
id State Bundle
0 ACTIVE org.eclipse.osgi_3.10.102.v20160118-1766
1 ACTIVE org.apache.felix.gogo.runtime_0.10.0.v201209301036
2 ACTIVE org.eclipse.emf.common_2.11.1.v20160208-0816
3 ACTIVE org.apache.felix.gogo.shell_0.10.0.v201212101605
4 ACTIVE org.eclipse.equinox.console_1.1.100.v20141023-1406
5 ACTIVE org.apache.felix.gogo.command_0.10.0.v201209301215
6 ACTIVE org.eclipse.emf.ecore_2.11.2.v20160208-0816
osgi>
我看到系统包以相同的修改版本号结尾,因此它对添加的 MANIFEST.MF
表示敬意。所以潜在的问题是一个不完整的系统包清单。复制现有的(Equinox 的)效果很好。它也适用于直接命令行测试:
$ java -cp semiotics-alpha-1.zap org.eclipse.core.runtime.adaptor.EclipseStarter -console
osgi> exit
Really want to stop Equinox? (y/n; default=y) y
不知道我是否会使用这种方法。至少我知道我需要做什么如果我想使用这种方法
我在写an extension to a Java application called ZAP. The extension is a fat/uber jar that has the Equinox bundle (org.eclipse.osgi
) inlined. Additional bundles are also included in this jar, within a sub-directory bundles
. The OSGi framework is being launched as outlined in How To Embed OSGi.
我正在尝试让 Felix GoGo shell 工作,遵循 the steps outlined 通过 Eclipse 的 "Console Shell" 文档。它指定了以下必需的包:
org.apache.felix.gogo.command
org.apache.felix.gogo.runtime
org.apache.felix.gogo.shell
org.eclipse.equinox.console
除了 Equinox / org.eclipse.osgi
。由于 Equinox 不在 class 路径上,我将 org.osgi.framework.system.packages.extra
配置设置为 Equinox 的包指定的 Export-Package
值,可见 here.
框架处于活动状态后,我在 Eclipse 中(或通过 Eclipse 外部的命令行)看到以下堆栈跟踪:
Starting OSGi framework...
OSGi framework state: 32
gogo: MalformedURLException: unknown protocol: bundleresource
java.net.MalformedURLException: unknown protocol: bundleresource
at java.net.URL.<init>(URL.java:593)
at java.net.URL.<init>(URL.java:483)
at java.net.URL.<init>(URL.java:432)
at java.net.URI.toURL(URI.java:1089)
at org.apache.felix.gogo.shell.Shell.readScript(Shell.java:209)
at org.apache.felix.gogo.shell.Shell.source(Shell.java:192)
at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
at java.lang.Thread.run(Thread.java:745)
GoGo 似乎没有使用 Equinox URL 处理程序。我注意到以下与它们相关的包不在 Equinox 的 Export-Package
:
org.eclipse.osgi.storage.url
org.eclipse.osgi.storage.url.bundleresource
org.eclipse.osgi.storage.url.bundleentry
所以我也将它们包含在 org.osgi.framework.system.packages.extra
包列表中。那没有帮助。
包已安装并启动,没有任何明显错误。
如何让 GoGo 使用 Equinox 的自定义 URL 处理程序?
更新 1:可能是红鲱鱼
在随机故障排除中,我想执行概述的最终着色 jar here。我在同一目录中复制了原始 org.eclipse.osgi
包和阴影 jar。有一个 configuration/config.ini
指定要加载的包。
执行库存包会调出控制台:
$ java -cp ~/.p2/pool/plugins/org.eclipse.osgi_3.11.0.v20160121-2005.jar org.eclipse.core.runtime.adaptor.EclipseStarter -console
osgi> ss
"Framework is launched."
id State Bundle
0 ACTIVE org.eclipse.osgi_3.11.0.v20160121-2005
1 ACTIVE org.apache.felix.gogo.runtime_0.10.0.v201209301036
2 ACTIVE org.apache.felix.gogo.command_0.10.0.v201209301215
3 ACTIVE org.apache.felix.gogo.shell_0.10.0.v201212101605
4 ACTIVE org.eclipse.equinox.console_1.1.200.v20150929-1405
osgi> exit
Really want to stop Equinox? (y/n; default=y)
正在执行阴影 jar,没那么多:
java -cp semiotics-alpha-1.zap org.eclipse.core.runtime.adaptor.EclipseStarter -console
java.lang.NullPointerException: A null service reference is not allowed.
at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:617)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:299)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:231)
at org.eclipse.core.runtime.adaptor.EclipseStarter.main(EclipseStarter.java:208)
这可能完全是在转移注意力...我对 OSGi 非常无知,这是我第一次 hands-on 使用它。但是,我希望阴影罐的执行方式与库存 Equinox 罐没有什么不同。由于我不明白为什么会有差异,我会在那里挖掘,因为没有更好的挖掘点......
更新 2:类路径上的 Equinox 解决问题
我通过其 lib
目录将 Equinox 包添加到 ZAP 的 class 路径,并将其从内联到扩展 jar 中删除。这样做并调整 ServiceLoader.load
调用以不包含 class 加载程序(默认为系统 class 加载程序)有效:
Starting bundle: org.apache.felix.gogo.shell_0.10.0.v201212101605 [1]
Starting bundle: org.eclipse.equinox.console_1.1.100.v20141023-1406 [2]
Starting bundle: org.apache.felix.gogo.command_0.10.0.v201209301215 [3]
Starting bundle: org.eclipse.emf.ecore_2.11.2.v20160208-0816 [4]
Starting bundle: org.eclipse.emf.common_2.11.1.v20160208-0816 [5]
Starting bundle: org.apache.felix.gogo.runtime_0.10.0.v201209301036 [6]
osgi> ss
"Framework is launched."
id State Bundle
0 ACTIVE org.eclipse.osgi_3.11.0.v20160121-2005
1 ACTIVE org.apache.felix.gogo.shell_0.10.0.v201212101605
2 ACTIVE org.eclipse.equinox.console_1.1.100.v20141023-1406
3 ACTIVE org.apache.felix.gogo.command_0.10.0.v201209301215
4 ACTIVE org.eclipse.emf.ecore_2.11.2.v20160208-0816
5 ACTIVE org.eclipse.emf.common_2.11.1.v20160208-0816
6 ACTIVE org.apache.felix.gogo.runtime_0.10.0.v201209301036
osgi>
根本问题可能是 jar 的内联方式,可能与 MANIFEST.MF
文件有关。可能相关,我现在不需要为 org.osgi.framework.system.packages.extra
.
我将不回答这个问题,因为最初的目的是将 OSGi 库作为阴影工件包含在内。也许 bndtools 可以提供帮助?
好的,似乎缺少描述性 META-INF/MANIFEST.MF
是罪魁祸首:
- 删除(
jar uM...
)然后更新(jar um...
)阴影罐的MANIFEST.MF
成为 Equinox 清单的副本,修改Bundle-Version
数字以1766
与1700
. - 从 ZAP 的类路径中删除了 Equinox
然后我按原样加载了扩展程序。 GoGo shell 开始:
osgi> 13177 [AWT-EventQueue-0] INFO org.parosproxy.paros.control.Control - New Session
ss
"Framework is launched."
id State Bundle
0 ACTIVE org.eclipse.osgi_3.10.102.v20160118-1766
1 ACTIVE org.apache.felix.gogo.runtime_0.10.0.v201209301036
2 ACTIVE org.eclipse.emf.common_2.11.1.v20160208-0816
3 ACTIVE org.apache.felix.gogo.shell_0.10.0.v201212101605
4 ACTIVE org.eclipse.equinox.console_1.1.100.v20141023-1406
5 ACTIVE org.apache.felix.gogo.command_0.10.0.v201209301215
6 ACTIVE org.eclipse.emf.ecore_2.11.2.v20160208-0816
osgi>
我看到系统包以相同的修改版本号结尾,因此它对添加的 MANIFEST.MF
表示敬意。所以潜在的问题是一个不完整的系统包清单。复制现有的(Equinox 的)效果很好。它也适用于直接命令行测试:
$ java -cp semiotics-alpha-1.zap org.eclipse.core.runtime.adaptor.EclipseStarter -console
osgi> exit
Really want to stop Equinox? (y/n; default=y) y
不知道我是否会使用这种方法。至少我知道我需要做什么如果我想使用这种方法