2012-08-05 58 views
2

好的,我很茫然。我有這條線一個空指針:JAXB內容沒有實例化

JAXBContext    context   = JAXBContext.newInstance(X3D.class); 

這裏是輸出錯誤的事情:

Exception in thread "main" java.lang.NullPointerException 
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.checkOverrideProperties(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.<init>(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.<init>(Unknown Source) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.property.PropertyFactory.create(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.<init>(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.<init>(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.<init>(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementProperty.<init>(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementNodeProperty.<init>(Unknown Source) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.property.PropertyFactory.create(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.<init>(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.<init>(Unknown Source) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.property.PropertyFactory.create(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.<init>(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source) 
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source) 
    at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at javax.xml.bind.ContextFinder.newInstance(Unknown Source) 
    at javax.xml.bind.ContextFinder.newInstance(Unknown Source) 
    at javax.xml.bind.ContextFinder.find(Unknown Source) 
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source) 
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source) 
    at com.prim.esaa.gui.x3d.MyXmlWriter.myWriteFile(MyXmlWriter.java:159) 
    at com.prim.esaa.gui.x3d.MyXmlWriter.myWrite(MyXmlWriter.java:199) 
    at com.prim.esaa.gui.x3d.Sim3DAnimator.writeXMLoutput(Sim3DAnimator.java:266) 
    at com.prim.esaa.gui.x3d.Sim3DAnimator.initModels(Sim3DAnimator.java:212) 
    at com.prim.esaa.gui.x3d.Sim3DAnimator.main(Sim3DAnimator.java:141) 

我意識到,並非所有的代碼是存在的,我可以添加更多的,但如果我的理解正確地說,這個命令設置的東西,並不完全依賴於我的任何其他變量。它正在工作,然後停下來。我不知道爲什麼。

它一遍又一遍地說「未知來源」,但我包括路徑和類X3D,以便它應該沒問題。

謝謝。

+2

X3D是什麼樣的?它是否正確註釋? – Reimeus 2012-08-05 16:49:14

+0

X3D文件爲空。 X3D類文件看起來很好。然後我在另一個文件中實例化,並將該X3D創建的變量傳遞給此函數,稍後在編組時使用。但是在這條線上,如果我理解正確,那只是設置和失敗。 – 2012-08-05 17:00:12

回答