开发者

How to load JAXB within an applet under Java 1.5

开发者 https://www.devze.com 2023-02-13 08:35 出处:网络
I have an applet (开发者_开发知识库packaged as a jar) requires JAXB (jaxb-api-2.1.jar) running fine with Java 1.6. However, when it is under Java 1.5, even with the JAXB classes extracted into the app

I have an applet (开发者_开发知识库packaged as a jar) requires JAXB (jaxb-api-2.1.jar) running fine with Java 1.6. However, when it is under Java 1.5, even with the JAXB classes extracted into the applet jar, I have the following exceptions:

Exception: javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory not found
 - with linked exception: [java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]

javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory not found
 - with linked exception: [java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]
     at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:152)
     at javax.xml.bind.ContextFinder.find(ContextFinder.java:299)
     at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
     at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
 .......
Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory
     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
     at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:117)

exceptions is thrwon of in this line:

jc = JAXBContext.newInstance("mypackage", this.getClass().getClassLoader());

Any ideas why? Many thanks in advance


You need all of the jars required for JAXB to be available to your applet (i. e. they all need to be downloaded) because JAXB does not come packaged with Java 1.5. You'll want to grab the entire JAXB implementation from either the reference or your favorite implementation and set your applet to use all of those jars.

0

精彩评论

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

关注公众号