You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Stefano Mazzocchi <st...@apache.org> on 2003/02/27 17:51:58 UTC

problem with forehead

Bob,

Cocoon is using Forehead to bootstrap its services. We found a weird 
problem related to JDK 1.3.1 which is probably a JDK bug that was fixed 
on 1.4.1.

This is related to the fact that the entry point class we call extends 
another class that exposes a main() method. It seems that Forehead calls 
the right method, but JDK 1.3.1 invoques the method of the super class 
instead of the one of the extending class.

I found out that if I modify the Forehead.run() method like the following:

     public void run(String[] args)
        throws
            NoSuchMethodException,
            IllegalAccessException,
            InvocationTargetException
     {
         Class[] method_param_types = new Class[1];
         method_param_types[0] = args.getClass();

         Method main = 
this.entryClass.getDeclaredMethod("main",method_param_types);

         Object[] method_params = new Object[1];
         method_params[0] = args;

         Thread.currentThread().setContextClassLoader( this.entryLoader );

         main.invoke(null,method_params);
     }

the problem goes away.

I'm recompiling forehead with this patch to include in Cocoon, but I'd 
be happy to see this bug fixed in the main Forehead distribution.

Thanks.

-- 
Stefano Mazzocchi                               <st...@apache.org>
    Pluralitas non est ponenda sine necessitate [William of Ockham]
--------------------------------------------------------------------



Re: problem with forehead

Posted by bob mcwhirter <bo...@werken.com>.
> I tried Classworlds and I found it incredibly slow. I tried to look into 
> the code to see why and I saw too many classloading and it does too many 
> things for the super-simple layer of classloading abstraction I wanted, 
> so I decided to write my own tiny one (took me half an hour). Since we 
> use it to run the servlet container with inside Cocoon (a total of 15mb 
> of java classes!!) classloading speed really isan issue for us, 
> expecially on development since you normally have to reload the 
> instances of Cocoon several times.

Just curios, but as a direct replacement for however you were
using forehead, was it slow?  Or just the uberjar functionality?
Uberjar is konwn to be slow in the current release, but Jason van Zyl
has improved its performance in CVS, I believe.

When used as a direct replacement for forehead, it should be
roughly comparable in speed.

> Anyway, many thanks for your support.

No problem.  I'll get the fix you need into forehead, which
you can certainly continue using if you wish.  

	-bob


Re: problem with forehead

Posted by Stefano Mazzocchi <st...@apache.org>.
Stefano Mazzocchi wrote:
> bob mcwhirter wrote:
> 
>> Stefano--
>>
>> Glad to hear you guys are finding it useful.  Forehead got sunsetted
>> pretty quickly though and has been replaced by Classworlds which has
>> slightly more robust concepts and also supports the 'uber-jar' for
>> running a complete app from a standalone jar and no external 
>> dependencies.
> 
> 
> Ah, didn't know that. I'll look into it right away.
> 
>> I'll be glad to integrate your change into forehead but you might find
>> classworlds a better solution overall.  (Though, it too may suffer from
>> this reflection issue).
> 
> 
> I'll try it and come back to you.
> 
>> Anyhow, http://classworlds.werken.com/ or 'maven uberjar' if you guys
>> are using maven.

Bob,

I tried Classworlds and I found it incredibly slow. I tried to look into 
the code to see why and I saw too many classloading and it does too many 
things for the super-simple layer of classloading abstraction I wanted, 
so I decided to write my own tiny one (took me half an hour). Since we 
use it to run the servlet container with inside Cocoon (a total of 15mb 
of java classes!!) classloading speed really isan issue for us, 
expecially on development since you normally have to reload the 
instances of Cocoon several times.

Anyway, many thanks for your support.

-- 
Stefano Mazzocchi                               <st...@apache.org>
    Pluralitas non est ponenda sine necessitate [William of Ockham]
--------------------------------------------------------------------



Re: problem with forehead

Posted by Stefano Mazzocchi <st...@apache.org>.
bob mcwhirter wrote:
> Stefano--
> 
> Glad to hear you guys are finding it useful.  Forehead got sunsetted
> pretty quickly though and has been replaced by Classworlds which has
> slightly more robust concepts and also supports the 'uber-jar' for
> running a complete app from a standalone jar and no external dependencies.

Ah, didn't know that. I'll look into it right away.

> I'll be glad to integrate your change into forehead but you might find
> classworlds a better solution overall.  (Though, it too may suffer from
> this reflection issue).

I'll try it and come back to you.

> Anyhow, http://classworlds.werken.com/ or 'maven uberjar' if you guys
> are using maven.

-- 
Stefano Mazzocchi                               <st...@apache.org>
    Pluralitas non est ponenda sine necessitate [William of Ockham]
--------------------------------------------------------------------



Re: problem with forehead

Posted by bob mcwhirter <bo...@werken.com>.
Stefano--

Glad to hear you guys are finding it useful.  Forehead got sunsetted
pretty quickly though and has been replaced by Classworlds which has
slightly more robust concepts and also supports the 'uber-jar' for
running a complete app from a standalone jar and no external dependencies.

I'll be glad to integrate your change into forehead but you might find
classworlds a better solution overall.  (Though, it too may suffer from
this reflection issue).

Anyhow, http://classworlds.werken.com/ or 'maven uberjar' if you guys
are using maven.

	-bob


On Thu, 27 Feb 2003, Stefano Mazzocchi wrote:

> Bob,
> 
> Cocoon is using Forehead to bootstrap its services. We found a weird 
> problem related to JDK 1.3.1 which is probably a JDK bug that was fixed 
> on 1.4.1.
> 
> This is related to the fact that the entry point class we call extends 
> another class that exposes a main() method. It seems that Forehead calls 
> the right method, but JDK 1.3.1 invoques the method of the super class 
> instead of the one of the extending class.
> 
> I found out that if I modify the Forehead.run() method like the following:
> 
>      public void run(String[] args)
>         throws
>             NoSuchMethodException,
>             IllegalAccessException,
>             InvocationTargetException
>      {
>          Class[] method_param_types = new Class[1];
>          method_param_types[0] = args.getClass();
> 
>          Method main = 
> this.entryClass.getDeclaredMethod("main",method_param_types);
> 
>          Object[] method_params = new Object[1];
>          method_params[0] = args;
> 
>          Thread.currentThread().setContextClassLoader( this.entryLoader );
> 
>          main.invoke(null,method_params);
>      }
> 
> the problem goes away.
> 
> I'm recompiling forehead with this patch to include in Cocoon, but I'd 
> be happy to see this bug fixed in the main Forehead distribution.
> 
> Thanks.
> 
> -- 
> Stefano Mazzocchi                               <st...@apache.org>
>     Pluralitas non est ponenda sine necessitate [William of Ockham]
> --------------------------------------------------------------------
> 
> 

--
Bob McWhirter        bob@werken.com
The Werken Company   http://werken.com/