You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by "F.D." <fr...@gmail.com> on 2019/01/28 12:49:02 UTC

Ignite and dynamic linking

Hi Igniters,
I'm trying to use Ignite in a dll (using c++) that is dinamically loaded. I
wrapped the method start/end/... bihind a "c" pure interface that I export.

It works quite well. I can call the LoadLibrary and start a Ignite node. I
can stop it and restart it again smoothly.

I've the problem when I LoadLibrary and then I call FreeLibrary (and until
here it works), but when I try to LoadLibrary again and to start the node,
I get the error: Failed to initialize JVM* [errCls=, errMsg=JVM already
created.]*

Do you any ideas why I got this error?

Thanks,
   F.D.

Re: Ignite and dynamic linking

Posted by Igor Sapego <is...@apache.org>.
You should not call it before FreeLibrary(). Try calling it after.

Best Regards,
Igor


On Tue, Jan 29, 2019 at 5:02 PM F.D. <fr...@gmail.com> wrote:

> Hi Igor,
>
> thanks for your reply, I've added this code:
>
> Snippet
>
> void Ignition::DestroyJVM()
>     {
>        factoryLock.Enter();
>
>        JniErrorInfo jniErr;
>
>        SharedPointer<JniContext> ctx(JniContext::Create(0, 0, JniHandlers(), &jniErr));
>
>        IgniteError err;
>        IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
>
>        if(err.GetCode() == IgniteError::IGNITE_SUCCESS)
>           ctx.Get()->DestroyJvm();
>
>        factoryLock.Leave();
>     }
>
> And call it before the FreeLibrary(), now when I call the start I got a
> unknow error. Any ideas?
>
> Thanks,
>    F.D.
>
>
> On Mon, Jan 28, 2019 at 5:08 PM Igor Sapego <is...@apache.org> wrote:
>
>> Hi,
>>
>> Currently, Ignite on start creates JVM instance internally, but
>> it never stops it. Also, it currently can not work with already started
>> JVM.
>>
>> So when you start Ignite the first time, it loads JVM, when you stop
>> and unload it, the JVM remains loaded in process memory. When
>> you start Ignite again, it discovers that JVM was already loaded, and
>> as it can not work with pre-loaded JVM, it just returns you the error.
>>
>> To solve the issue, the following ticket should be implemented [1], but
>> currently, it is not. As a workaround you may try to call
>> JNI_DestroyJavaVM() after you have unloaded Ignite, I'm not sure
>> of the result though. This is simply is not a use case we have tested.
>>
>> [1] - https://issues.apache.org/jira/browse/IGNITE-4618
>>
>> Best Regards,
>> Igor
>>
>>
>> On Mon, Jan 28, 2019 at 3:49 PM F.D. <fr...@gmail.com> wrote:
>>
>>> Hi Igniters,
>>> I'm trying to use Ignite in a dll (using c++) that is dinamically
>>> loaded. I wrapped the method start/end/... bihind a "c" pure interface that
>>> I export.
>>>
>>> It works quite well. I can call the LoadLibrary and start a Ignite node.
>>> I can stop it and restart it again smoothly.
>>>
>>> I've the problem when I LoadLibrary and then I call FreeLibrary (and
>>> until here it works), but when I try to LoadLibrary again and to start the
>>> node, I get the error: Failed to initialize JVM* [errCls=, errMsg=JVM
>>> already created.]*
>>>
>>> Do you any ideas why I got this error?
>>>
>>> Thanks,
>>>    F.D.
>>>
>>

Re: Ignite and dynamic linking

Posted by "F.D." <fr...@gmail.com>.
Hi Igor,

thanks for your reply, I've added this code:

Snippet

void Ignition::DestroyJVM()
    {
       factoryLock.Enter();

       JniErrorInfo jniErr;

       SharedPointer<JniContext> ctx(JniContext::Create(0, 0,
JniHandlers(), &jniErr));

       IgniteError err;
       IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);

       if(err.GetCode() == IgniteError::IGNITE_SUCCESS)
          ctx.Get()->DestroyJvm();

       factoryLock.Leave();
    }

And call it before the FreeLibrary(), now when I call the start I got a
unknow error. Any ideas?

Thanks,
   F.D.


On Mon, Jan 28, 2019 at 5:08 PM Igor Sapego <is...@apache.org> wrote:

> Hi,
>
> Currently, Ignite on start creates JVM instance internally, but
> it never stops it. Also, it currently can not work with already started
> JVM.
>
> So when you start Ignite the first time, it loads JVM, when you stop
> and unload it, the JVM remains loaded in process memory. When
> you start Ignite again, it discovers that JVM was already loaded, and
> as it can not work with pre-loaded JVM, it just returns you the error.
>
> To solve the issue, the following ticket should be implemented [1], but
> currently, it is not. As a workaround you may try to call
> JNI_DestroyJavaVM() after you have unloaded Ignite, I'm not sure
> of the result though. This is simply is not a use case we have tested.
>
> [1] - https://issues.apache.org/jira/browse/IGNITE-4618
>
> Best Regards,
> Igor
>
>
> On Mon, Jan 28, 2019 at 3:49 PM F.D. <fr...@gmail.com> wrote:
>
>> Hi Igniters,
>> I'm trying to use Ignite in a dll (using c++) that is dinamically loaded.
>> I wrapped the method start/end/... bihind a "c" pure interface that I
>> export.
>>
>> It works quite well. I can call the LoadLibrary and start a Ignite node.
>> I can stop it and restart it again smoothly.
>>
>> I've the problem when I LoadLibrary and then I call FreeLibrary (and
>> until here it works), but when I try to LoadLibrary again and to start the
>> node, I get the error: Failed to initialize JVM* [errCls=, errMsg=JVM
>> already created.]*
>>
>> Do you any ideas why I got this error?
>>
>> Thanks,
>>    F.D.
>>
>

Re: Ignite and dynamic linking

Posted by Igor Sapego <is...@apache.org>.
Hi,

Currently, Ignite on start creates JVM instance internally, but
it never stops it. Also, it currently can not work with already started
JVM.

So when you start Ignite the first time, it loads JVM, when you stop
and unload it, the JVM remains loaded in process memory. When
you start Ignite again, it discovers that JVM was already loaded, and
as it can not work with pre-loaded JVM, it just returns you the error.

To solve the issue, the following ticket should be implemented [1], but
currently, it is not. As a workaround you may try to call
JNI_DestroyJavaVM() after you have unloaded Ignite, I'm not sure
of the result though. This is simply is not a use case we have tested.

[1] - https://issues.apache.org/jira/browse/IGNITE-4618

Best Regards,
Igor


On Mon, Jan 28, 2019 at 3:49 PM F.D. <fr...@gmail.com> wrote:

> Hi Igniters,
> I'm trying to use Ignite in a dll (using c++) that is dinamically loaded.
> I wrapped the method start/end/... bihind a "c" pure interface that I
> export.
>
> It works quite well. I can call the LoadLibrary and start a Ignite node. I
> can stop it and restart it again smoothly.
>
> I've the problem when I LoadLibrary and then I call FreeLibrary (and until
> here it works), but when I try to LoadLibrary again and to start the node,
> I get the error: Failed to initialize JVM* [errCls=, errMsg=JVM already
> created.]*
>
> Do you any ideas why I got this error?
>
> Thanks,
>    F.D.
>