Getting a weird cast exception when trying to run a Warp10 extension

19 views
Skip to first unread message

Alexandre Berthaud

unread,
Aug 10, 2020, 5:05:26 AM8/10/20
to Warp 10 users
Hey everyone,

I'm working on a Warp10 extension and I cannot make it work because of a casting exception which does not make any sense to me.

My extension has this in its dependencies: io.warp10:warpscript:2.6.0

I'm trying to make it run in a standalone Warp10 2.6.0 (clean install).

This is the "main" class:

package com.clevercloud.warp10.script.ext.pulsarwriter;

import java.util.HashMap;
import java.util.Map;

import io.warp10.warp.sdk.WarpScriptExtension;

public class PulsarWriterExtension extends WarpScriptExtension {

  private static final Map<String, Object> functions;

  static {
      functions = new HashMap<String, Object>();
      functions.put("SENDTOPULSAR", new SENDTOPULSAR("SENDTOPULSAR"));
  }

  @Override
  public Map<String, Object> getFunctions() {
      return functions;
  }
}

Here is how I added it in the configuration: warpscript.extension.pulsarwriter = com.clevercloud.warp10.script.ext.pulsarwriter.PulsarWriterExtension

Now, here's the error I'm getting when starting Warp10:

Exception in thread "main" java.lang.RuntimeException: java.lang.ClassCastException: com.clevercloud.warp10.script.ext.pulsarwriter.PulsarWriterExtension cannot be cast to io.warp10.warp.sdk.WarpScriptExtension
    at io.warp10.script.WarpScriptLib.registerExtensions(WarpScriptLib.java:2496)
    at io.warp10.standalone.Warp.main(Warp.java:270)

Am I missing something obvious? Could there be a dependency issue somewhere in the sdk?

Thanks for your help!

mathias....@gmail.com

unread,
Aug 10, 2020, 10:43:25 AM8/10/20
to Warp 10 users
Most likely you packaged your extension with the WarpScript dependency.

The safest way is to use WarpFleet CLI tool to create a template for a new extension.

Alexandre Berthaud

unread,
Aug 11, 2020, 3:03:59 AM8/11/20
to Warp 10 users
Oh I definitely did that, I did not think it would be an issue.

Thanks for your input.

Alexandre Berthaud

unread,
Aug 11, 2020, 3:22:49 AM8/11/20
to Warp 10 users

That was it, I excluded the warpscript dependency from the fat jar I was generating with shadowJar and it works fine now.

For future reference, here is what I added into my build.gradle file:

shadowJar {
    dependencies {
      exclude(dependency('io.warp10:warpscript'))
    }
}

Reply all
Reply to author
Forward
0 new messages