jwsdp 1.4 / JDK 1.4.2_04-b05
在使用JAXB时运行出错,sun 教程的 JAXB 的第一个例子
public class Main {
public static void main(String[] args) throws JAXBException {
javax.xml.bind.JAXBContext jc=javax.xml.bind.JAXBContext.newInstance("com.ecc.dragon.webservice.jaxb.po");
Unmarshaller u=jc.createUnmarshaller();
PurchaseOrder po=(PurchaseOrder) u.unmarshal(new File("E:\\webservice\\xml\\jaxb\\unmarshal-read\\po.xml"));
}
}
异常如下
java.lang.SecurityException: class "javax.xml.bind.JAXBContext"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:599)
at java.lang.ClassLoader.defineClass(ClassLoader.java:532)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at com.ecc.dragon.webservice.jaxb.po.Main.main(Main.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Exception in thread "main"
------解决方法--------------------------------------------------------
这个错误的原因是因为你在你载入的包里面有两个相同路径的类,就是在一个包里面有两个同名的类
有可能是你将相同的包载入两次或者你把包解开后,先将jar文件载入了,后又将解开的类载入了