You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geode.apache.org by Alberto Gomez <al...@est.tech> on 2019/08/09 11:16:12 UTC

About deploying jars with dependencies among them

Hi,

We have two jar files one containing  a Geode function and another one 
containing some class used by the function in its execute method.

We have observed the following behavior:

If we load on a Geode cluster one jar and then the other (on any order) 
with gfsh and then call the function from a client, the function is 
executed correctly.

But, if we first load the jar containing the function, call the function 
from a client (in which we get a java.lang.NoClassDefFoundError 
exception for the class referenced), load the other jar containing the 
class used by the function and then call the function we still get the 
same exception.

If the servers are restarted afterwards the problem disappears.

The Geode version we are using is the one found in the development 
branch last week.

Is there an explanation for this behavior or is this a bug?

Thanks in advance,

-Alberto G



Re: About deploying jars with dependencies among them

Posted by Alberto Gomez <al...@est.tech>.
Thanks a lot for your answers.

I do not know if I fully understand the behavior.
Strangely, the problem is not manifested just by deploying the two jars in the wrong order (first deploy jar A with a dependency on jar B, second, deploy jar B).
If I do just that, there is no exception when the function is called.

The problem only shows up when jar A is deployed and the function in jar A with a dependency is called before jar B is deployed.
At this point, the exception is expected because jar B has not yet been deployed.
But, if later jar B is deployed, the exception keeps coming when the function is called.

Could it be that in the first case, even if the two jars are deployed by two independent gfsh commands, they are still loaded by the same class loader?

Thanks,

-Alberto G.

Obtener Outlook para Android<https://aka.ms/ghei36>

________________________________
From: Jens Deppe <jd...@pivotal.io>
Sent: Friday, August 9, 2019 2:41:32 PM
To: user@geode.apache.org <us...@geode.apache.org>
Subject: Re: About deploying jars with dependencies among them

Just to refine Jinmei's answer a little bit; as jars are deployed they create a hierarchy of classloaders so there is a 'direction' of class resolution. If class A depends on B (A->B) then B must be deployed before OR at the same time as A.

--Jens

On Fri, Aug 9, 2019 at 5:13 AM Jinmei Liao <ji...@pivotal.io>> wrote:
Alberto, what you see is the expected behavior. Jars with dependencies have to be deployed together, otherwise, they get loaded by different class loaders, and one can't recognize the other. I believe this was the restriction we put on deployed jars in order to avoid eager loading of all the classes in the deployed jars.

If you bounce the servers, all the jars are loaded together at server restart time, so you won't get the exception anymore.

On Fri, Aug 9, 2019 at 4:16 AM Alberto Gomez <al...@est.tech> wrote:
Hi,

We have two jar files one containing  a Geode function and another one
containing some class used by the function in its execute method.

We have observed the following behavior:

If we load on a Geode cluster one jar and then the other (on any order)
with gfsh and then call the function from a client, the function is
executed correctly.

But, if we first load the jar containing the function, call the function
from a client (in which we get a java.lang.NoClassDefFoundError
exception for the class referenced), load the other jar containing the
class used by the function and then call the function we still get the
same exception.

If the servers are restarted afterwards the problem disappears.

The Geode version we are using is the one found in the development
branch last week.

Is there an explanation for this behavior or is this a bug?

Thanks in advance,

-Alberto G




--
Cheers

Jinmei

Re: About deploying jars with dependencies among them

Posted by Jens Deppe <jd...@pivotal.io>.
Just to refine Jinmei's answer a little bit; as jars are deployed they
create a hierarchy of classloaders so there is a 'direction' of class
resolution. If class A depends on B (A->B) then B must be deployed before
OR at the same time as A.

--Jens

On Fri, Aug 9, 2019 at 5:13 AM Jinmei Liao <ji...@pivotal.io> wrote:

> Alberto, what you see is the expected behavior. Jars with dependencies
> have to be deployed together, otherwise, they get loaded by different class
> loaders, and one can't recognize the other. I believe this was the
> restriction we put on deployed jars in order to avoid eager loading of all
> the classes in the deployed jars.
>
> If you bounce the servers, all the jars are loaded together at server
> restart time, so you won't get the exception anymore.
>
> On Fri, Aug 9, 2019 at 4:16 AM Alberto Gomez <al...@est.tech>
> wrote:
>
>> Hi,
>>
>> We have two jar files one containing  a Geode function and another one
>> containing some class used by the function in its execute method.
>>
>> We have observed the following behavior:
>>
>> If we load on a Geode cluster one jar and then the other (on any order)
>> with gfsh and then call the function from a client, the function is
>> executed correctly.
>>
>> But, if we first load the jar containing the function, call the function
>> from a client (in which we get a java.lang.NoClassDefFoundError
>> exception for the class referenced), load the other jar containing the
>> class used by the function and then call the function we still get the
>> same exception.
>>
>> If the servers are restarted afterwards the problem disappears.
>>
>> The Geode version we are using is the one found in the development
>> branch last week.
>>
>> Is there an explanation for this behavior or is this a bug?
>>
>> Thanks in advance,
>>
>> -Alberto G
>>
>>
>>
>
> --
> Cheers
>
> Jinmei
>

Re: About deploying jars with dependencies among them

Posted by Jinmei Liao <ji...@pivotal.io>.
Alberto, what you see is the expected behavior. Jars with dependencies have
to be deployed together, otherwise, they get loaded by different class
loaders, and one can't recognize the other. I believe this was the
restriction we put on deployed jars in order to avoid eager loading of all
the classes in the deployed jars.

If you bounce the servers, all the jars are loaded together at server
restart time, so you won't get the exception anymore.

On Fri, Aug 9, 2019 at 4:16 AM Alberto Gomez <al...@est.tech> wrote:

> Hi,
>
> We have two jar files one containing  a Geode function and another one
> containing some class used by the function in its execute method.
>
> We have observed the following behavior:
>
> If we load on a Geode cluster one jar and then the other (on any order)
> with gfsh and then call the function from a client, the function is
> executed correctly.
>
> But, if we first load the jar containing the function, call the function
> from a client (in which we get a java.lang.NoClassDefFoundError
> exception for the class referenced), load the other jar containing the
> class used by the function and then call the function we still get the
> same exception.
>
> If the servers are restarted afterwards the problem disappears.
>
> The Geode version we are using is the one found in the development
> branch last week.
>
> Is there an explanation for this behavior or is this a bug?
>
> Thanks in advance,
>
> -Alberto G
>
>
>

-- 
Cheers

Jinmei