Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException with CompositeService when calling method inherited from super-interface #56

Open
federicoon opened this issue Feb 11, 2015 · 0 comments
Labels
Milestone

Comments

@federicoon
Copy link

Following the example in the documentation, a composite server is created as:

    UserverService userService = ...;
    ContentService contentService = ...;
    BlackJackService blackJackService = ...;

    Object compositeService = ProxyUtil.createCompositeServiceProxy(
        this.getClass().getClassLoader(),
        new Object[] { userService, contentService, blackJackService},
        new Class<?>[] { UserService.class, ContentService.class, BlackJackService.class},
        true);

And then the corresponding client-side code is:

    UserverService userService = ProxyUtil.createClientProxy(
                UserverService.class.getClassLoader(), UserverService.class,
                jsonRpcClient, socket);
    ContentService contentService = ...;
    BlackJackService blackJackService = ...;

    Object compositeService = ProxyUtil.createCompositeServiceProxy(
        this.getClass().getClassLoader(),
        new Object[] { userService, contentService, blackJackService},
        new Class<?>[] { UserService.class, ContentService.class, BlackJackService.class},
        true);

    // now compositeService can be used as any of the above service, ie:
    User user = ((UserverService)compositService).createUser(...);
    Content content =  ((ContentService)compositService).getContent(...);
    Hand hand = ((BlackJackService)compositService).dealHand(...);  

Now, suppose both UserverService and ContentService extend a super-interface OperationService, which declares a method getOperation();
Then both calls:

    int id = ((UserverService)compositService).getOperation();
    int id = ((ContentService)compositService).getOperation();

will throw the following exception:

java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.googlecode.jsonrpc4j.ProxyUtil$1.invoke(ProxyUtil.java:103)
at com.sun.proxy.$Proxy6.getOperation(Unknown Source)

@gaborbernat gaborbernat added this to the 1.3.0 milestone Nov 10, 2015
@gaborbernat gaborbernat self-assigned this Nov 10, 2015
@gaborbernat gaborbernat removed their assignment Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants