Resolution as found on http://stackoverflow.com/questions/7891250/batik-not-in-classpath
XML Commons needs to be included with the project. Thanks, Mark -----Original Message----- From: Mark Riley [mailto:mark.ri...@seriousintegrated.com] Sent: Thursday, August 22, 2013 1:09 PM To: batik-users@xmlgraphics.apache.org Subject: RE: Problems loading an SVG file to Document Yes that worked. Thank you. java.lang.NoClassDefFoundError: org/w3c/dom/svg/SVGDocument while loading org.apache.batik.dom.svg.SVGOMDocument; see http://wiki.netbeans.org/DevFaqTroubleshootClassNotFound at org.netbeans.ProxyClassLoader.selfLoadClass(ProxyClassLoader.java:304) at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:227) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at com.seriousintegrated.ship.propertysets.ImagePropertySet.setScaledVectorImage(ImagePropertySet.java:166) at com.seriousintegrated.ship.propertysets.ImagePropertySet.mashImage(ImagePropertySet.java:144) at com.seriousintegrated.ship.propertysets.ImagePropertySet.mash(ImagePropertySet.java:328) at com.seriousintegrated.ship.objects.SHIPObject.mashProperties(SHIPObject.java:960) at com.seriousintegrated.ship.objects.SHIPObject.mash(SHIPObject.java:989) at com.seriousintegrated.ship.objects.SHIPObject.mash(SHIPObject.java:1005) at com.seriousintegrated.ship.objects.DryLandObject.mash(DryLandObject.java:101) at com.seriousintegrated.ship.base.SHIP.mash(SHIP.java:412) at com.seriousintegrated.ship.tide.settings.project.MashWorker.doInBackground(MashWorker.java:42) at com.seriousintegrated.ship.tide.settings.project.MashWorker.doInBackground(MashWorker.java:23) at javax.swing.SwingWorker$1.call(SwingWorker.java:296) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at javax.swing.SwingWorker.run(SwingWorker.java:335) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/svg/SVGDocument at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at org.netbeans.JarClassLoader.doLoadClass(JarClassLoader.java:274) at org.netbeans.ProxyClassLoader.selfLoadClass(ProxyClassLoader.java:300) ... 19 more Caused by: java.lang.ClassNotFoundException: org.w3c.dom.svg.SVGDocument starting from ModuleCL@6d3ac260[com.seriousintegrated.ship.base] with possible defining loaders null and declared parents [ModuleCL@680112df[org.netbeans.modules.csl.api], ModuleCL@44925e1f[org.netbeans.spi.editor.hints], ModuleCL@77dcf9f4[org.netbeans.modules.parsing.api], ModuleCL@58a769d7[org.netbeans.libs.junit4], ModuleCL@2f0496f0[org.netbeans.modules.lexer], org.netbeans.MainImpl$BootClassLoader@af5b2da, ModuleCL@340c7a1b[com.seriousintegrated.ship.tide.resources], ModuleCL@78fcc563[org.openide.loaders], ModuleCL@236077c2[org.netbeans.api.progress], ModuleCL@3d47dde[org.openide.nodes]] at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:264) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ... 23 more Caused by: java.lang.ClassNotFoundException: org.w3c.dom.svg.SVGDocument at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:262) ... 24 more -----Original Message----- From: Robert Marcano [mailto:rob...@marcanoonline.com] Sent: Thursday, August 22, 2013 12:29 PM To: batik-users@xmlgraphics.apache.org Subject: Re: Problems loading an SVG file to Document On 08/22/2013 01:44 PM, Mark Riley wrote: > I don't get any generated crash files nor a stack trace. > > With your provided code it fails at the same spot > > > String parser = > XMLResourceDescriptor.getXMLParserClassName(); > > SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); > //Fails here, Drops into a FINALLY statement in the application. You must have some code in those multiple layer of your applcation that must be eating the Exception (do a try/catch and not print/, log or re/throw exception) try this SAXSVGDocumentFactory f = null; try { f = new SAXSVGDocumentFactory(parser); } catch (Throwable e) { // Notice that it is Throwable and not Exception, // it catches Error too e.printStackTrace(); throw e; } > > String uri = image.getFilename(); > System.out.println(uri); > File file = new File("myFile.svg"); > FileUtils.copyInputStreamToFile(image.getStream(), file); > System.out.println("File saved"); > > InputStream is = new BufferedInputStream(new > FileInputStream(file)); > Document doc = f.createDocument(uri, is); > is.close(); > > The code that calls it looks like > > try { > setProgress(1); > ship.mash(); > } catch (Exception ex) { > StatusDisplayer.getDefault().setStatusText("Project verify > failed!"); > LOGGER.log(Level.SEVERE, "\nVerify failed!\n"); > Exceptions.printStackTrace(ex); > } finally { > } > return ship; > > ship.mash() starts a long process of verifying the users information which in > turn calls the SVG code. When the SVG code 'Fails' it falls into the finally > statement. > > Thanks > Mark > > -----Original Message----- > From: Robert Marcano [mailto:rob...@marcanoonline.com] > Sent: Thursday, August 22, 2013 6:03 AM > To: batik-users@xmlgraphics.apache.org > Subject: Re: Problems loading an SVG file to Document > > On 08/21/2013 06:17 PM, Mark Riley wrote: >> I can't seem to get it to generate a stack trace. It's being run in a thread >> and the thread just dies. >> >> I put a break point at SAXSVGDocumentFactory and when I try to step >> into it the thread dies. This code is surrounded by a try-catch so >> I'm not too sure what's going on. Sorry, I know that info is not too >> helpful. I just seem to lose the paper trail right at >> SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); >> >> Thanks, >> Mark > > > Ummm a crash instead of stack trace! > > If it is a JVM crash check the directory where the application is > running, you should find a crash dump file there. You can force a > location with the JVM option -XX:ErrorFile=path_to_file/java_error.log > or any file name you want, do not run it under a debugger and check > for the generated file > > try something like (this is a test no pretty code), lets see if you get > printed if the contents if read and saved to a file, probably the crash > happens reading the stream and not parsing it: > > ========================= > String parser = XMLResourceDescriptor.getXMLParserClassName(); > > SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); > > String uri = image.getFilename(); > System.out.println(uri); > File file = new File("myFile.svg"); > FileUtils.copyTofile(image.getStream(), file); > System.out.println("File saved"); > > InputStream is = new BufferedInputStream(new FileInputStream(file)); > Document doc = f.createDocument(uri, is); is.close(); > ========================= > > >> >> -----Original Message----- >> From: Robert Marcano [mailto:rob...@marcanoonline.com] >> Sent: Wednesday, August 21, 2013 3:35 PM >> To: batik-users@xmlgraphics.apache.org >> Subject: Re: Problems loading an SVG file to Document >> >> On 08/21/2013 12:27 PM, Mark Riley wrote: >>> Im using the code: >>> >>> String parser = XMLResourceDescriptor.getXMLParserClassName(); >>> >>> SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); >>> >>> Document doc = f.createDocument(image.getFilename(), >>> image.getStream()); >>> >>> It seems parser returns null and my application crashes out. >> >> Can you copy the stacktrace, because it is normal for >> getXMLParserClassName() to returns null, the default parser is the JRE >> included parser. >> >> See: >> >> http://svn.apache.org/viewvc/xmlgraphics/batik/tags/batik-1_7/sources >> / >> org/apache/batik/dom/util/SAXDocumentFactory.java?revision=608260&vie >> w >> =markup >> >> Line 404 >> >> >>> >>> Thanks, >>> >>> Mark >>> >> --------------------------------------------------------------------- To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org