Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Tomcat 5 and class importing problems

Tomcat 5 and class importing problems

2003-12-29       - By Jeff Greenland

 Back
Reply:     1     2  

Hello all, sorry this is long, but it takes time to explain,

I'm having a frustrating issue with JSP files and trying to import our
custom classes.  Originally the classes were developed when Tomcat 3 was
out and being used, so putting all of our compiled (*.class) files into
"webapps\WEB-INF\classes" worked fine -- the JSPs all ran and could see
& import the classes just dandy.  When we upgraded to Tomcat 4, the
classes were no longer visible.  After some research and testing, we
found that placing a:
<%@ page import="MyClass" %>
At the top of each JSP file solved the problem.  Kinda cumbersome to add
that for every class that we used, but it worked.

Now we are attempting to upgrade to Tomcat 5 and are again having class
loading issues.  The import line is causing the following error:

D:\Jakarta5\work\Catalina\166.70.225.99\_\org\apache\jsp\site_jsp.java:8
: '.' expected
import MyClass;

Obviously the compiler is expecting a package name in order to import
external classes (which I realize is probably a function of javac, not
of tomcat).  The first thing I did was to convert our entire class
library to packages (it originally wasn't when it was developed several
years ago).  I then copied these classes to the WEB-INF\classes folder
and the application began running.  However, the next problem arose when
some of our code was doing dynamic class instantiation (using
Class.forName()) since all of the class names had changed.  So, of
course, I fixed that throughout the code, which brought me to my present
position:  serialization.

Many of our classes contain state information which we serialize to a
database.  However, now that all of the class names have changed, we
cannot deserialize any of our existing objects because the class names
don't match (ClassCastException is what's being thrown, if I remember
right).

Realizing that we cannot lose our serialized objects (since they contain
all of our customers' data), I have been looking into other options.
Some of the things I have tried are putting the class files (the
original -- before repackaging them) into JAR files, changing the
scratch directory for compilation in hopes that the compiler will find
our classes, and moving classes into various folders to see if they can
be found.

So, now that I've spoke my novel, here's my question:  Is there a way I
can simply allow Tomcat to import *.class from
"webapps\WEB-INF\classes\" and have them all available to my JSP (like
it used to work in Tomcat 3)?  The problem is simple -- I need my
non-packaged classes to be available to my .JSP files.  Yes, I realize
that we should have the files all in the same package from the
beginning, but we don't.  Our hope is that finding a solution that will
make it work will cost us less time/money than rebuilding all of the
serialized objects in our customers' databases (which I haven't thought
of a good way to do that yet, either).

Any help or suggestions that anyone has is GREATLY appreciated.  I've
been fairly impressed with the Jakarta community as I've used the
products over the past several years.

Thanks in advance,

Jeff

P.S.  Theoretically it shouldn't make a difference, but this is being
deployed on a Windows Server 2003 machine.

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)




©2008 junlu.com - Jax Systems, LLC, U.S.A.