Changes made to cloud code overnight

Hi,

Similar to the thread posted here, I am also experiencing issues after updates last night. Since midnight last night I am receiving exceptions when running code in production. This does not occur when running through CodeRunner in debug (locally through terminal).

Specifically, I am getting the following exceptions:

Exception 1)
Exception: java.lang.IncompatibleClassChangeError: Found interface com.backendless.Messaging, but class was expected at com.btcmarketsticker.timers.NotificationSenderTimer.execute(NotificationSenderTimer.java:304) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at com.backendless.coderunner.runtime.task.TimerInvocationTask.runImpl(TimerInvocationTask.java:55) at com.backendless.coderunner.runtime.executor.ExtendedRunnable.run(ExtendedRunnable.java:42) at java.base/java.lang.Thread.run(Thread.java:833)

Which is relating to this particular line of code:
Backendless.Messaging.publish("default", "this is a message", publishOptions, deliveryOptions);

Exception 2)
Exception: java.lang.NoSuchFieldError: Persistence at com.btcmarketsticker.timers.JavaWorkerTimer.execute(JavaWorkerTimer.java:320) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at com.backendless.coderunner.runtime.task.TimerInvocationTask.runImpl(TimerInvocationTask.java:55) at com.backendless.coderunner.runtime.executor.ExtendedRunnable.run(ExtendedRunnable.java:42) at java.base/java.lang.Thread.run(Thread.java:833)

Which is relating to this line of code:
Backendless.Persistence.of(DailyChange.class).remove(firstElement);

Exception 3)
Exception: java.lang.NoSuchFieldError: Persistence at com.btcmarketsticker.timers.PriceGetterTimer.execute(PriceGetterTimer.java:645) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at com.backendless.coderunner.runtime.task.TimerInvocationTask.runImpl(TimerInvocationTask.java:55) at com.backendless.coderunner.runtime.executor.ExtendedRunnable.run(ExtendedRunnable.java:42) at java.base/java.lang.Thread.run(Thread.java:833)

Which is relating to the following line of code:
Backendless.Persistence.of(Prices.class).remove(firstElement);

As mentioned these exceptions are not thrown in debug mode when running CodeRunner locally through terminal. This occurs only for published timers running in production.

Please advise if any breaking changes have been made to the production environment overnight. As it stands my app is essentially useless until this is resolved.

I’m now also getting the following exception:

19:1:11.750 | Coderunner | ERROR | Business logic execution has been stopped, due to error: Code: 0 Class: java.lang.IncompatibleClassChangeError Message: TimerInvocationTask{className='com.btcmarketsticker.timers.NotificationSenderTimer', abstractRequest=RequestMethodInvocation(super=InvocationRequest(super=AbstractRequest(lang=JAVA, id=F6182A5D-7542-4D01-A089-3A6E6B467523, responseChannelId=null, applicationId=130CA81A-36A3-9479-FFEE-AB623F4D0E00, initAppData=InitAppData{apiKey='03B58C03-D546-C2A5-FF8A-A687D1E2BB00', url='http://bl-server:9000'}, timestamp=1685264470152, invocationOverheadTimeoutInMillis=0, timeout=25000, threadCount=3, invocationContextDto=null, relativePath=files/servercode/JAVA/default/PRODUCTION/, deploymentModelName=default, loggers=[Logger(id=056AD00B-CE35-6807-FFB1-150F34108100, name=Coderunner, level=ERROR, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=3AC31141-B1D6-E0FD-FFCF-65E2D0FCD400, name=com.btcmarketsticker.timers.JavaWorkerTimer, level=DEBUG, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=74338B55-8940-CD6F-FFC5-B2426FF2BE00, name=com.btcmarketsticker.timers.PriceGetterTimer, level=DEBUG, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=78FFEFD9-AEEE-C255-FFA2-7A2378CFB500, name=com.btcmarketsticker.timers.NotificationSenderTimer, level=DEBUG, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=C75C6F77-FF96-40E1-A628-EEB3D0131098, name=com.btcmarketsticker.timers.DailyAlertGenerator, level=ALL, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=DA2E897E-C379-3A59-FF4E-90AC3704E400, name=Purchases.Logger, level=ALL, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=FB6DF1E8-6433-C37A-FF08-E3B1551EB400, name=Global logger, level=ALL, policy=DATE-BASED, value=1, logFormat=%d | %c | %5p | %m%n)]), mode=Production, async=true), eventId=800, arguments=null, target=notificationSender, provider=com.btcmarketsticker.timers.NotificationSenderTimer)} Exception: java.lang.IncompatibleClassChangeError: Found interface com.backendless.Messaging, but class was expected at com.btcmarketsticker.timers.NotificationSenderTimer.execute(NotificationSenderTimer.java:409) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at com.backendless.coderunner.runtime.task.TimerInvocationTask.runImpl(TimerInvocationTask.java:55) at com.backendless.coderunner.runtime.executor.ExtendedRunnable.run(ExtendedRunnable.java:42) at java.base/java.lang.Thread.run(Thread.java:833)

