You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by David Flanagan <da...@oreilly.com> on 2000/01/04 19:33:08 UTC

can't use tag libraries with tomcat 3.0

When I try to run the taglibrary examples with tomcat 3.0 on my Redhat
3.1 box and Java 1.2.2 rc1 from Sun I get the following:

    Unhandled error! You might want to consider having an error page to report
    such errors more gracefully
    java.lang.IllegalAccessError: try to access class
    com/sun/xml/tree/ParentNode from class
    org/apache/jasper/compiler/TagLibraryInfoImpl at
    org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:155) at
    org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEve

The relevant line in TagLibraryInfoImpl.java is:

     XmlDocument webtld = JspUtil.parseXMLDoc(is, dtdURL,
                                           Constants.WEBAPP_DTD_PUBLIC_ID);

An com.sun.xml.tree.XmlDocument is a public subclass of the
package-private class ParentNode, which is itself a subclass of the
package-private class NodeBase.  If I'm understanding this bug right,
the access error occurs because although XmlDocument is public, its
superclasses are not, and therefore it is effectively not public.

I haven't checked the spec, so I don't know if this is expected
behavior.  Perhaps it is a bug in my implementation of Java, which seems
more plausible then the alternative, which would seem to be that
XmlDocument is entirely unusable.  (Another thought: does Tomcat do
anything fancy with class loaders?  Could this be causing the problem?)

In any case, I suspect the workaround is to modify Sun's parser classes
and make ParentNode and NodeBase public.  Both classes contain this
comment:

    // not public ... javadoc looks a bit odd (hidden base class)
    // but it's only subclassable within this package anyway

which indicates to me that the author realized he was doing something
weird, but thought he could get away with it...  I'd hate to have to
change code that comes all nicely pre-packaged from Sun.  I don't know
what else to do, though.

Any hints, comments, or solutions are quite welcome.  I've tried to
subscribe to this list, but appear to have failed.  Is there a human or
a machine on the other end of tomcat-dev-subscribe@jakarta.apache.org?
Do I need to put anything special in the subject line or the body of the
message?

Thanks,

	David Flanagan

Re: can't use tag libraries with tomcat 3.0

Posted by Danno Ferrin <sh...@earthlink.net>.
The error lies in the compiled class in the Tomcat 3.0 distribution and no
with anything else.  Somehow TagLibraryInfoImpl got a messed up constants
pool.  Compile tomcat from the 3.0 source and it should work fine.

--Danno

----- Original Message -----
From: "Patrick Regan" <pa...@globalcrossing.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, January 04, 2000 2:03 PM
Subject: Re: can't use tag libraries with tomcat 3.0


> David -
>
> I hit the same problem a few months ago (not with Tomcat but with an App
Server) and
> actually had to change the Sun source code as you described (yuk!).  But
for Tomcat, I can
> run the tag lib example fine under Solaris 2.6 / Tomcat 3.0 / JDK 1.2.
Are you sure its
> using the xml.jar that comes with Tomcat?  Or is it picking up an
different version of the
> jar?
>
> Patrick Regan
>
> Ps.  Assuming you are the author of the JavaScript book, I just bought it
and it looks
> great!
>
> David Flanagan wrote:
>
> > When I try to run the taglibrary examples with tomcat 3.0 on my Redhat
> > 3.1 box and Java 1.2.2 rc1 from Sun I get the following:
> >
> >     Unhandled error! You might want to consider having an error page to
report
> >     such errors more gracefully
> >     java.lang.IllegalAccessError: try to access class
> >     com/sun/xml/tree/ParentNode from class
> >     org/apache/jasper/compiler/TagLibraryInfoImpl at
> >
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java
:155) at
> >
org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEve
> >
> > The relevant line in TagLibraryInfoImpl.java is:
> >
> >      XmlDocument webtld = JspUtil.parseXMLDoc(is, dtdURL,
> >
Constants.WEBAPP_DTD_PUBLIC_ID);
> >
> > An com.sun.xml.tree.XmlDocument is a public subclass of the
> > package-private class ParentNode, which is itself a subclass of the
> > package-private class NodeBase.  If I'm understanding this bug right,
> > the access error occurs because although XmlDocument is public, its
> > superclasses are not, and therefore it is effectively not public.
> >
> > I haven't checked the spec, so I don't know if this is expected
> > behavior.  Perhaps it is a bug in my implementation of Java, which seems
> > more plausible then the alternative, which would seem to be that
> > XmlDocument is entirely unusable.  (Another thought: does Tomcat do
> > anything fancy with class loaders?  Could this be causing the problem?)
> >
> > In any case, I suspect the workaround is to modify Sun's parser classes
> > and make ParentNode and NodeBase public.  Both classes contain this
> > comment:
> >
> >     // not public ... javadoc looks a bit odd (hidden base class)
> >     // but it's only subclassable within this package anyway
> >
> > which indicates to me that the author realized he was doing something
> > weird, but thought he could get away with it...  I'd hate to have to
> > change code that comes all nicely pre-packaged from Sun.  I don't know
> > what else to do, though.
> >
> > Any hints, comments, or solutions are quite welcome.  I've tried to
> > subscribe to this list, but appear to have failed.  Is there a human or
> > a machine on the other end of tomcat-dev-subscribe@jakarta.apache.org?
> > Do I need to put anything special in the subject line or the body of the
> > message?
> >
> > Thanks,
> >
> >         David Flanagan
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
>


