Error with Backendless.Messaging in Java Cloud Code

One of our core app features which involves sending emails is currently unusable due to an issue when attempting to execute the following Java SDK function within deployed Cloud Code:

Backendless.Messaging.sendTextEmail(subject, body, recipients);

which results in the following error:

BackendlessException: Type:"java.lang.IncompatibleClassChangeError", Description:"Found interface com.backendless.Messaging, but class was expected", ExceptionClass:"ServiceException"  {Msg:"none", Cause:"none"}, code = 0

This issue appears to be very similar to the following issue that we faced previously:

Has anything user related changed overnight? - User Service - Backendless Support

When I run the code through Code Runner in debug mode using my old Code Runner version 6.6.3 with Java 15, the function executes without error and an email is sent.

When this cloude code is “deployed”, with the previously stated configuration or debugged or deployed using the latest Code Runner with Java 17, then the function results in the previously stated error message.

I also receive the following error message in my Code Runner console output when using the latest version and Java 17:

|JavaWorkerPool_pool-thread-2| Error when set InvocationContext
java.lang.IllegalAccessException: class com.backendless.coderunner.runtime.task.ServiceInvocationTask cannot access a member of class com.backendless.BLHeadersManager with modifiers "public"
        at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392)
        at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674)
        at java.base/java.lang.reflect.Method.invoke(Method.java:560)
        at com.backendless.coderunner.runtime.task.ServiceInvocationTask.createInvocationContext(ServiceInvocationTask.java:226)
        at com.backendless.coderunner.runtime.task.ServiceInvocationTask.runImpl(ServiceInvocationTask.java:128)
        at com.backendless.coderunner.runtime.executor.ExtendedRunnable.run(ExtendedRunnable.java:42)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)

Is there a version compatibility matrix or some other documentation available for what versions of CodeRunner and what Java versions will properly work for deploying Java Cloud Code to Backendless?

This is another feature that seems to have been broken by whatever internal Backendless update was pushed on or around 05/21/2023.

Hello @Mark_Moline

I could not reproduce the issue with the new code runner and Java 17. I was using the following code to check:

@BackendlessService
public class TestEmail
{
  public void send(){
    ArrayList<String> recipients = new ArrayList<String>();
    recipients.add( "me@tes.com" );
    Backendless.Messaging.sendTextEmail( "Test", "My body", recipients );
  }
}

Is this test correct? Could you share the project with us that we can check?

After you confirmed that this basic test worked for you I tried to repeat by downloading the very latest project template, again, and building this exact simple test.

It did work for me as well after some additional tweaking to my java environment and after some more trial and error and rebuilding of my normal code base I was also able to get it working as well!

Thank you for the prompt investigation and reply!