Linux org.GNOME.Accessibility.JavaBridge$AccessQueue 在先前加载类后抛出 java.lang.ClassNotFoundException

发布于 2024-08-20 02:46:37 字数 4313 浏览 3 评论 0原文

我正在使用代理运行java。

当我的应用程序不使用 GUI(swing)时,它在下面提到的两个 JRE 下运行良好。

当它使用 GUI (swing) 时,当使用 JRE:HotSpot (TM) 64 位服务器 VM(版本 1.6.0-b105,混合模式)时,它运行良好。

但是使用 JRE:/usr/lib/jvm/java-6-openjdk,它会产生由 org.GNOME.Accessibility.JavaBridge$AccessQueue 抛出的异常 java.lang.NoClassDefFoundError

没有我的代理或有代理但应用于控制台应用程序时,它对于两个 JRE 都运行良好。

该异常表明找不到我的代理类之一: ****java.lang.NoClassDefFoundError: mypack/myagent/MyClass****

但是这个类已经加载了: ****[从文件加载mypack.myagent.MyClass:/home.owner/Tests/AGENT.jar]****

??????

为什么 JRE 尝试再次加载相同的类?为什么这次找不到呢?

(所有代理类及其所有依赖项都存在于 jar 文件内)

以下是输出的摘录。使用-verbose命令行选项。


