Plugin & GrailsClassLoader trouble

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Plugin & GrailsClassLoader trouble

smaldini
Hi folks,

I'm writing a plugin which integrate JSF 1.2/2.0 - Icefaces 1.8.2/2.0 for personnal needs (but maybe this is interesting for some crazy dude).

I had troubles with GrailsClassLoader on non war environnement and a workaround I found was this in the plugin descriptor :

def doWithDynamicMethods = {ctx ->
...
         def oldcl = Thread.currentThread().getContextClassLoader()
        Thread.currentThread().setContextClassLoader oldcl.parent
...
}

Is someone thinking this hack is BAD ? What am I facing to in doing this ?

Best regards fanstastic gommunity !


 

--
Stéphane MALDINI
doc4web consultant
[hidden email]
--
http://fr.linkedin.com/in/smaldini
Reply | Threaded
Open this post in threaded view
|

Re: Plugin & GrailsClassLoader trouble

smaldini
Application reloading seems to work altough with this bad evil hack

On Fri, Mar 12, 2010 at 1:39 PM, Stephane Maldini <[hidden email]> wrote:
Hi folks,

I'm writing a plugin which integrate JSF 1.2/2.0 - Icefaces 1.8.2/2.0 for personnal needs (but maybe this is interesting for some crazy dude).

I had troubles with GrailsClassLoader on non war environnement and a workaround I found was this in the plugin descriptor :

def doWithDynamicMethods = {ctx ->
...
         def oldcl = Thread.currentThread().getContextClassLoader()
        Thread.currentThread().setContextClassLoader oldcl.parent
...
}

Is someone thinking this hack is BAD ? What am I facing to in doing this ?

Best regards fanstastic gommunity !


 

--
Stéphane MALDINI
doc4web consultant
[hidden email]
--
http://fr.linkedin.com/in/smaldini



--
Stéphane MALDINI
doc4web consultant
[hidden email]
--
http://fr.linkedin.com/in/smaldini
Reply | Threaded
Open this post in threaded view
|

Re: Plugin & GrailsClassLoader trouble

pledbrook
In reply to this post by smaldini
> I'm writing a plugin which integrate JSF 1.2/2.0 - Icefaces 1.8.2/2.0 for
> personnal needs (but maybe this is interesting for some crazy dude).
>
> I had troubles with GrailsClassLoader on non war environnement and a
> workaround I found was this in the plugin descriptor :

What problem did you have? Some details would help!
>
> def doWithDynamicMethods = {ctx ->
> ...
>          def oldcl = Thread.currentThread().getContextClassLoader()
>         Thread.currentThread().setContextClassLoader oldcl.parent
> ...
> }

To be honest, this looks like it will break application reloading. If
I recall the class loader structure correctly, removing the top class
loader will mean you don't see changes to controllers, tag libraries,
and services.

Cheers,

Peter

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugin & GrailsClassLoader trouble

smaldini
Problem is JSF specific in Dev env : JSF Factories are bound to a thread classloader when application starts. The trouble : at start, the thread classloader is an instance of GrailsClassLoader. JSF listener bind the factories to this classloader. But when I went to a jsf page ( *.jspx ou *.iface), I obtained a nice error "LifecycleFactory is not found" and after step by step debugging I found the classloader is not the GrailsClassLoader anymore but his parent.
I tried to associate the factories to the both classloader (GCL and GCL.parent) but I raised an "Application ID already associated", so I concluded  to tweak the classloader at startup.
Interesting thing is grails reloading is still working ( I tested with controller and service artifacts ). I think this grails class loader is operating at startup only then the parent takes his place. I just force this operation sooner to let JSF ConfigureListener to bind factories to the right CL.

Between thank you for your answer Peter :

On Sat, Mar 13, 2010 at 8:54 AM, Peter Ledbrook <[hidden email]> wrote:
> I'm writing a plugin which integrate JSF 1.2/2.0 - Icefaces 1.8.2/2.0 for
> personnal needs (but maybe this is interesting for some crazy dude).
>
> I had troubles with GrailsClassLoader on non war environnement and a
> workaround I found was this in the plugin descriptor :

What problem did you have? Some details would help!
>
> def doWithDynamicMethods = {ctx ->
> ...
>          def oldcl = Thread.currentThread().getContextClassLoader()
>         Thread.currentThread().setContextClassLoader oldcl.parent
> ...
> }

To be honest, this looks like it will break application reloading. If
I recall the class loader structure correctly, removing the top class
loader will mean you don't see changes to controllers, tag libraries,
and services.

Cheers,

Peter

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
Stéphane MALDINI
doc4web consultant
[hidden email]
--
http://fr.linkedin.com/in/smaldini