You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Rickard Öberg <ri...@xpedio.com> on 2001/09/13 12:40:35 UTC

Tomcat4-RC1: parse exception on taglibs

Hey

I've finally managed to get Catalina working with JBoss (I had not set
"catalina.base", but no error was produced, just nothing happened).

Anyway, the first thing I try is to deploy an app with a taglib JAR,
with the TLD inside. But it seems like there's something wrong with the
TLD parsing because I get this:
org.xml.sax.SAXParseException: The markup in the document preceding the
root element must
be well-formed.

And this happens no matter what I do with the actual TLD.

Removing the taglib makes the WAR deploy properly, so it's definitely
that which blows up.

Any ideas?

/Rickard

-- 
Rickard Öberg
Software Development Specialist
xlurc - Xpedio Linköping Ubiquitous Research Center
Author of "Mastering RMI"
Email: rickard@xpedio.com

Re: Tomcat4-RC1: parse exception on taglibs

Posted by "Craig R. McClanahan" <cr...@apache.org>.
Please do report to the bug tracking system:

  http://nagoya.apache.org/bugzilla/

Craig


On Thu, 13 Sep 2001, Rickard Öberg wrote:

> Date: Thu, 13 Sep 2001 17:18:36 +0200
> From: Rickard Öberg <ri...@xpedio.com>
> Reply-To: tomcat-dev@jakarta.apache.org
> To: tomcat-dev@jakarta.apache.org
> Subject: Re: Tomcat4-RC1: parse exception on taglibs
>
> Rickard Öberg wrote:
> > Rickard Öberg wrote:
> > > I've finally managed to get Catalina working with JBoss (I had not set
> > > "catalina.base", but no error was produced, just nothing happened).
> > >
> > > Anyway, the first thing I try is to deploy an app with a taglib JAR,
> > > with the TLD inside. But it seems like there's something wrong with the
> > > TLD parsing because I get this:
> > > org.xml.sax.SAXParseException: The markup in the document preceding the
> > > root element must
> > > be well-formed.
> > >
> > > And this happens no matter what I do with the actual TLD.
> > >
> > > Removing the taglib makes the WAR deploy properly, so it's definitely
> > > that which blows up.
> >
> > This apparently only happens when the WAR is deployed through the
> > EmbeddedManager MBean. When deploying the same WAR, with the taglib, as
> > a webapp by placing it in /webapps and running startup.bat, there is no
> > error.
>
> Even more info. Setting debug level to high, and looking in the logs I
> found this:
> 2001-09-13 17:12:35 ContextConfig[/webwork]:   URI='webwork',
> ResourcePath='/WEB-INF/lib/webwork.jar'
> 2001-09-13 17:12:35 ContextConfig[/webwork]:
> tldConfigJar(/WEB-INF/lib/webwork.jar): java.lang.IllegalStateException:
> zip file closed
> 2001-09-13 17:12:35 ContextConfig[/webwork]:
> tldConfigTld(/WEB-INF/lib/webwork.jar): org.xml.sax.SAXParseException:
> The markup in the document preceding the root element must be
> well-formed.
>
> This does not happen if the webapp is deployed in /webapps and I run
> Tomcat4 through startup.bat, only when I do it using the EmbeddedManager
> MBean.
>
> Any ideas? Should I just send this to the bug tracker and await any
> response?
>
> /Rickard
>
> --
> Rickard Öberg
> Software Development Specialist
> xlurc - Xpedio Linköping Ubiquitous Research Center
> Author of "Mastering RMI"
> Email: rickard@xpedio.com
>


Re: Tomcat4-RC1: parse exception on taglibs

Posted by Rickard Öberg <ri...@xpedio.com>.
Rickard Öberg wrote:
> Rickard Öberg wrote:
> > I've finally managed to get Catalina working with JBoss (I had not set
> > "catalina.base", but no error was produced, just nothing happened).
> >
> > Anyway, the first thing I try is to deploy an app with a taglib JAR,
> > with the TLD inside. But it seems like there's something wrong with the
> > TLD parsing because I get this:
> > org.xml.sax.SAXParseException: The markup in the document preceding the
> > root element must
> > be well-formed.
> >
> > And this happens no matter what I do with the actual TLD.
> >
> > Removing the taglib makes the WAR deploy properly, so it's definitely
> > that which blows up.
> 
> This apparently only happens when the WAR is deployed through the
> EmbeddedManager MBean. When deploying the same WAR, with the taglib, as
> a webapp by placing it in /webapps and running startup.bat, there is no
> error.

Even more info. Setting debug level to high, and looking in the logs I
found this:
2001-09-13 17:12:35 ContextConfig[/webwork]:   URI='webwork',
ResourcePath='/WEB-INF/lib/webwork.jar'
2001-09-13 17:12:35 ContextConfig[/webwork]:    
tldConfigJar(/WEB-INF/lib/webwork.jar): java.lang.IllegalStateException:
zip file closed
2001-09-13 17:12:35 ContextConfig[/webwork]:    
tldConfigTld(/WEB-INF/lib/webwork.jar): org.xml.sax.SAXParseException:
The markup in the document preceding the root element must be
well-formed.

