You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Huaxin <hx...@cs.ualberta.ca> on 2001/11/09 20:27:15 UTC

class loaded wrong

I am moving my 3.2.3 application to 4.0.1, and it
failed to work

my jsp file uses a bean which is defined under WEB-INF/classes
(without package)

say that class is MyBean.java, the error log shows

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 4 in the jsp file: /process.jsp

Generated servlet error:
D:\henry\jakarta-tomcat-4.0.1\work\localhost\survey\process$jsp.java:61:
Class org.apache.jsp.MyBean not found.


Must I define all classes inside a package?


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: class loaded wrong

Posted by David Smith <dn...@cornell.edu>.
Thanks Craig for the info.  You do a great job with the TC 4 development and 
answering questions on the list!

I kind of thought of that after I sent the email but I did the method below 
as a fake, fudge, and cheat method in a learn-as-you-go experiment page.  
Some time soon I'll have to take the time to learn the class loading scheme 
and how to use it right. :-)

Back to reading the docs for me.....

--David Smith

On Friday 09 November 2001 02:47 pm, you wrote:
> On Fri, 9 Nov 2001, David Smith wrote:
> > Date: Fri, 9 Nov 2001 14:57:59 -0500
> > From: David Smith <dn...@cornell.edu>
> > Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> > To: Tomcat Users List <to...@jakarta.apache.org>
> > Subject: Re: class loaded wrong
> >
> > I've done this in one of my JSP pages and all I did was import the class.
> > Only specified the class name itself (no org.whatever....) and placed the
> > .class file in the WEB-INF/classes directory.  You do need to compile
> > your class though with javac or equivalent.
> >
> > I'm using Tomcat 4.0.1.
> >
> > --David Smith
> >
> > On Friday 09 November 2001 02:27 pm, you wrote:
> > > I am moving my 3.2.3 application to 4.0.1, and it
> > > failed to work
> > >
> > > my jsp file uses a bean which is defined under WEB-INF/classes
> > > (without package)
> > >
> > > say that class is MyBean.java, the error log shows
> > >
> > > org.apache.jasper.JasperException: Unable to compile class for JSP
> > >
> > > An error occurred at line: 4 in the jsp file: /process.jsp
> > >
> > > Generated servlet error:
> > > D:\henry\jakarta-tomcat-4.0.1\work\localhost\survey\process$jsp.java:61
> > >: Class org.apache.jsp.MyBean not found.
> > >
> > >
> > > Must I define all classes inside a package?
>
> To use a class that is not in a package, you have to specifically import
> it in a <%@ page %> directive.  However, you should know that this is
> likely to cause you portability problems -- you are much better off using
> fully qualified bean names in packages.
>
> Craig
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: class loaded wrong

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

On Fri, 9 Nov 2001, David Smith wrote:

> Date: Fri, 9 Nov 2001 14:57:59 -0500
> From: David Smith <dn...@cornell.edu>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: Re: class loaded wrong
>
> I've done this in one of my JSP pages and all I did was import the class.
> Only specified the class name itself (no org.whatever....) and placed the
> .class file in the WEB-INF/classes directory.  You do need to compile your
> class though with javac or equivalent.
>
> I'm using Tomcat 4.0.1.
>
> --David Smith
>
> On Friday 09 November 2001 02:27 pm, you wrote:
> > I am moving my 3.2.3 application to 4.0.1, and it
> > failed to work
> >
> > my jsp file uses a bean which is defined under WEB-INF/classes
> > (without package)
> >
> > say that class is MyBean.java, the error log shows
> >
> > org.apache.jasper.JasperException: Unable to compile class for JSP
> >
> > An error occurred at line: 4 in the jsp file: /process.jsp
> >
> > Generated servlet error:
> > D:\henry\jakarta-tomcat-4.0.1\work\localhost\survey\process$jsp.java:61:
> > Class org.apache.jsp.MyBean not found.
> >
> >
> > Must I define all classes inside a package?
> >
> >

To use a class that is not in a package, you have to specifically import
it in a <%@ page %> directive.  However, you should know that this is
likely to cause you portability problems -- you are much better off using
fully qualified bean names in packages.

Craig


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: class loaded wrong

Posted by David Smith <dn...@cornell.edu>.
I've done this in one of my JSP pages and all I did was import the class.  
Only specified the class name itself (no org.whatever....) and placed the 
.class file in the WEB-INF/classes directory.  You do need to compile your 
class though with javac or equivalent.

I'm using Tomcat 4.0.1.

--David Smith

On Friday 09 November 2001 02:27 pm, you wrote:
> I am moving my 3.2.3 application to 4.0.1, and it
> failed to work
>
> my jsp file uses a bean which is defined under WEB-INF/classes
> (without package)
>
> say that class is MyBean.java, the error log shows
>
> org.apache.jasper.JasperException: Unable to compile class for JSP
>
> An error occurred at line: 4 in the jsp file: /process.jsp
>
> Generated servlet error:
> D:\henry\jakarta-tomcat-4.0.1\work\localhost\survey\process$jsp.java:61:
> Class org.apache.jsp.MyBean not found.
>
>
> Must I define all classes inside a package?
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>