cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ġURDINA Michal <>
Subject Sharing cocoon.jar between multiple web aplications
Date Wed, 08 Sep 2004 13:44:07 GMT

I created ear file with about 6 war files. All war files are cocoon web applications and thus
have same WEB-INF/lib directories. The ear file has apx. 100MB due to duplicity of libraries
in WEB-INF/lib's. It seems reasonable to me to pull up those duplicit libraries at ear level
and share them among web applications.

But I'm stuck with the use of static ThreadLocal class fields in some cocoon classes. 

Good example is CocoonComponentManager.environmentStack:

this static field is used in methods 
	- enterEnvironment()
	- leaveEnvironment() 
which are call on every request process by Cocoon.process() method:

process(Environment environment) {
	try {
		CocoonComponentManager.enterEnvironment(environment, this.componentManager, this); 	// <-
	finally {
		CocoonComponentManager.leaveEnvironment();							// -> environmentStack.pop
            CocoonComponentManager.endProcessing(environment, key);

Providing that CocoonComponentManager class is located in WEB-INF/lib, we have no problem,
because every webapp gets its own class loader that creates its local instance of static field.
This field is then used only by proper webapplication and in the threadsafe manner. But if
we move CocoonComponentManager to ear level and share this class among more than one web application,
we break the contract, because only one instance of this static field will be created for
all web applications. When we consider that one application can call other one, then we can
see this not working, because multiple web aplications will be writing the same instance of
the static field. The example is CocoonComponentManager.checkEnvironment() which throws exception
when environmentStack is not empty.

The problem can be even more visible in portlet environmnet (our environment in use), when
portlet container - webapp #1 is allowed to call portlets - webapp #2-#n) parallelly in separate

That's why the use of static ThredLocal class fields should be prohibited in all cocoon component
classes. There must be some alternative for it.


Call of CocoonComponentManager.checkEnvironment in Cocoon.process() is marked as 
            // TODO (CZ): This is only for testing - remove it later on

Isn't this the proper time to remove it? Or at least to have a possibility to disable this
Thank you,


Attch: classes using the ThreadLocal static field:


View raw message