Run a Java Service

Do I need to do something special to run a Service implemented in Java?

I’m getting ClassNotFoundException when I try to run my service. Interestingly I cannot find any example of a working Java service.

As reference, the component repo is on github at: grozadanut/moqui-linic-legacy/

Caused by: java.lang.ClassNotFoundException: Class not found.
        at org.moqui.util.MClassLoader.loadClassInternal(MClassLoader.java:433)
        at org.moqui.util.MClassLoader.loadClass(MClassLoader.java:381)
        at org.moqui.util.MClassLoader.loadClass(MClassLoader.java:370) 
        at org.moqui.impl.service.runner.JavaServiceRunner.runService(JavaServiceRunner.groovy:62)

This is my service definition:

<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/service-definition-3.xsd">

    <!-- moqui-linic-legacy & Related Services -->
    <service verb="legacySync" noun="AllProducts" type="java"
             location="ro.colibri.legacy.service.LegacySyncServices" method="syncAllProducts">
        <description>
            Synchronizes all ACTIVE products(no images) from the legacy database to the Moqui database. No stock, just initial data.
        </description>
    </service>
</services>

You can refer to:
GitHub - netvariant/moqui-workflow: Extendable workflow engine for the Moqui Framework
I think using Groovy is more convenient

Okay, got it to work. So it seems I misunderstood what the lib folder was for. I was expecting that the lib folder is to add jar dependencies that my code needs, but it seems it is only for jars that Moqui framework needs to discover, thus I need to build the jar of my code and add it there in order for Moqui to see my code.

So I ended up creating another libs folder where I put the jars that are dependencies of my code, and the gradle build task makes sure that all those jars, and also my library jar gets copied to the lib folder.

@newmannhu yea, probably Groovy is more convenient, but I have little experience with it, and I needed to call a legacy system through remote ejb calls, for which I already had the code written, just needed to copy it to Moqui.