Re: [jnc-users] IllegalAccessError
Status: Beta
Brought to you by:
soapy
From: Marco T. <mt...@gm...> - 2007-09-12 08:18:08
|
Hey Ariel chosen forsaken wrote: > Hi Marco, > > I tried using your example - I added the file to my source files (on > Step 1 of GUI) and added the gcj flag for the driver.o file (using full > path) - but I got this error: > > Exception in thread "main" java.lang.NoClassDefFoundError: > org.xml.sax.helpers.XMLReaderFactory > at sv.tools.reader.ReaderFactory.main(ReaderFactory.exe) Did you ran this example: public static void main(String[] args) { try { XMLReader xmlreader = XMLReaderFactory.createXMLReader(); System.out.println(xmlreader.getClass().getName()); } catch (Exception e) { e.printStackTrace(); } } Or did you run something else? If you ran something else, please provide a minimal example. Or - assuming you're using the latest JNC and gcc version - lets just try to manually include all xml objects into the binary: 1. create a temporary folder. e.g. d:\test 2. open "cmd" and change into that folder 3. extract all objects from libgcj.a (run in cmd): path_to\gcc-122233-win\bin\ar.exe x path_to\gcc-122233-win\lib\libgcj.a 4. Delete all extracted files that have no "xml" in the name (you know how to do that automatically, right?) 5. Now remove the two files I sent you before and instead, in step 3 in the GUI, add the directory: d:\test\* With this procedure, you've the complete XML support in your binary. If everything works, you might want to try to remove some of the objects (if the application still works without them, they're not needed)... Hope that helps Marco > I also tried adding: > > static{ > org.xml.sax.helpers.XMLReaderFactory.class.getName(); > } > > to no avail... > Is there a specific location to put the static references to the classes? > > Thanks. > > Ariel > > > */Marco Trudel <mt...@gm...>/* wrote: > > Hey Ariel > > chosen forsaken wrote: > > Hi Marco, > > > > I've made a small class to better illustrate the problem: > > > > public class ReaderFactory { > > > > static{ > > SAXParser.class.getName(); > > XMLReaderFactory.class.getName(); > > } > > > > public static XMLReader getXMLReader(){ > > XMLReader xmlreader = null; > > try { > > xmlreader = XMLReaderFactory.createXMLReader(); > > // xmlreader = new SAXParser(); > > System.out.println(xmlreader.getClass().getName()); > > } catch (Exception e) { > > e.printStackTrace(); > > System.out.println("Initialization error " + e.getMessage()); > > } > > > > return xmlreader; > > } > > > > > > public static void main(String[] args) { > > XMLReaderFactory.class.getName(); > > ReaderFactory.getXMLReader(); > > } > > > > > > } > > Unfortunately, XML is always a little circuitous with JNC because the > corresponding objects aren't pulled into the binary by default. For > your > minimal example, two objects are needed. To pull them into the binary, > add the two attached files to your compilation (the java file as > source, > the object file as custom gcj flag). > Then your minimal example can be cleaned up to: > > public static void main(String[] args) > { > try > { > XMLReader xmlreader = XMLReaderFactory.createXMLReader(); > System.out.println(xmlreader.getClass().getName()); > } catch (Exception e) > { > e.printStackTrace(); > } > } > > And the output will be: > gnu.xml.stream.SAXParser > > > hope it helps > Marco > > > > > > > The settings for compilation are: > > SOURCE: > > --- Archives > > XMLFactory.jar (checked) > > xerces-2.4.0.jar (checked) > > BASIC SETTINGS: > > --- Main class > > sv.tools.reader.ReaderFactory > > --- Windows executable (checked) > > ADVANCED SETTINGS > > --- Custom GCJ Flags > > -findirect-dispatch > > -Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser > > --- ExcludeGUI (checked) > > > > Although the exception isn't IllegalAccess, I think I still am > not using > > GCJ properly... > > > > I hope my example helps in determining the problem. > > > > Thanks. > > > > > > Ariel > > > > > > */Marco Trudel /* wrote: > > > > Hey Ariel > > > > chosen forsaken wrote: > > > Hi Marco, > > > > > > I was having trouble with like this : > > > > > > Exception in thread "main" java.lang.NoClassDefFoundError: > > > org.xml.sax.helpers.XMLReaderFactory > > > > > > so I added this code to my class : > > > > > > static { > > > XMLReaderFactory.class.getName(); > > > } > > > > > > but when I compiled my class, I got an error: > > > > During compilation or later, during execution of the compiled binary? > > > > > > > Caused by: java.lang.IllegalAccessError: > sv.tools.conf.Configuration > > > can't access class org.xml.sax.helpers.XMLReaderFactory > > > > Can you post a minimal example so I can try to reproduce that? > > Where comes "sv.tools.conf.Configuration" from? > > Is this the whole exception? > > > > > > > Is this a JNC or GCJ problem? Thanks. > > > > JNC is the bundle of > > - the JNC GUI, > > - various precompiled cross and non-cross GCJs and > > - some enhancements of GCJ (partial classpath exclusion, AWT/Swing > > support, jar compilation: only referenced classes, ...). > > > > So, in this matter (your XML problem), JNC and GCJ is the same > > thing. Or > > respectively, it's a GCJ issue since JNC doesn't touch XML handling > > of GCJ. > > > > > > Marco > > > > > > > > > > > > > Ariel > > > > > > Send instant messages to your online friends > > http://uk.messenger.yahoo.com > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by: Splunk Inc. > > > Still grepping through log files to find problems? Stop. > > > Now Search log events and configuration files using AJAX and a > > browser. > > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > _______________________________________________ > > > javaCompiler-users mailing list > > > jav...@li... > > > https://lists.sourceforge.net/lists/listinfo/javacompiler-users > > > > > > Send instant messages to your online friends > http://uk.messenger.yahoo.com > > > > public class JncXmlLoader > { > static > { > gnu.xml.stream.SAXParser.class.getName(); > } > } > > > Send instant messages to your online friends http://uk.messenger.yahoo.com > |