osgi 中的常规控制台

发布于 2024-11-03 09:16:16 字数 3356 浏览 2 评论 0原文

我设法将标准的 groovy 控制台嵌入到 Felix 中并公开了许多变量(即 BundleContext 等)。

但是,在“第一次”启动我的蓝图包时,我收到此错误:

Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_24]
  ... ... ...
    at groovy.util.FactoryBuilderSupport.callAutoRegisterMethods(FactoryBuilderSupport.java:202)[groovy-all-1.7.8.jar:1.7.8]
    ... 42 more
Caused by: java.lang.NoClassDefFoundError: sun/reflect/ConstructorAccessorImpl
    at sun.misc.Unsafe.defineClass(Native Method)[:1.6.0_24]
    ... ... ...
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)[:1.6.0_24]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)[:1.6.0_24]
    ... ... ...
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)[groovy-all-1.7.8.jar:1.7.8]
    at groovy.swing.SwingBuilder.registerActionButtonWidgets(SwingBuilder.groovy:94)[groovy-all-1.7.8.jar:1.7.8]
    ... 47 more
Caused by: java.lang.ClassNotFoundException: *** Package 'sun.reflect' is not imported by bundle groovy-all [18], nor is there any bundle that exports package 'sun.reflect'. However, the class 'sun.reflect.ConstructorAccessorImpl' is available from the system class loader. There are two fixes: 1) Add package 'sun.reflect' to the 'org.osgi.framework.system.packages.extra' property and modify bundle groovy-all [18] to import this package; this causes the system bundle to export class path packages. 2) Add package 'sun.reflect' to the 'org.osgi.framework.bootdelegation' property; a library or VM bug can cause classes to be loaded by the wrong class loader. The first approach is preferable for preserving modularity. ***
    at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1782)[org.apache.felix.framework-3.0.9.jar:]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_24]
    at org.codehaus.groovy.runtime.callsite.CallSiteClassLoader.loadClass(CallSiteClassLoader.java:51)[groovy-all-1.7.8.jar:1.7.8]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_24]
    at org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.loadClass(ClassLoaderForClassArtifacts.java:58)[groovy-all-1.7.8.jar:1.7.8]
    ... 65 more
Caused by: java.lang.ClassNotFoundException: sun.reflect.ConstructorAccessorImpl not found by groovy-all [18]
    at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)[org.apache.felix.framework-3.0.9.jar:]
    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)[org.apache.felix.framework-3.0.9.jar:]
    at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)[org.apache.felix.framework-3.0.9.jar:]
    ... 69 more

抛出异常后,我的包现在处于活动状态。但是,控制台不显示。如果我停止并再次启动捆绑包,错误将不再显示,并且我可以查看并使用我的 swing groovy 控制台。

堆栈跟踪指示以下选项可解决此问题:

  1. 将包“sun.reflect”添加到 'org.osgi.framework.system.packages.extra' 属性并修改包 groovy-all [18] 导入这个 包裹;这会导致系统 捆绑到导出类路径 包。

  2. 将包“sun.reflect”添加到 'org.osgi.framework.bootdelegation' 财产;库或虚拟机错误可能 导致类被加载 错误的类加载器。第一个 方法更适合 保持模块化。 *

我非常确定使用选项 2,错误将会消失。

但是,我的问题是...如果未导入 sun.reflect ,为什么在我重新启动捆绑包后会显示 groovy 控制台?感谢任何有此类经验的人的建议。

I managed to embed the standard groovy console to Felix and expose a number of variables (i.e. BundleContext, etc).

However, on "first" start up of my blueprint bundle, I got this error:

Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_24]
  ... ... ...
    at groovy.util.FactoryBuilderSupport.callAutoRegisterMethods(FactoryBuilderSupport.java:202)[groovy-all-1.7.8.jar:1.7.8]
    ... 42 more
Caused by: java.lang.NoClassDefFoundError: sun/reflect/ConstructorAccessorImpl
    at sun.misc.Unsafe.defineClass(Native Method)[:1.6.0_24]
    ... ... ...
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)[:1.6.0_24]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)[:1.6.0_24]
    ... ... ...
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)[groovy-all-1.7.8.jar:1.7.8]
    at groovy.swing.SwingBuilder.registerActionButtonWidgets(SwingBuilder.groovy:94)[groovy-all-1.7.8.jar:1.7.8]
    ... 47 more
Caused by: java.lang.ClassNotFoundException: *** Package 'sun.reflect' is not imported by bundle groovy-all [18], nor is there any bundle that exports package 'sun.reflect'. However, the class 'sun.reflect.ConstructorAccessorImpl' is available from the system class loader. There are two fixes: 1) Add package 'sun.reflect' to the 'org.osgi.framework.system.packages.extra' property and modify bundle groovy-all [18] to import this package; this causes the system bundle to export class path packages. 2) Add package 'sun.reflect' to the 'org.osgi.framework.bootdelegation' property; a library or VM bug can cause classes to be loaded by the wrong class loader. The first approach is preferable for preserving modularity. ***
    at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1782)[org.apache.felix.framework-3.0.9.jar:]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_24]
    at org.codehaus.groovy.runtime.callsite.CallSiteClassLoader.loadClass(CallSiteClassLoader.java:51)[groovy-all-1.7.8.jar:1.7.8]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_24]
    at org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.loadClass(ClassLoaderForClassArtifacts.java:58)[groovy-all-1.7.8.jar:1.7.8]
    ... 65 more
Caused by: java.lang.ClassNotFoundException: sun.reflect.ConstructorAccessorImpl not found by groovy-all [18]
    at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)[org.apache.felix.framework-3.0.9.jar:]
    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)[org.apache.felix.framework-3.0.9.jar:]
    at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)[org.apache.felix.framework-3.0.9.jar:]
    ... 69 more

With the exception thrown, my bundle is now active. However, the console do not show. If I stop and start the bundle again, the error no longer shows and i'm able to see and use my swing groovy console.

The stack trace indicates the following options to fix this problem:

  1. Add package 'sun.reflect' to the
    'org.osgi.framework.system.packages.extra'
    property and modify bundle
    groovy-all [18] to import this
    package; this causes the system
    bundle to export class path
    packages.

  2. Add package 'sun.reflect' to the
    'org.osgi.framework.bootdelegation'
    property; a library or VM bug can
    cause classes to be loaded by the
    wrong class loader. The first
    approach is preferable for
    preserving modularity. *

I am quite certain that with option 2, the error will go away.

However, my question is...if sun.reflect is not imported, why does the groovy console show after i restart the bundle? Appreciate advice from anyone with such experience.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愛放△進行李 2024-11-10 09:16:16

选项 1 是问题的正确解决方案。您的捆绑包依赖于包 sun.reflect,因此您应该在 Import-Package 语句中明确说明这一点。

我不知道为什么控制台会在重新启动后显示。如果无法加载 sun.reflect 包,它可能会执行自己的内部“故障转移”。我不会太担心这方面,只需通过添加导入来使其工作即可。

Option 1 is the correct solution to the problem. Your bundle depends on package sun.reflect, so you should make that explicit in the Import-Package statement.

I have no idea why the console might show after restarting. It may do its own internal "fail-over" in the event it can't load the sun.reflect package. I wouldn't worry too much about this aspect, just get it to work by adding the import.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文