jQuery in Action, 3rd edition
The moose likes XML and Related Technologies and the fly likes  XML Parsing Error: junk after document element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark " XML Parsing Error: junk after document element " Watch " XML Parsing Error: junk after document element " New topic

XML Parsing Error: junk after document element

Romeo Ranjan
Ranch Hand

Joined: Feb 23, 2009
Posts: 95
Hi All,

I get this "XML Parsing Error: junk after document element" error. I what to know what is the meaning of this error and how do I rectify in order to make my code work.

I am trying to use SVG web toolkit in my j2ee application. Below is detailed version of the error that I get on my jsp page instead of vector graphics.

XML Parsing Error: junk after document element
Location: http://localhost:8080/appname
Line Number 21, Column 1:
<svg id ="name"

I am not sure if the log file is of help. This is what the log file has

Sep 8, 2010 11:50:22 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet jsp as unavailable
Sep 8, 2010 11:50:22 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /applicationname threw load() exception
java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at org.apache.jasper.servlet.JspServlet.<init>(JspServlet.java:57)
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 java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)


SCJP 6.0
David Newton

Joined: Sep 29, 2008
Posts: 12617

If nothing else: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory

So you're missing a dependency.

And if the error is showing up on line 21, why wouldn't you post the lines up to that line?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Sounds like your svg tag is being parsed by the JSP parser as a JSP tag.

You want to embed SVG in the output content so you need to treat it like html tags not seen by the JSP parser.

Here is an article on SVG in HTML

I agree. Here's the link: http://aspose.com/file-tools
subject: XML Parsing Error: junk after document element
It's not a secret anymore!