Re: [Simple-support] [nbdev] ClassDefNotFoundError
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2007-08-21 07:49:05
|
Hi Wessam, I suspect you are loading from two different class loaders here. So although the ZephyrParserFactory is an implementation of the XMLInputFactory they are both loaded from different class loaders (perhaps the ZephyrParserFactory is bundled with a separate StAX API JAR). If two identical classes are loaded from different class loaders they are NOT the same class, so you will get a class cast exception. Why don't you just download Woodstox, bundle this with the Simple XML JAR and set the system property: -Djavax.xml.stream.XMLInputFactory=com.ctc.wstx.stax.WstxInputFactory Niall --- Wessam Abd Rabo <wes...@gm...> wrote: > hey david, > > Thanks for the note. I did what you suggested but > still i get this same > error: > > java.lang.ClassCastException: > com.sun.xml.stream.ZephyrParserFactory cannot > be cast to javax.xml.stream.XMLInputFactory > at > javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136) > at > org.simpleframework.xml.stream.NodeBuilder.<clinit>(NodeBuilder.java:48) > Caused: *java.lang.ExceptionInInitializerError > * at > org.simpleframework.xml.load.Persister.write(Persister.java:687) > at > org.simpleframework.xml.load.Persister.write(Persister.java:669) > at > org.simpleframework.xml.load.Persister.write(Persister.java:650) > at > org.simpleframework.xml.load.Persister.write(Persister.java:629) > at > org.netbeans.shapesample.GraphSceneImpl.generateXML(GraphSceneImpl.java > :152 > > > Let me tell you what i'm trying to do here. I'm > using an external library > called Simple Framework > http://simple.sourceforge.net/ for generating the > XML file from the diagram. I created a moudle suite > and added to it this > library as a library wrapper and also added a module > which contains my > appliction that will use the library. This > application is just topcomponent > and graphscene implementation. inside dragndrop > accept method, i call a > function that generates xml using this piece of code > which i got from a > tutorial on the website of this library : > > > java.io.File result = new > java.io.File("example.xml"); > > Example example=new Example("Example Message",123); > > org.simpleframework.xml.Serializer serializer = new > org.simpleframework.xml.load.Persister(); > > serializer.write(example, result); > > it doesn't work at all inside a module project while > it works perfectly and > generates the xml file in a standard java project. > > i asked the help of the developer who wrote this > library and that was his > reply: > > > Your NoClassDefFoundError is caused by a failure to > > load a suitable StAX implementation from the static > > initializer. If you are using Java 5 then you need > the > > StAX API and a StAX implementation. Both come with > the > > download in the lib directory. > so what i did is that i wrapped the stax api and > implementation inside the > library wrapper i have together with the rest of the > library jar file. i > then added this library as a dependency to my > application module. > > I'm really stuck with this for 3 days and i dunno > what else i can do to fix > it. can you help me with it? > > Thanks in advance > > Wessam > > > > > On 8/20/07, David Van Couvering > <da...@va...> wrote: > > > > You have to make sure that the package you want to > have accessible are > > exported as friends. You do this through the > project's > > Properties->API Versioning, then click on [Add...] > under "Public > > Packages" > > > > Then in the module that uses the package, you have > to add your module > > as a Library. You do this thorugh the project's > > Properties->Libraries. Click on [Add...]. Make > sure you click on > > "Show Non-API modules", and then you can type in > the name of your > > module to search for it. > > > > David > > > > On 8/20/07, Wessam Abd Rabo > <wes...@gm...> wrote: > > > hi toni, i still get the ClassDefNotFoundError > exception even after > > creating > > > the library wrapper for my external library. the > strange thing is that > > when > > > i add this same library in a java application > and not a module project > > it > > > works perefectly. once i try it out in a module, > it craches. I call it > > > inside a class implementation of a GraphScene, > can this be contributing > > to > > > the problem? > > > > > > thanks again > > > wessam > > > > > > > > > > > > > > > > > > > > > > > > On 8/20/07, Anton Epple <ep...@ge... > > wrote: > > > > > Hi Wessam, > > > > > > > > > > create a library wrapper module for your > xml serialization library: > > > > > > > > > http://wiki.netbeans.info/wiki/view/DevFaqWrapperModules > > > > > > > > > > then you can find it in the modules list. > > > > > > > > > > best, > > > > > Toni > > > > > > > > > > Wessam Abd Rabo wrote: > > > > > > > > > > > Hi, > > > > > > > > > > > > I'm developing a module in netbeans in > which i use an external > > library > > > > > > called simple framework for XML > serialization. I just call a > > function > > > > > > inside a class that extends GraphScene > class. on exectuting this > > code, > > > > > > a ClassDefNotFountError exception is > thrown. I don't include this > > > > > > library in the module dependency cause i > don't know how to do this > > if > > > > > > the library is not added to the list of > modules of nb. I tried > > putting > > > > > > the jar file of this library in all nb > folders but still i cant > > find > > > > > > it in the modules list. so i just added > the packages of this > > library > > > > > > to the source packages of my module. I > don't know if this > > contibutes > > > > > > to the problem or have nothing to do with > it. also a null pointer > > > > > > exception is thrown the 2nd time the > function is called. the > > strange > > > > > > thing is when i use this same piece of > code in a java application, > > not > > > > > > a module application, it runs perfectly. > can anyone help me with > > this? > > > > > > > > > > > > Thanks in advance, > > > > > > > > > > > > Wessam > > > > > > === message truncated === ____________________________________________________________________________________ Shape Yahoo! in your own image. Join our Network Research Panel today! http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 |