I have mixed  setup, where java client trying to run kotlin function on
ignite server. Also  i dont run server and client in intelliJ. If I run
both client and server in IntelliJ, it works. So I am trying to find out
what list of jars IntelliJ is providing which are missing in standalone
ignite node libs.
here are my steps.
1. compile and create jar file using gradle
2. copy jar file and kotlin stdlib-jdk8 file to local ignite/libs directory
3. start server node
4. start client node
 5. Client and server both running ignite 2.11.0 and jdk : openjdk
11.0.12+7-LTS, OS : Linux 4.14.248-189.247.amzn2.x86_64 amd62
MockTest.kt

fun abc(x: Int): () -> Int ={
println("Kotlin prints : " + (x*2))
x*2
}

Java main file:
Test{
psvm(){

IgniteConfiguration igniteConfiguration = new IgniteConfiguration()
                .setClientMode(true)
                .setPeerClassLoadingEnabled(true);

Ignite ignite = Ignition.start(igniteConfiguration)

    ignite.compute().run(() ->  abc(1).invoke());
}

Server node is simple ignite node with peer class loading enabled

Exception : NoClassDefinitionFoundError kotlin/jvm/functions/Function0

On Fri, Oct 29, 2021 at 8:09 PM Stephen Darlington <
stephen.darling...@gridgain.com> wrote:

> As long as it can peer-class-load the necessary classes (or they’re
> already deployed on the server side) it should work. This works on my
> machine:
>
> val cfg = IgniteConfiguration()
>         .setClientMode(true)
>         .setPeerClassLoadingEnabled(true)
> Ignition.start(cfg)
>         .use { ignite ->
>             ignite.compute().run() { println("Hello") }
>         }
>
>
> On 29 Oct 2021, at 13:20, Surinder Mehra <redni...@gmail.com> wrote:
>
> Hi Thanks much for investigating it with me.  After spending lot of time
> on it, I found that client and servers were running on different JDK
> versions. Client running in java 11 was submitting tasks to server node
> running on java 8. I upgraded java version on server node and it worked.
>
> Actually I have another question. Does ignite needs any extra dependencies
> to run tasks written in Kotlin. I am getting below error when try to run
> kotlin code as part of task
>
> Caused by: java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
> at com.test.TestTask.<clinit>(TestTask.kt:36)
> Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
> at
> java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
> at
> java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
> at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
> ... 45 more
>
> On Wed, Oct 27, 2021 at 9:57 PM Stephen Darlington <
> stephen.darling...@gridgain.com> wrote:
>
>> Using Ignite 2.11 and the following code works.
>>
>> Server:
>>
>> public class ComputeServer {
>>     public static void main(String[] args) {
>>         IgniteConfiguration igniteConfiguration = new IgniteConfiguration()
>>                 .setPeerClassLoadingEnabled(true);
>>         Ignite ignite = Ignition.start(igniteConfiguration);
>>     }
>> }
>>
>> Client:
>>
>> public class ComputeClient {
>>     public static void main(String[] args) {
>>         IgniteConfiguration igniteConfiguration = new IgniteConfiguration()
>>                 .setClientMode(true)
>>                 .setPeerClassLoadingEnabled(true);
>>         try (Ignite ignite = Ignition.start(igniteConfiguration)) {
>>             ignite.compute().run(() -> System.out.println("Hello, world"));
>>         }
>>
>>     }
>> }
>>
>> (It executes on server nodes by default; you don’t need to create a
>> cluster group for that.)
>>
>> So I think you’ll need to share more about your configuration and/or code
>> to get to the bottom of this.
>>
>> On 27 Oct 2021, at 16:47, Surinder Mehra <redni...@gmail.com> wrote:
>>
>> Just wondering if it is possible at all. All examples/demos I have seen
>> are either using a thin client  or one server node submitting a task to the
>> grid, or with affinity to a particular node. I have tried all compute apis,
>> like run, call, runAffinity. callaffinity, broadcast. none of them works
>> when submitted from client node. They do run if I change clusterGroup to
>> local nodes. like ClusterGroup grp = ignite.cluster().forLocalNodes();
>>
>> On Wed, Oct 27, 2021 at 6:20 PM Surinder Mehra <redni...@gmail.com>
>> wrote:
>>
>>> yes, it is enabled. Even if that wasn't enabled, I should get class not
>>> found error. Here i dont get any error but its simply doesn't execute. I
>>> see below flag needs to be enabled for thin client. Is there any
>>> setting for thick clients as well ?
>>>
>>> https://ignite.apache.org/docs/latest/thin-clients/java-thin-client
>>>
>>> <bean class="org.apache.ignite.configuration.IgniteConfiguration" 
>>> id="ignite.cfg">
>>>     <property name="clientConnectorConfiguration">
>>>         <bean 
>>> class="org.apache.ignite.configuration.ClientConnectorConfiguration">
>>>             <property name="thinClientConfiguration">
>>>                 <bean 
>>> class="org.apache.ignite.configuration.ThinClientConfiguration">
>>>                     <property name="maxActiveComputeTasksPerConnection" 
>>> value="100" />
>>>                 </bean>
>>>             </property>
>>>         </bean>
>>>     </property></bean>
>>>
>>>
>>> On Wed, Oct 27, 2021 at 6:04 PM Stephen Darlington <
>>> stephen.darling...@gridgain.com> wrote:
>>>
>>>> Did you enable peer class loading?
>>>>
>>>> > On 27 Oct 2021, at 13:18, Surinder Mehra <redni...@gmail.com> wrote:
>>>> >
>>>> > Hi,
>>>> > I have a sever node and a thick client node running. I am trying to
>>>> submit ignite compute job from client node to server node but it doesn't
>>>> work.
>>>> >
>>>> > ClusterGroup grp = ignite.cluster().forServers()
>>>> > IgniteCompute ignieCompute = ignite.compute(grp);
>>>> > igniteCompute.run(() ->  System.out.println("Task Executed"));
>>>> >
>>>> > Sysout never printed on console and client keeps running. If I change
>>>> it to server mode, tasks completed immediately.
>>>> >
>>>> > Can someone help me understand if I am missing some configuration?
>>>> >
>>>>
>>>>
>>>>
>>
>>
>
>

Reply via email to