This does not happen if the webapp is deployed in /webapps and I run
Tomcat4 through startup.bat, only when I do it using the EmbeddedManager
MBean.

Any ideas? Should I just send this to the bug tracker and await any
response?

/Rickard

-- 
Rickard Öberg
Software Development Specialist
xlurc - Xpedio Linköping Ubiquitous Research Center
Author of "Mastering RMI"
Email: rickard@xpedio.com

Re: Tomcat4-RC1: parse exception on taglibs

Posted by Rickard Öberg <ri...@xpedio.com>.
Rickard Öberg wrote:
> I've finally managed to get Catalina working with JBoss (I had not set
> "catalina.base", but no error was produced, just nothing happened).
> 
> Anyway, the first thing I try is to deploy an app with a taglib JAR,
> with the TLD inside. But it seems like there's something wrong with the
> TLD parsing because I get this:
> org.xml.sax.SAXParseException: The markup in the document preceding the
> root element must
> be well-formed.
> 
> And this happens no matter what I do with the actual TLD.
> 
> Removing the taglib makes the WAR deploy properly, so it's definitely
> that which blows up.

This apparently only happens when the WAR is deployed through the
EmbeddedManager MBean. When deploying the same WAR, with the taglib, as
a webapp by placing it in /webapps and running startup.bat, there is no
error.

/Rickard

-- 
Rickard Öberg
Software Development Specialist
xlurc - Xpedio Linköping Ubiquitous Research Center
Author of "Mastering RMI"
Email: rickard@xpedio.com

Re: Tomcat4-RC1: parse exception on taglibs

Posted by Remy Maucherat <re...@apache.org>.
> "Craig R. McClanahan" wrote:
> > Yesterday, I added an update to Embedded.start() to set "catalina.base"
to
> > the value of "catalina.home" if it's not already set.  That way, others
> > won't get bit by this one.
>
> Yes, I saw the commit message in CVS, which hinted that I should do it
> manually with RC1. :-)
>
> > It's certainly an odd symptom.  One potentially significant
environmental
> > difference is that Embedded does not set up the usual class loader
> > hierarchy that org.apache.catalina.startup.Bootstrap does.  What is the
> > class loader environment when you're running into this?
>
> The parent classloader is set to the application classloader that JBoss
> provides. The code I use to access the EmbeddedManager looks like this:
>    protected WebApplication performDeploy(String ctxPath, String warUrl,
> AbstractWebContainer.WebDescriptorParser webAppParser) throws Exception
>    {
>       String deployPath = ctxPath.equals("/") ? "" : ctxPath;
>       ClassLoader ctxClassLoader =
> Thread.currentThread().getContextClassLoader();
>       Context ctx = mapper.deploy(deployPath, warUrl);
>       ctx.setParentClassLoader(ctxClassLoader);
>       ClassLoader scl = (ClassLoader) ctx.getLoader().getClassLoader();
>
>       ServletContext servletCtx = ctx.getServletContext();
> //      Element webXml = (Element) ctx.getAttribute("web-app.xml");
> //      Element jbossWebXml = (Element)
> ctx.getAttribute("jboss-web.xml");
>       URL url = new URL(warUrl);
>       WebApplication appInfo = new WebApplication(url.getFile(), url,
> scl);
> //      appInfo.setWebApp(webXml);
> //      appInfo.setJbossWeb(jbossWebXml);
>       appInfo.setAppData(ctx);
>
>       return appInfo;
>    }
> and mapper.deploy looks like this:
>    public Context deploy(String cxPath, String warUrl) throws
> DeploymentException
>    {
>       if (warUrl.startsWith("file:"))
>          warUrl = warUrl.substring(5);
>       try
>       {
>          Context context = (Context) mBServ.invoke(catName,
> "createContext", new Object[]{ cxPath,warUrl }, new String[]{
> "java.lang.String", "java.lang.String" });
>          StandardLoader loader = new
> StandardLoader(Thread.currentThread().getContextClassLoader());

That's unrelated, but maybe you should try using the WebappLoader (if what
you're loading is a webapp, of course). It is more robust (and a lot faster
too) than the StandardLoader.

>          context.setLoader(loader);
>          context.setReloadable(true);
>          deployHost.addChild(context);
>          return context;
>       } catch (RuntimeErrorException e)
>       {
>          e.getTargetError().printStackTrace();
>          throw new DeploymentException(e.getLocalizedMessage());
>       } catch (Exception e)
>       {
>          e.printStackTrace();
>          throw new DeploymentException(e.getLocalizedMessage());
>       }
>    }
> ---
> (Yes the parent CL is set twice, which is redundant, but shouldn't cause
> any actual problems).
>
> Any ideas on this?

Not yet. I tried things with the Embedded class and it worked decent.
Try the small patch to ContextConfig I mentined in the comments in the bug
(if you use a Catalina version built from CVS, of course), as the exception
you get is interesting - I want to see where it happens.

