Custom Services are not loading in camunda

Custom Services are not loading in camunda.

The module.xml looks like this

<?xml version="1.0" encoding="UTF-8"?>
<properties>
    <property name="jboss.api" value="public"/>
</properties>

<resources>
    <resource-root path="SDK.jar"/>
</resources>

<dependencies>
    <module name="javax.api" export="false"/>
    <module name="javax.servlet.api"/>
</dependencies>

In SDK.jar have added custom services

In SDK.jar\META-INF\services\com.XXX.YYY.sdk.SdkFactory and its cotnent is com.XXX.YYY.sdk.SdkFactoryProvider

Updated the jboss-deployment-structure.xml

        <dependencies>
               <module name="com.XXX.YYY.sdk" export="true" />
         </dependencies>

When I am trying to load the services it is throwing the error.

var factoryClass = java.lang.Class.forName(“com.XXX.YYY.sdk.SdkFactory”);
var serviceLoader = java.util.ServiceLoader.load(factoryClass);
var iterator = serviceLoader.iterator();
log.debug("Has next--------- " + iterator.hasNext()); This line is returning false. It has one element. Instead of true it is returning false.

Could some one help to load the custom services in camunda.

Details
Camunda: 7.20.0
Wildfly: wildfly-30.0.1.Final
Java 17

Thank you in advance

@Niall Could you please help me here…

Can you give a clearer idea of exactly what you need help with.

  1. What are you trying to do?
  2. What are you expecting to happen?
  3. What is actually happening
  4. Did it work before
  5. If so - what has changed since

Thank you @Niall.

Please find my below comments
What are you trying to do?

We are trying to load the services. With our non camuda flow the iterator.hasNext() is returning true. With camunda engine it is returning false. After loading the services, we are calling getXXXX method to achieve some business logic wrto some service operation that is not happening in camunda.

What are you expecting to happen?
What is actually happening

As mentioned in descripton we are trying to load the services and trying to use this in camunda as rhino script.
var factoryClass = java.lang.Class.forName(“com.XXX.YYY.sdk.SdkFactory”);
var serviceLoader = java.util.ServiceLoader.load(factoryClass);

In our code, we are iterating this service loader.In iterator is returing false in camuda but it is returning true in other places than camunda.So we are expecting the service loader should have value for the iterator in camunda engine also.
var iterator = serviceLoader.iterator();
The iterator.hasNext() is returning false.

Did it work before : Trying to implement/achieve the same what we can do from non camunda flow.
If so - what has changed since: No.

I tried with existing services also. Example log4j-api-2.17.1.jar\META-INF\services\org.apache.logging.log4j.util.PropertySource. This as 2 entries ie
org.apache.logging.log4j.util.EnvironmentPropertySource
org.apache.logging.log4j.util.SystemPropertiesPropertySource

When I tried these also, count is coming as 0 in camunda and non camunda count is coming as 2.

I appreciates your help on this.

Regards,
Poornima