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 7027019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:11:36+00:00 2026-05-28T00:11:36+00:00

I got a question about the usage of GWT-RequestFactory in Android. As a starting

  • 0

I got a question about the usage of GWT-RequestFactory in Android. As a starting point I used the code from the “Create a AppEngine connected Android-Project”-Wizard (infos: http://code.google.com/intl/de-DE/eclipse/docs/appengine_connected_android.html) and it worked great.

But now in my case I want do extend this application to use a local ContentProvider with SQLite and a SyncService with SyncAdapter do synchronize the data from the ContentProvider to the AppEngine using the RequestFactory.
Now my problem is the following: I can call

MyRequestFactory requestFactory = Util.getRequestFactory(mContext, MyRequestFactory.class);

in any Activity I want and will receive an instance of MyRequestFactory. (Note: Util is a class created by the Wizard.) But if I try to make the same call from my SyncAdapter, I will get a
java.lang.RuntimeException: The RequestFactory ValidationTool must be run for the com.hotool.client.MyRequestFactory RequestFactory type”.

Maybe for your information: The Util.getRequestFacory method looks like this:

/**
* Creates and returns an initialized {@link RequestFactory} of the given
* type.
 */
public static <T extends RequestFactory> T getRequestFactory(
        Context context, Class<T> factoryClass) {

    T requestFactory = RequestFactorySource.create(factoryClass);

    SharedPreferences prefs = getSharedPreferences(context);
    String authCookie = prefs.getString(Util.AUTH_COOKIE, null);

    String uriString = Util.getBaseUrl(context) + RF_METHOD;
    URI uri;
    try {
        uri = new URI(uriString);
    } catch (URISyntaxException e) {
        Log.w(TAG, "Bad URI: " + uriString, e);
        return null;
    }
    requestFactory.initialize(new SimpleEventBus(),
            new AndroidRequestTransport(uri, authCookie));

    return requestFactory;
}

The error occurs in RequestFactorySource which lies in the requestfactory-client.jar
I think, that this may be a Class-Loader problem, but tried to figure it out with no success.

I tried to use the ValidationTool but first of all it didn’t help and secondly I discovered, that the classes the ValidationTool will generate are already in place (probably thanks to annotation-processing as mentioned here: http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation)

Does anybody have an idea what could cause this?

Thanks a lot and best regards.

Markus Neuenschwander

  • 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-05-28T00:11:37+00:00Added an answer on May 28, 2026 at 12:11 am

    You are right Mark, this is an class-loader issue.

    It happens in the requestfactory-client.jar, here the relevant source:

    class InProcessRequestFactory extends AbstractRequestFactory {
    
        //...
    
        public InProcessRequestFactory(Class<? extends RequestFactory> requestFactoryInterface) {
            this.requestFactoryInterface = requestFactoryInterface;
            deobfuscator =
                Deobfuscator.Builder.load(requestFactoryInterface,
                    Thread.currentThread().getContextClassLoader()).build();
        }
    
        //...
    
    }
    

    and

    public class Deobfuscator {
    
        //...
    
        public static class Builder {
            public static Builder load(Class<?> clazz, ClassLoader resolveClassesWith) {
                Throwable ex;
                try {
                    Class<?> found;
                    try {
                        // Used by the server
                        found = Class.forName(clazz.getName() + GENERATED_SUFFIX, false, resolveClassesWith);
                    } catch (ClassNotFoundException ignored) {
                        // Used by JRE-only clients
                        found = Class.forName(clazz.getName() + GENERATED_SUFFIX_LITE, false, resolveClassesWith);
                    }
                    Class<? extends Builder> builderClass = found.asSubclass(Builder.class);
                    Builder builder = builderClass.newInstance();
                    return builder;
                } catch (ClassNotFoundException e) {
                    throw new RuntimeException("The RequestFactory ValidationTool must be run for the "
                        + clazz.getCanonicalName() + " RequestFactory type");
                } catch (InstantiationException e) {
                ex = e;
            } catch (IllegalAccessException e) {
                ex = e;
            }
            throw new RuntimeException(ex);
        }
    
        //...
    
    }
    

    The problem is that Thread.currentThread().getContextClassLoader() seems to return a null value when called from the sync adapter on Android, because the Sync Adapter thread is created by the System, not by your application.

    I solved this by calling manually calling setContextClassLoader in the onPerformSync method before creating a requestfactory instance:

    @Override
    public void onPerformSync(final Account account, Bundle extras,
            String authority, final ContentProviderClient provider,
            final SyncResult syncResult) {
    
        Thread.currentThread().setContextClassLoader(mContext.getClassLoader());
    
        // ...
    
        MyRequestFactory requestFactory = Util.getRequestFactory(mContext,
                MyRequestFactory.class, acsidToken);
    
        // ...
    }
    

    I hope this makes sense.
    Andreas

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

Sidebar

Related Questions

I've got a question about getting the values from a constructor in a generic
I got a question about usage of JMS(Java Message Queue). Somewhere in documentation I
I've got one question about the memory management of the NSMutableArray . I create
Currently I'm running some code and got some question about this. Below are the
I've got question about wpf xaml style definitions. When I try to set style
Just got a question about generics, why doesn't this compile when using a generic
i got a question about unsigned char array. How can i store an integer
I've got a question about references between projects in a solution. Most of my
I've got a question about testing methods working on strings. Everytime, I write a
i've got a question about how is it possible (if possible :) to use

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.