开发者

Linux org.GNOME.Accessibility.JavaBridge$AccessQueue throws java.lang.ClassNotFoundException after the class has been previously loaded

开发者 https://www.devze.com 2022-12-18 14:30 出处:网络
I am running java with an agent. When my application does not use GUI (swing) it runs fine under both JREs mentioned below.

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 o开发者_高级运维rg.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


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消