tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Greenland" <je...@netwidedev.com>
Subject Tomcat 5 and class importing problems
Date Mon, 29 Dec 2003 23:34:35 GMT
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@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message