Quantcast

Grails classloading - how to edit a jar file to test some changes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Grails classloading - how to edit a jar file to test some changes

olivertynes
Original reason for doing this is outlined here:

http://grails.1312388.n4.nabble.com/GORM-produces-errors-saying-I-have-duplicate-entries-on-some-hidden-API-code-td4632727.html

So... I started out by simply placing GrailsDomainBinder in src/java
in the same package structure, assuming that the grails project itself
is the first place the classloader would look for a class in it's
first come first serve loading.

No cigar on that one, it kept using the one from grails-hibernate.

So I unpacked grails-hibernate, changed the class, repacked, put back
into my grails-2.1.0 folder.
Inspecting the file in IDEA shows my changes all loaded (I have
deleted the one in src/java), but when I run, the same error still
happens, my changes do not take effect.

I have of course cleaned, compiled, restarted, prayed to all the
fifteen voodoo gods and sacrificed a goat.

Nothing works.

Hints are greatly appreciated!

--
*****
Oliver Tynes
Developer
Uni CIPR -- www.cipr.uni.no
55588266
*****

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails classloading - how to edit a jar file to test some changes

pledbrook
> Original reason for doing this is outlined here:
>
> http://grails.1312388.n4.nabble.com/GORM-produces-errors-saying-I-have-duplicate-entries-on-some-hidden-API-code-td4632727.html
>
> So... I started out by simply placing GrailsDomainBinder in src/java
> in the same package structure, assuming that the grails project itself
> is the first place the classloader would look for a class in it's
> first come first serve loading.

This is a minefield. In terms of 'run-app', you can use the script I
created here to look at the class loader ordering:

    http://pastebin.com/vbEEJ402

But remember that URLClassLoader is a _parent-first_ loader, i.e. it
asks the parent for a class before looking in its own search path.
This is probably why the grails-hibernate class is being used.

Another thing to bear in mind is that in WAR mode, there are probably
no guarantees of load order.

> So I unpacked grails-hibernate, changed the class, repacked, put back
> into my grails-2.1.0 folder.
> Inspecting the file in IDEA shows my changes all loaded (I have
> deleted the one in src/java), but when I run, the same error still
> happens, my changes do not take effect.

This is probably because the JAR is being taken from the Ivy cache,
not directly from $GRAILS_HOME. Try updating ~/.grails/ivy-cache/...
with your custom JAR.

In response to your earlier email, it looks like a good candidate for a JIRA.

Peter

--
Peter Ledbrook
Developer Advocate
VMware

t: @pledbrook

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails classloading - how to edit a jar file to test some changes

olivertynes
Yeah, I'm just gonna fix it before I JIRA it.

Then I will make a pull request.

Thanks for feedback, feel pretty dumb that I forgot to kill ivy cache!

Will do and report back, thanks for the quick reply :-)

-Oliver

On Tue, Aug 21, 2012 at 6:11 PM, Peter Ledbrook <[hidden email]> wrote:

>> Original reason for doing this is outlined here:
>>
>> http://grails.1312388.n4.nabble.com/GORM-produces-errors-saying-I-have-duplicate-entries-on-some-hidden-API-code-td4632727.html
>>
>> So... I started out by simply placing GrailsDomainBinder in src/java
>> in the same package structure, assuming that the grails project itself
>> is the first place the classloader would look for a class in it's
>> first come first serve loading.
>
> This is a minefield. In terms of 'run-app', you can use the script I
> created here to look at the class loader ordering:
>
>     http://pastebin.com/vbEEJ402
>
> But remember that URLClassLoader is a _parent-first_ loader, i.e. it
> asks the parent for a class before looking in its own search path.
> This is probably why the grails-hibernate class is being used.
>
> Another thing to bear in mind is that in WAR mode, there are probably
> no guarantees of load order.
>
>> So I unpacked grails-hibernate, changed the class, repacked, put back
>> into my grails-2.1.0 folder.
>> Inspecting the file in IDEA shows my changes all loaded (I have
>> deleted the one in src/java), but when I run, the same error still
>> happens, my changes do not take effect.
>
> This is probably because the JAR is being taken from the Ivy cache,
> not directly from $GRAILS_HOME. Try updating ~/.grails/ivy-cache/...
> with your custom JAR.
>
> In response to your earlier email, it looks like a good candidate for a JIRA.
>
> Peter
>
> --
> Peter Ledbrook
> Developer Advocate
> VMware
>
> t: @pledbrook
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>



--
*****
Oliver Tynes
Developer
Uni CIPR -- www.cipr.uni.no
55588266
*****

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

    http://xircles.codehaus.org/manage_email


Loading...