You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by "Fred R." <fr...@sourcetechcorp.com> on 2000/07/21 20:54:18 UTC

error using taglib

I'm trying to use a taglib library that I've developed and I keep
getting the follwoing error. The interesting thing is that if the
web.xml has only the taglib tags I get no error and everything works
fine. Any idea what could be wrong? I've been fighting this problem
almost all day. Obviously the error message is not the indicator of the
actual error here. I love tomcat, but in this case I wish it would give
a more descriptive error.

TIA.
Fred R.

org.apache.jasper.JasperException: Unable to open taglibrary /xxxtags :
Parse Error in the tag library descriptor: Element "web-app" does not
allow "init-param" here.
        at
org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEventListener.java,
Compiled Code)
        at
org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingListener.java:116)

        at
org.apache.jasper.compiler.Parser$Directive.accept(Parser.java, Compiled
Code)
        at org.apache.jasper.compiler.Parser.parse(Parser.java, Compiled
Code)
        at org.apache.jasper.compiler.Parser.parse(Parser.java:1038)
        at org.apache.jasper.compiler.Parser.parse(Parser.java:1034)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java,
Compiled Code)
        at
org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:413)
        at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:149)

        at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:161)

        at
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)

        at org.apache.jasper.runtime.JspServlet.service(JspServlet.java,
Compiled Code)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
Compiled Code)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java,
Compiled Code)
        at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java,
Compiled Code)
        at java.lang.Thread.run(Thread.java, Compiled Code)




Re: error using taglib

Posted by Justyna Horwat <Ju...@eng.sun.com>.
The order of servlet elements is defined in the servlet specification.

http://java.sun.com/products/servlet/download.html

Chapter 13 talks about dtd's and gives some examples.

If you are familiar with dtd's you can take a look at the web.xml dtd
directly:

http://java.sun.com/j2ee/dtds/web-app_2_2.dtd

The structure of you web.xml file has to follow the rules defined in the
dtd. Order is important.

Without seeing your web.xml file I can't tell you what is wrong exactly
but I can give you an example that would cause the error like you're seeing.

In the dtd defined in the spec, the servlet element is defined as follows:

<!ELEMENT servlet (icon?, servlet-name, display-name?, description?,
(servlet-class|jsp-file), init-param*, load-on-startup?,
security-role-ref*)>

Here is what an incorrect servlet element could look like. Note that I
have <load-on-startup> coming before <init-param>. This is INCORRECT
and would cause the error that you see:

...
<servlet>
  <servlet-name>myservlet</servletname>
  <load-on-startup>1</load-on-startup>
  <init-partam>
    <param-name>myparam</param-name>
    <param-value>0</param-value>
  </init-param>
</servlet>
...

Make sure that the order of your elements is correct as specified in the
dtd.

Here's an FYI, Tomcat 3.1 does not use a validating parser when reading
the web.xml file. That is why you didn't see an error on start-up. When you
access the JSP page, the Jasper compiler reads the web.xml. It is the JSP
page compiler that uses a validating parser and reports an error if the
contents
are invalid.

Justyna
< horwat@eng.sun.com >

----- Original Message -----
From: "Fred R." <fr...@sourcetechcorp.com>
To: <ta...@jakarta.apache.org>
Sent: Friday, July 21, 2000 11:54 AM
Subject: error using taglib


> I'm trying to use a taglib library that I've developed and I keep
> getting the follwoing error. The interesting thing is that if the
> web.xml has only the taglib tags I get no error and everything works
> fine. Any idea what could be wrong? I've been fighting this problem
> almost all day. Obviously the error message is not the indicator of the
> actual error here. I love tomcat, but in this case I wish it would give
> a more descriptive error.
>
> TIA.
> Fred R.
>
> org.apache.jasper.JasperException: Unable to open taglibrary /xxxtags :
> Parse Error in the tag library descriptor: Element "web-app" does not
> allow "init-param" here.
>         at
>
org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEve
ntListener.java,
> Compiled Code)
>         at
>
org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingList
ener.java:116)
>
>         at
> org.apache.jasper.compiler.Parser$Directive.accept(Parser.java, Compiled
> Code)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java, Compiled
> Code)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java:1038)
>         at org.apache.jasper.compiler.Parser.parse(Parser.java:1034)
>         at org.apache.jasper.compiler.Compiler.compile(Compiler.java,
> Compiled Code)
>         at
> org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:413)
>         at
>
org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspSe
rvlet.java:149)
>
>         at
>
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:161)
>
>         at
> org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
>
>         at org.apache.jasper.runtime.JspServlet.service(JspServlet.java,
> Compiled Code)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
> Compiled Code)
>         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
>         at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java,
> Compiled Code)
>         at
> org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java,
> Compiled Code)
>         at java.lang.Thread.run(Thread.java, Compiled Code)
>
>
>