Which is flagging this line in my server code:

status2 = Backendless.Messaging.publish("default", "this is a message", publishOptions, deliveryOptions);

Which sits in the following block of code:

        List<String> deviceIDArray = new ArrayList<String>();

        for (int p = 0; p < pages; p++) {
          List<Map> devices = Backendless.Data.of( "AutoAlerts" ).find( queryBuilder );
          int count = devices.size();
          for (int j = 0; j < count; j++) {
            String deviceID = devices.get(j).get("deviceID").toString();
            //deviceIDArray.add(j,deviceID);
            deviceIDArray.add(deviceID);

          }
          queryBuilder.prepareNextPage();
        }

        DeliveryOptions deliveryOptions = new DeliveryOptions();
        deliveryOptions.setPushSinglecast(deviceIDArray);

        PublishOptions publishOptions = new PublishOptions();
        publishOptions.putHeader( "ios-alert-subtitle", "Price Change Alert" );
        publishOptions.putHeader( "ios-alert-body", messageString);
        publishOptions.putHeader("ios-sound", "default");
        publishOptions.putHeader("coin",coin);

        MessageStatus status2 = new MessageStatus();

        if (deviceIDArray.size()>0) {
          status2 = Backendless.Messaging.publish("default", "this is a message", publishOptions, deliveryOptions);
          status2 = Backendless.Messaging.publish("mitch", "this is a message", publishOptions, deliveryOptions);
        }

This works fine in CodeRunner but not when deployed for production. I also make calls to messaging API elsewhere in code with no issue

Issue now occurring for all instances of Backendless.Messaging.publish :

6:11:10.275 | Coderunner | ERROR | Business logic execution has been stopped, due to error: Code: 0 Class: java.lang.IncompatibleClassChangeError Message: TimerInvocationTask{className='com.btcmarketsticker.timers.NotificationSenderTimer', abstractRequest=RequestMethodInvocation(super=InvocationRequest(super=AbstractRequest(lang=JAVA, id=1C988685-D910-40F1-9308-6653BD1E13D5, responseChannelId=null, applicationId=130CA81A-36A3-9479-FFEE-AB623F4D0E00, initAppData=InitAppData{apiKey='03B58C03-D546-C2A5-FF8A-A687D1E2BB00', url='http://bl-server:9000'}, timestamp=1685304670145, invocationOverheadTimeoutInMillis=0, timeout=25000, threadCount=3, invocationContextDto=null, relativePath=files/servercode/JAVA/default/PRODUCTION/, deploymentModelName=default, loggers=[Logger(id=056AD00B-CE35-6807-FFB1-150F34108100, name=Coderunner, level=ERROR, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=3AC31141-B1D6-E0FD-FFCF-65E2D0FCD400, name=com.btcmarketsticker.timers.JavaWorkerTimer, level=DEBUG, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=74338B55-8940-CD6F-FFC5-B2426FF2BE00, name=com.btcmarketsticker.timers.PriceGetterTimer, level=DEBUG, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=78FFEFD9-AEEE-C255-FFA2-7A2378CFB500, name=com.btcmarketsticker.timers.NotificationSenderTimer, level=DEBUG, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=C75C6F77-FF96-40E1-A628-EEB3D0131098, name=com.btcmarketsticker.timers.DailyAlertGenerator, level=ALL, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=DA2E897E-C379-3A59-FF4E-90AC3704E400, name=Purchases.Logger, level=ALL, policy=DATE-BASED, value=null, logFormat=%d | %c | %5p | %m%n), Logger(id=FB6DF1E8-6433-C37A-FF08-E3B1551EB400, name=Global logger, level=ALL, policy=DATE-BASED, value=1, logFormat=%d | %c | %5p | %m%n)]), mode=Production, async=true), eventId=800, arguments=null, target=notificationSender, provider=com.btcmarketsticker.timers.NotificationSenderTimer)} Exception: java.lang.IncompatibleClassChangeError: Found interface com.backendless.Messaging, but class was expected at com.btcmarketsticker.timers.NotificationSenderTimer.execute(NotificationSenderTimer.java:305) at jdk.internal.reflect.GeneratedMethodAccessor1831.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at com.backendless.coderunner.runtime.task.TimerInvocationTask.runImpl(TimerInvocationTask.java:55) at com.backendless.coderunner.runtime.executor.ExtendedRunnable.run(ExtendedRunnable.java:42) at java.base/java.lang.Thread.run(Thread.java:833)

