Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8921329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:30:54+00:00 2026-06-15T06:30:54+00:00

I have the following GWT code: package my.package.name; public class MyImpl { public void

  • 0

I have the following GWT code:

package my.package.name;

public class MyImpl {

    public void scan(AsyncCallback<String> callBack) {
        this.callBack = callBack;
        scanJNSI();
    }

    private native void scanJNSI()/*-{
        var instance = this;
        instance.@my.package.name.MyImpl::onError(Ljava/lang/String;)("BROWSER");
    }-*/;

    private void onError(String obj) {
        callBack.onFailure(new Exception(obj));
    }
}

When I call:

instance.scan(new AsyncCallback<String>() {
    @Override
    public void onSuccess(String result) {
        Window.alert(result);
    }

    @Override
    public void onFailure(Throwable caught) {
        Window.alert(caught.getMessage());
    }
});

I get a Caused by: java.lang.ClassCastException: null:

Caused by: java.lang.ClassCastException: null
    at java.lang.Class.cast(Class.java:2990)
    at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:163)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:57)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
    at my.package.name.MyImpl.scanJNSI(MyImpl.java)
    at my.package.name.MyImpl.scan(MyImpl.java:12)

What can possibly be the class that it couldn’t cast ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:30:55+00:00Added an answer on June 15, 2026 at 6:30 am

    I found a workaround:

    I replaced :

    instance.@my.package.name.MyImpl::onError(Ljava/lang/String;)("BROWSER");
    

    With:

    instance.@my.package.name.MyImpl::onError(Lcom/google/gwt/core/client/JavaScriptObject;)({name:"BROWSER"});
    

    And

    private void onError(String obj) {
        callBack.onFailure(new Exception(obj));
    }
    

    With:

    private void onError(JavaScriptObject obj) {
        JSOModel jso = obj.cast();
        callBack.onFailure(new Exception(jso.get("name")));
    }
    

    And it worked..

    I don’t know if using the String class is the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code from GWT in Action: public void processOperator(final AbstractOperator
Using GWT I have a Java class: public class Pojo { private String name;
In my GWT app I have the following model class: import com.google.gwt.user.client.rpc.IsSerializable; public class
I have the 2 following entities: @Entity @Table(name = brand) public class Brand {
I have the following code in my presenter in a GWT MVP application: public
I have the following GWT module: public class FizzModule implements EntryPoint { private Buzz
I have the following code in a GWT class: private native JavaScriptObject getRequest() /*-{
I have the following code from a GWT Project that is part of the
Using GWT 1.6.4, I have the following code to retrieve the dimensions of the
I have the following code in an abstract java class: protected abstract <E extends

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.