0

MarshalBusException with InstantiationException, Android and Java

asked 2014-11-17 17:02:29 -0700

cs_chance gravatar image

updated 2014-11-19 09:13:46 -0700

I am trying to send a class between an Android application and a Java application running on a desktop. When I submit the data from the phone to the server, I receive the following error on the phone:

11-17 16:13:55.277: E/PERMISSION_MGR(2945):  267.553 ****** ERROR PERMISSION_MGR lepDisp    ...ndroid/PermissionDB.cc:202 | Failed to open /data/system/packages.xml: ER_FAIL
11-17 16:14:09.340: E/SimpleClient(2945): SimpleClient.sendBids(): org.alljoyn.bus.ErrorReplyBusException: org.alljoyn.Bus.ErStatus
11-17 16:14:09.340: E/SimpleClient(2945): org.alljoyn.bus.ErrorReplyBusException: org.alljoyn.Bus.ErStatus
11-17 16:14:09.340: E/SimpleClient(2945):   at org.alljoyn.bus.ProxyBusObject.methodCall(Native Method)
11-17 16:14:09.340: E/SimpleClient(2945):   at org.alljoyn.bus.ProxyBusObject.access$300(ProxyBusObject.java:36)
11-17 16:14:09.340: E/SimpleClient(2945):   at org.alljoyn.bus.ProxyBusObject$Handler.invoke(ProxyBusObject.java:241)
11-17 16:14:09.340: E/SimpleClient(2945):   at $Proxy1.sendBids(Native Method)
11-17 16:14:09.340: E/SimpleClient(2945):   at org.alljoyn.bus.samples.simpleclient.MainActivity$BusHandler.handleMessage(MainActivity.java:344)
11-17 16:14:09.340: E/SimpleClient(2945):   at android.os.Handler.dispatchMessage(Handler.java:99)
11-17 16:14:09.340: E/SimpleClient(2945):   at android.os.Looper.loop(Looper.java:137)
11-17 16:14:09.340: E/SimpleClient(2945):   at android.os.HandlerThread.run(HandlerThread.java:60)

And the following error message at the server:

24.938 ****** ERROR ALLJOYN_JAVA lepDisp      ...a/jni/alljoyn_java.cc:9946 | org.alljoyn.bus.MarshalBusException: cannot marshal '(aiibi)' into class org.alljoyn.bus.samples.ClientBid
  24.940 ****** ERROR ALLJOYN_JAVA lepDisp      ...a/jni/alljoyn_java.cc:9946 |     at org.alljoyn.bus.MsgArg.unmarshal(MsgArg.java:353)
  24.940 ****** ERROR ALLJOYN_JAVA lepDisp      ...a/jni/alljoyn_java.cc:9946 |     at org.alljoyn.bus.MsgArg.unmarshal(MsgArg.java:377)
  24.940 ****** ERROR ALLJOYN_JAVA lepDisp      ...a/jni/alljoyn_java.cc:9946 | Caused by: java.lang.InstantiationException: org.alljoyn.bus.samples.ClientBid
  24.941 ****** ERROR ALLJOYN_JAVA lepDisp      ...a/jni/alljoyn_java.cc:9946 |     at java.lang.Class.newInstance0(Class.java:342)
  24.941 ****** ERROR ALLJOYN_JAVA lepDisp      ...a/jni/alljoyn_java.cc:9946 |     at java.lang.Class.newInstance(Class.java:310)
  24.941 ****** ERROR ALLJOYN_JAVA lepDisp      ...a/jni/alljoyn_java.cc:9946 |     at org.alljoyn.bus.MsgArg.unmarshal(MsgArg.java:313)
  24.941 ****** ERROR ALLJOYN_JAVA lepDisp      ...a/jni/alljoyn_java.cc:9946 |     at org.alljoyn.bus.MsgArg.unmarshal(MsgArg.java:377)

I'm having trouble debugging the problem, because I'm not sure which issue is happening first. I suspect the issue is originating at the server, but there's nothing wrong with the associated class where the error is evidently occurring.

Here is the interface I'm using:

@BusInterface (name = "org.sample.busMethods")
public interface SampleInterface {  
    @BusMethod
    public void sendBids(ClientBid cb) throws BusException;
}

and the class:

public class ClientBid {    
    @Position(0) public int[] bids;
    @Position(1) public int sessionId;
    @Position(2) public boolean pcc;
    @Position(3) public int onInterruption;

    public ClientBid(int[] bids, int sessionId, boolean pcc, int onInterruption) {
        this.bids = bids;
        this.sessionId = sessionId ...
(more)
edit retag flag offensive close merge delete

Comments

Can you please post the Interface you are using and the data structure you are trying to send. I'm certain the issue is either a missmatch of the signature, missing annotation in the data structure, or a incorrect signature.

bspencer ( 2014-11-18 14:51:26 -0700 )edit

I've included the relevant code.

cs_chance ( 2014-11-19 09:14:31 -0700 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-11-20 12:07:15 -0700

Add a parameterless constructor to ClientBid:

public ClientBid() { }

See https://allseenalliance.org/docs/api/java/org/alljoyn/bus/annotation/Signature.html#note-3 .

edit flag offensive delete publish link more

Comments

I thought about trying that, but that's a circumvention rather than a correction. Why couldn't you instantiate an object with parameters?

cs_chance ( 2014-11-20 14:07:51 -0700 )edit

The unmarshalling code uses Class.newInstance() to create a ClientBid. Class.newInstance() doesn't support passing parameters.

tmalsbar ( 2014-11-20 23:08:10 -0700 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2014-11-17 17:02:29 -0700

Seen: 437 times

Last updated: Nov 20 '14