Which is pointing to this line of code:

MessageStatus status = Backendless.Messaging.publish("default", "this is a message", publishOptions, deliveryOptions);

and in context:

       publishOptions.putHeader("ios-alert-title", "Afternoon Alert");

      }

      publishOptions.putHeader("ios-alert-body", messageString);
      publishOptions.putHeader("ios-sound", "default");
      publishOptions.putHeader("coin",notification.coin);
      MessageStatus status = Backendless.Messaging.publish("default", "this is a message", publishOptions, deliveryOptions);
      status = Backendless.Messaging.publish("mitch", "this is a message", publishOptions, deliveryOptions);
      //Backendless.Persistence.of(NotificationToSend.class).remove(notification);
      Backendless.Data.of(NotificationToSend.class).remove(notification);

Again nothing has changed on my end, this code has been working fine for many months with no changes. I’m getting these issues since a few days ago only

Hello @mitchell

We apologize for the inconvenience you are experiencing. An internal ticket to investigate and resolve the problem has been created and is of the highest priority.

Regards,
Inna

Relatively to the “Persistence” errors – that link was deprecated.
In order not to wait, you may:

  1. Download new CodeRunner (it’s bundled with new sdk).
  2. Take your current “src” dir (with your business logic) and replace the same dir in new CodeRunner on it.
  3. Recompile and fix errors (i think you will only have to change Presistence → Data).

But even if not to talk about these errors, you have to check your code for compatibility with new sdk. That is why i highly recommended to try what I described above.

Hi Oleg,

Yes I since realised that ‘persistence’ must have been deprecated. Do I download the new code runner from ‘Download project template’, as shown below?

Yes, you can download it here or from the Business Logic section.

1 Like

@oleg-vyalyh @Inna_Shkolnaya that seems to be working now, including the sending of Push messages.

How often in general should we as users be updating to the latest SDK and code runner version? It seems that sometimes when the backend is updated to a new SDK or Java version, there can be breaking changes in existing business logic. What is best way to ensure this doesn’t occur?

Such a major changes were made only once.
New sdk was published here: GitHub - Backendless/java-sdk
These changes were necessary in order to separate android and plain java SDKs.

Other errors, which you were talking recently doesn’t require any changes from your side (there were some server regressions).

That’s good to know. I’ve moved away from ‘Persistence’ to ‘Data’ and all seems to be working. Looks like ‘Data’ is used to save or delete a row in a table, is ‘Persistence’ still used to update an existing record, or can ‘Data’ be used here as well?

At the end of this exercise I am now on the latest SDK anyway, so good time to update anyway.

Thanks both for looking into this, really appreciate the support.

Persistence was an alias for Data, that’s why it was removed, as the one that does not bring any benefit.
So, they are totally interchangable.

1 Like