Re: error using taglib

Posted by Hans Bergsten <ha...@gefionsoftware.com>.
"Fred R." wrote:
> 
> Hans,
> 
> Thanks for your reply. I thought that may be the problem so I removed all
> <init-param> tags and the error message moved to the next item in the web.xml
> (which is a context tag).  A collegue of mine said that he got the same error
> when the package/class name had a different case than the actual class name.
> I checked that too. But I'm still having the same problem.

This has nothing to do with class names, only the order of the elements.
You must follow the order defined by the DTD for all elements. Apparently
it was not only the <init-param> elements that were out of order in your
web.xml file.

Hans
-- 
Hans Bergsten		hans@gefionsoftware.com
Gefion Software		http://www.gefionsoftware.com

Re: error using taglib

Posted by "Fred R." <fr...@sourcetechcorp.com>.
Hans,

Thanks for your reply. I thought that may be the problem so I removed all
<init-param> tags and the error message moved to the next item in the web.xml
(which is a context tag).  A collegue of mine said that he got the same error
when the package/class name had a different case than the actual class name.
I checked that too. But I'm still having the same problem.

Thanks,
Fred R.

Hans Bergsten wrote:

> "Fred R." wrote:
> >
> > I'm trying to use a taglib library that I've developed and I keep
> > getting the follwoing error. The interesting thing is that if the
> > web.xml has only the taglib tags I get no error and everything works
> > fine. Any idea what could be wrong? I've been fighting this problem
> > almost all day. Obviously the error message is not the indicator of the
> > actual error here. I love tomcat, but in this case I wish it would give
> > a more descriptive error.
> >
> > TIA.
> > Fred R.
> >
> > org.apache.jasper.JasperException: Unable to open taglibrary /xxxtags :
> > Parse Error in the tag library descriptor: Element "web-app" does not
> > allow "init-param" here.
> > [...]
>
> This means that you have an <init-param> element somewhere in the web.xml
> where it's not valid according to the DTD. The order of the elements is
> significant and defined by the DTD. Look at the DTD, either online (the
> URL is in the web.xml file) or in the Servlet 2.2 specification to see
> how the elements must be ordered.
>
> Hans
> --
> Hans Bergsten           hans@gefionsoftware.com
> Gefion Software         http://www.gefionsoftware.com

--
Fred Rahmanian
Certified Inprise Instructor (Delphi 5/JBuilder 3)
Sun Certified Java Programmer
http://www.sourcetechcorp.com



Re: error using taglib

Posted by Hans Bergsten <ha...@gefionsoftware.com>.
"Fred R." wrote:
> 
> I'm trying to use a taglib library that I've developed and I keep
> getting the follwoing error. The interesting thing is that if the
> web.xml has only the taglib tags I get no error and everything works
> fine. Any idea what could be wrong? I've been fighting this problem
> almost all day. Obviously the error message is not the indicator of the
> actual error here. I love tomcat, but in this case I wish it would give
> a more descriptive error.
> 
> TIA.
> Fred R.
> 
> org.apache.jasper.JasperException: Unable to open taglibrary /xxxtags :
> Parse Error in the tag library descriptor: Element "web-app" does not
> allow "init-param" here.
> [...]

This means that you have an <init-param> element somewhere in the web.xml
where it's not valid according to the DTD. The order of the elements is
significant and defined by the DTD. Look at the DTD, either online (the
URL is in the web.xml file) or in the Servlet 2.2 specification to see
how the elements must be ordered.

Hans
-- 
Hans Bergsten		hans@gefionsoftware.com
Gefion Software		http://www.gefionsoftware.com