Re: can't use tag libraries with tomcat 3.0

Posted by Patrick Regan <pa...@globalcrossing.com>.
David -

I hit the same problem a few months ago (not with Tomcat but with an App Server) and
actually had to change the Sun source code as you described (yuk!).  But for Tomcat, I can
run the tag lib example fine under Solaris 2.6 / Tomcat 3.0 / JDK 1.2.  Are you sure its
using the xml.jar that comes with Tomcat?  Or is it picking up an different version of the
jar?

Patrick Regan

Ps.  Assuming you are the author of the JavaScript book, I just bought it and it looks
great!

David Flanagan wrote:

> When I try to run the taglibrary examples with tomcat 3.0 on my Redhat
> 3.1 box and Java 1.2.2 rc1 from Sun I get the following:
>
>     Unhandled error! You might want to consider having an error page to report
>     such errors more gracefully
>     java.lang.IllegalAccessError: try to access class
>     com/sun/xml/tree/ParentNode from class
>     org/apache/jasper/compiler/TagLibraryInfoImpl at
>     org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:155) at
>     org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEve
>
> The relevant line in TagLibraryInfoImpl.java is:
>
>      XmlDocument webtld = JspUtil.parseXMLDoc(is, dtdURL,
>                                            Constants.WEBAPP_DTD_PUBLIC_ID);
>
> An com.sun.xml.tree.XmlDocument is a public subclass of the
> package-private class ParentNode, which is itself a subclass of the
> package-private class NodeBase.  If I'm understanding this bug right,
> the access error occurs because although XmlDocument is public, its
> superclasses are not, and therefore it is effectively not public.
>
> I haven't checked the spec, so I don't know if this is expected
> behavior.  Perhaps it is a bug in my implementation of Java, which seems
> more plausible then the alternative, which would seem to be that
> XmlDocument is entirely unusable.  (Another thought: does Tomcat do
> anything fancy with class loaders?  Could this be causing the problem?)
>
> In any case, I suspect the workaround is to modify Sun's parser classes
> and make ParentNode and NodeBase public.  Both classes contain this
> comment:
>
>     // not public ... javadoc looks a bit odd (hidden base class)
>     // but it's only subclassable within this package anyway
>
> which indicates to me that the author realized he was doing something
> weird, but thought he could get away with it...  I'd hate to have to
> change code that comes all nicely pre-packaged from Sun.  I don't know
> what else to do, though.
>
> Any hints, comments, or solutions are quite welcome.  I've tried to
> subscribe to this list, but appear to have failed.  Is there a human or
> a machine on the other end of tomcat-dev-subscribe@jakarta.apache.org?
> Do I need to put anything special in the subject line or the body of the
> message?
>
> Thanks,
>
>         David Flanagan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org