[打开/usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

[从/usr/lib/jvm/java-6-openjdk/jre/lib/rt加载java.lang.Object。 jar]

[从文件加载 mypack.myagent.Main:/home/owner/Tests/AGENT.jar

[从 /usr/lib/jvm/java-6-openjdk/jre/lib

/rt 加载 java.lang.instrument.ClassFileTransformer .jar]

启动代理...

[从 /usr/lib/jvm/java-6-openjdk/jre/lib/rt 加载 java.net.URLClassLoader$2。 jar]

[从文件加载 org.apache.log4j.CategoryKey:/home/owner/Tests/AGENT.jar]

[从文件加载 mypack.myagent.MyClass:/home.owner/Tests/AGENT .jar]

[从 /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar 加载 org.w3c.dom.Node]

[从 /usr/lib/jvm/java 加载 java.io.UnsupportedEncodingException -6-openjdk/jre/lib

/rt.jar]

加载 sun.net.www.protocol.jar.URLJarFile$URLJarFileEntry

[从 /usr/lib/jvm/java- 6-openjdk/jre/lib/rt.jar

] [从 /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar 加载 sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream

]

[加载 com.sun.org.apache.xerces.internal /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar 中的 .util.SecurityManager

]

[从 /usr/lib/jvm/java-6-openjdk/jre/lib 加载 sun.management.RuntimeImpl /rt.jar]

来自代理的问候...

[从文件加载 testpackage.GuiTest: ...

[从 /usr/lib/jvm 加载 java.awt.LayoutManager /java-6-openjdk/jre/lib/rt.jar]

[从 /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar 加载 java.awt.image.ImageObserver]

[加载 java.util.ImageObserver] awt.MenuContainer 来自 /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

。 。 。

[从 /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar 加载 sun.awt.X11.XEvent]

[从文件加载 org.GNOME.Accessibility.JavaBridge:/usr/share/java/ gnome-java-bridge.jar]

[从 /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar 加载 java.awt.event.FocusListener]

[加载 org.GNOME.Accessibility.JavaBridge$AccessQueue来自文件:/usr/share/java/gnome-

java-bridge.jar]

[从 /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar 加载 java.lang.InstantiationException]

线程“main”中的异常 java.lang.NoClassDefFoundError: mypack/myagent/MyClass

at org.GNOME.Accessibility.JavaBridge.(JavaBridge.java)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (本机方法)

位于 sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)

在 java.lang.reflect.Constructor.newInstance(Constructor.java:532)

在 java.lang.Class.newInstance0(Class.java:372)

在 java.lang.Class.newInstance(Class. java:325)

在java.awt.Toolkit.loadAssistiveTechnologies(Toolkit.java:786)

在java.awt.Toolkit.getDefaultToolkit(Toolkit.java:874)

在java.awt.Window.getToolkit(Window.java:1170)

在java.awt.Window.init(Window.java:400)

在 java.awt.Window.(Window.java:438)

在 java.awt.Frame.(Frame.java:419)

在 javax.swing.JFrame.( JFrame.java:224)

在 testpackage.GuiTest.(GuiTest.java:52)

在 testpackage.GuiTest.main(GuiTest.java:39)

引起:java.lang.ClassNotFoundException:mypack.myagent。 MyClass

位于 java.net.URLClassLoader$1.run(URLClassLoader.java:217)

位于 java.security.AccessController.doPrivileged(Native Method)

位于 java.net.URLClassLoader.findClass(URLClassLoader.java: 205)

在 java.lang.ClassLoader.loadClass(ClassLoader.java:323)

在 java.lang.ClassLoader.loadClass(ClassLoader.java:268)

在 java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)

...还有 16 个

I am running java with an agent.

When my application does not use GUI (swing) it runs fine under both JREs mentioned below.

When it does use GUI (swing), when using JRE: HotSpot (TM) 64 Bits Server VM (build 1.6.0-b105, mixed mode) it runs fine.

But with JRE: /usr/lib/jvm/java-6-openjdk, it produces exception java.lang.NoClassDefFoundError thrown by org.GNOME.Accessibility.JavaBridge$AccessQueue

Without my agent or with an agent but applied to a console application it runs fine for both JREs.

The exception tells that one of my agent's classes is not found :
****java.lang.NoClassDefFoundError: mypack/myagent/MyClass****

however this class was already loaded:
****[Loaded mypack.myagent.MyClass from file:/home.owner/Tests/AGENT.jar]****

?????

Why JRE is trying to load same class again? and why it can not find it this time?

(All the agent classes are present inside jar file with all their dependencies)

Below is the extract of output. The -verbose command line option is used.


[Opened /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

[Loaded java.lang.Object from /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

[Loaded mypack.myagent.Main from file:/home/owner/Tests/AGENT.jar

[Loaded java.lang.instrument.ClassFileTransformer from /usr/lib/jvm/java-6-openjdk/jre/lib

/rt.jar]

Launching agent...

[Loaded java.net.URLClassLoader$2 from /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

[Loaded org.apache.log4j.CategoryKey from file:/home/owner/Tests/AGENT.jar]

[Loaded mypack.myagent.MyClass from file:/home.owner/Tests/AGENT.jar]

[Loaded org.w3c.dom.Node from /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

[Loaded java.io.UnsupportedEncodingException from /usr/lib/jvm/java-6-openjdk/jre/lib

/rt.jar]

[Loaded sun.net.www.protocol.jar.URLJarFile$URLJarFileEntry from /usr/lib/jvm/java-

6-openjdk/jre/lib/rt.jar]

[Loaded sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream from /usr/lib/jvm/java-

6-openjdk/jre/lib/rt.jar]

[Loaded com.sun.org.apache.xerces.internal.util.SecurityManager from /usr/lib/jvm/java-

6-openjdk/jre/lib/rt.jar]

[Loaded sun.management.RuntimeImpl from /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

Hello from agent ...

[Loaded testpackage.GuiTest from file: ...

[Loaded java.awt.LayoutManager from /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

[Loaded java.awt.image.ImageObserver from /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

[Loaded java.awt.MenuContainer from /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

. . .

[Loaded sun.awt.X11.XEvent from /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

[Loaded org.GNOME.Accessibility.JavaBridge from file:/usr/share/java/gnome-java-bridge.jar]

[Loaded java.awt.event.FocusListener from /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

[Loaded org.GNOME.Accessibility.JavaBridge$AccessQueue from file:/usr/share/java/gnome-

java-bridge.jar]

[Loaded java.lang.InstantiationException from /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar]

Exception in thread "main" java.lang.NoClassDefFoundError: mypack/myagent/MyClass

at org.GNOME.Accessibility.JavaBridge.(JavaBridge.java)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:532)

at java.lang.Class.newInstance0(Class.java:372)

at java.lang.Class.newInstance(Class.java:325)

at java.awt.Toolkit.loadAssistiveTechnologies(Toolkit.java:786)

at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:874)

at java.awt.Window.getToolkit(Window.java:1170)

at java.awt.Window.init(Window.java:400)

at java.awt.Window.(Window.java:438)

at java.awt.Frame.(Frame.java:419)

at javax.swing.JFrame.(JFrame.java:224)

at testpackage.GuiTest.(GuiTest.java:52)

at testpackage.GuiTest.main(GuiTest.java:39)

Caused by: java.lang.ClassNotFoundException: mypack.myagent.MyClass

at java.net.URLClassLoader$1.run(URLClassLoader.java:217)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:205)

at java.lang.ClassLoader.loadClass(ClassLoader.java:323)

at java.lang.ClassLoader.loadClass(ClassLoader.java:268)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)

... 16 more

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

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

发布评论

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

评论(1

无风消散 2024-08-27 02:46:37

创建到 jar 文件的符号链接解决了该问题。

我通过从/usr/lib/jvm/java-6-openjdk/jre/lib/ext 目录

I fixed the problem by creating a symbolic link to my jar file from

/usr/lib/jvm/java-6-openjdk/jre/lib/ext directory.

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