Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Developing a large java project using Tomcat, please help me

Status
Not open for further replies.

sils

Programmer
Jan 17, 2005
5
IT
Hi, all
we are developing a large java project using Tomcat.
On the same project works several persons and the project counts
serveral thousand of classes.

The project has (in few words) three big places in hich classes are stored:
- standard: a folder in which are placed all the classes (not jar but
classes)
- patches: a folder in which are places the bug-fixes of standard classes
- work in progress: a place in which a developer develop his own
modification to a standard class

Each developer has its own Tomcat.

Now, imagine that
- in standard classes is there a class named: helpme.class
- this class has been bug-fixed and in patches is there the same class
- a developer is working on its own local copy of this class and he has
places it in his own work-in-progress folder

Is possible using Tomcat to manage a situation like that?
In other word, if I develop using j2SE standard, to obtaint what i want, I
simply set my CLASSPATH
env variable in this way;

set
CLASSPATH=x:\MyWorkInProgress\classes;x:\AllPatches\classes;x:\Standard\classes

And java default class loader ensure me that it loads helpme.class first
looking in WowkInProgress,
than, if not found, in AllPatches, than, if not found in standard

Is it possible during Tomcat runtime to have something like that (possibly
WITHOUT using jar)

Thank you very much in advance.
 
Tomcat is a servlet container, not a source version control system, or a build tool !

If you are working on a large project, you should always bundle your classes into a .jar file, which is contained inside "yourWebapp/WEB-INF/lib" and your webapp should always be bundled into a deployable .war file. This way, you can build the .war any way you please, with whatever code, safe in the knowledge that you deploy it in Tomcat in a contained manner.

Look at Ant for a build tool, and VSS,RCS,CVS for version control.

Click here to learn Ways to help with Tsunami Relief
--------------------------------------------------
Free Database Connection Pooling Software
 
I know it, thanks.
The real problem is find a way to safe time during develop.
Our customers has our project shipped using jars.
But, when we develop, is needed to rebuild jar several
times during the day and it costs too much: I remember
you that we have several thousands of classes shipped
in about 30-40 jar files.
All programmers needs to have all classes (or jars)
for perform his job.
Our team needs that, when a classes is released from
a programmer, immediatly is available to other programmers
of our team.
 
sedj, probably my english is not good and I not explain me
clearly.
Is not a compile problem and is not a versioning problem.
We just use Eclipse and VSS.
But after that a class has been compiled is needed to
ship a jar for able others developers to use it in his
tomcat.
Having some thousands of classes shipped in 40 jars files it costs too much.
We need to safe time needed to ship a jar to other
developers, if possible.
So, when we "check in" the modified classes, is there
a way that allows others developers to use it in
his own tomcat without ship the whole jar?
 
I do understand your problem, and I really think you are going about your project in an incorrect manner - thats my point !

You say you have "thousands" of source files. Well, I think you should try to break these down into separate components which means just because you modify X.class doesn't mean you have to build the entire codebase. Using ant, you could compile these modified classes into independant .jar files without building the whole codebase. If you cannot achieve this, then I think you have a major problem with your project design. Otherwise you will just have to take the hit that recompiling and building the codebase will have !

Click here to learn Ways to help with Tsunami Relief
--------------------------------------------------
Free Database Connection Pooling Software
 
No, the problem is not in the way you imagine.
Our classes are all componets and each jar is
a subsystem of our project.
The project has a good desing.
The whole project runs under Tomcat.


I try to use an example to describe where is the problem
in a simple way.

Be sure that we have to problem ONLY during Tomcat runtime.

Imagine that a part of all system (e.g. the login subsystem)
has 2 classes: Login.class and ValidateUser.class
The 2 classes are shipped in a file named login.jar

All developes has its own Tomcat and uses this jar.

An upgrade is requested in Login class.
The developer check out the class, perform the upgrade,
and tests it.
After that, he check in the upgrade.

Scenario 1) (using jar files, the one that cost too much time)
He must build the jar of Login subsystem (so the two classes)
and ship it to able other developers to have to upgrade.
This is the way that now we use and works but we want
to safe more developers time.


Scenario 2) (using classes, the one that we'd like)
He puts the Login.class in another Tomcat folder
that Tomcat see before (just like the java class loader)
the folder in which is placed the Login class that has
not been updated.

java class loader do that, it looks in the classpath for
class to be loaded and stops when the class if found.

If during Tomcat runtime is possible to have:
- a folder in which is stored the project classes before the upgrade (1)
- a folder in which are stored the upgrade that
all developers must use during the runtime (2)
- a personal forder for each developer (3)

Now I'd like to set something like: classpath=(3);(2);(1)

So, it will be possible to work in this way:
- One developer "check out" Login class and puts it in folder (3)
He can develop his own job without any problem for others
developers. (Tomcat "see" only for him the modified class
because it is putted on the top of classpath only for that
developer)
- The developers that "check in" Login class and puts
it in folder (2)
Other developers, when restarts his Tomcat, immediatly
can use during Tomcat Run Time the modified Login class
(Because in Tomcat classpath the (2) folder is before the
folder (1)

Now, the team that performs the quality test can
a) Validate the upgrade
The class is moved in project folder (1)
b) Reject the upgrade
The developer move the class in its own folder so:
Tomcat of others developers continues to load using
(1) classes
Tomcat of the developer that performs the job load
class from (3) he ships the class in folder (2) and
restarts a quality test until the quality team move
the class in (1) folder

So I safe all time needed to build and ship loging.jar

I don't find another way to be more clear.
Thanks a lot for your intresting.





































 
Basically then, you are asking if Tomcat can switch between libraries held on a CLASSPATH depending on a certain condition. The short answer is no. You would have to write your own context classlodaer, and then alter the Tomcat codebase to use your loader instead of the original one.

Click here to learn Ways to help with Tsunami Relief
--------------------------------------------------
Free Database Connection Pooling Software
 
No, not depending on a certain condition.
If my classpath is always set in this way:

set CLASSPATH=(1);(2);(3)

I only like to know if Tomcat class Loader works
just like java class loader, so, as I have said in my
first post:

The class if first searched in (1) folder,
if found is loaded the class that stay in (1)
if not found
it search in (2) folder
if found is loaded the class that stay in (2)
if not found
it search in (3) folder
if found is loaded the class that stay in (3)
if not fuond an Exception is thown

This is exaclty what do the java default class loader.

Does standard Tomcat class loader do that (just like
standard java class loader) and where is the way (if one exists) to do it?




 
For webapps, the Tomcat class loader looks in TOMCAT_HOME\common\lib, and also TOMCAT_HOME\webapps\webappName\WEB-INF\lib and TOMCAT_HOME\webapps\webappName\WEB-INF\classes .

In Tomcat 5, any libraries in your webapp override those in common\lib . It does not look anywhere else (apart from server\lib but you should not use that really).

Click here to learn Ways to help with Tsunami Relief
--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top