Note: The ctxPath *must* start with a "/". If it doesn't, it will break when
trying to use getResource (the algorithm is picky on the path parsing at the
moment, and it will be made more robust later).

> I'm developing this by mostly guessing how to do it
> properly, so any more educated guesses would be appreciated :-) You have
> no idea how much I want this to work! 8-)

:)

Remy


Re: Tomcat4-RC1: parse exception on taglibs

Posted by Rickard Öberg <ri...@xpedio.com>.
"Craig R. McClanahan" wrote:
> Yesterday, I added an update to Embedded.start() to set "catalina.base" to
> the value of "catalina.home" if it's not already set.  That way, others
> won't get bit by this one.

Yes, I saw the commit message in CVS, which hinted that I should do it
manually with RC1. :-)

> It's certainly an odd symptom.  One potentially significant environmental
> difference is that Embedded does not set up the usual class loader
> hierarchy that org.apache.catalina.startup.Bootstrap does.  What is the
> class loader environment when you're running into this?

The parent classloader is set to the application classloader that JBoss
provides. The code I use to access the EmbeddedManager looks like this:
   protected WebApplication performDeploy(String ctxPath, String warUrl,
AbstractWebContainer.WebDescriptorParser webAppParser) throws Exception
   {
      String deployPath = ctxPath.equals("/") ? "" : ctxPath;
      ClassLoader ctxClassLoader =
Thread.currentThread().getContextClassLoader();
      Context ctx = mapper.deploy(deployPath, warUrl);
      ctx.setParentClassLoader(ctxClassLoader);
      ClassLoader scl = (ClassLoader) ctx.getLoader().getClassLoader();

      ServletContext servletCtx = ctx.getServletContext();
//      Element webXml = (Element) ctx.getAttribute("web-app.xml");
//      Element jbossWebXml = (Element)
ctx.getAttribute("jboss-web.xml");
      URL url = new URL(warUrl);
      WebApplication appInfo = new WebApplication(url.getFile(), url,
scl);
//      appInfo.setWebApp(webXml);
//      appInfo.setJbossWeb(jbossWebXml);
      appInfo.setAppData(ctx);

      return appInfo;
   }
and mapper.deploy looks like this:
   public Context deploy(String cxPath, String warUrl) throws
DeploymentException
   {
      if (warUrl.startsWith("file:"))
         warUrl = warUrl.substring(5);
      try
      {
         Context context = (Context) mBServ.invoke(catName,
"createContext", new Object[]{ cxPath,warUrl }, new String[]{
"java.lang.String", "java.lang.String" });
         StandardLoader loader = new
StandardLoader(Thread.currentThread().getContextClassLoader());
         context.setLoader(loader);
         context.setReloadable(true);
         deployHost.addChild(context);
         return context;
      } catch (RuntimeErrorException e)
      {
         e.getTargetError().printStackTrace();
         throw new DeploymentException(e.getLocalizedMessage());
      } catch (Exception e)
      {
         e.printStackTrace();
         throw new DeploymentException(e.getLocalizedMessage());
      }
   }
---
(Yes the parent CL is set twice, which is redundant, but shouldn't cause
any actual problems).

Any ideas on this? I'm developing this by mostly guessing how to do it
properly, so any more educated guesses would be appreciated :-) You have
no idea how much I want this to work! 8-)

/Rickard

-- 
Rickard Öberg
Software Development Specialist
xlurc - Xpedio Linköping Ubiquitous Research Center
Author of "Mastering RMI"
Email: rickard@xpedio.com

Re: Tomcat4-RC1: parse exception on taglibs

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 13 Sep 2001, Rickard Öberg wrote:

> Date: Thu, 13 Sep 2001 12:40:35 +0200
> From: Rickard Öberg <ri...@xpedio.com>
> Reply-To: tomcat-dev@jakarta.apache.org
> To: "tomcat-dev@jakarta.apache.org" <to...@jakarta.apache.org>
> Subject: Tomcat4-RC1: parse exception on taglibs
>
> Hey
>
> I've finally managed to get Catalina working with JBoss (I had not set
> "catalina.base", but no error was produced, just nothing happened).
>

Yesterday, I added an update to Embedded.start() to set "catalina.base" to
the value of "catalina.home" if it's not already set.  That way, others
won't get bit by this one.

> Anyway, the first thing I try is to deploy an app with a taglib JAR,
> with the TLD inside. But it seems like there's something wrong with the
> TLD parsing because I get this:
> org.xml.sax.SAXParseException: The markup in the document preceding the
> root element must
> be well-formed.
>
> And this happens no matter what I do with the actual TLD.
>
> Removing the taglib makes the WAR deploy properly, so it's definitely
> that which blows up.
>
> Any ideas?
>

It's certainly an odd symptom.  One potentially significant environmental
difference is that Embedded does not set up the usual class loader
hierarchy that org.apache.catalina.startup.Bootstrap does.  What is the
class loader environment when you're running into this?

> /Rickard
>

Craig