2

I have setup a small test java application that calls a python script after starting a pyro server (in python). It works great except now I want to pass the python class an object as a parameter to its method. I get an exception from the python side saying:

Pyro4.errors.SerializeError: unsupported serialized class: 
com.test.pyro4.TestLog  

According to pyros documentation a class will get converted to a dict in python but I can't even get that far.

java code:

NameServerProxy ns = NameServerProxy.locateNS("localhost");
PyroProxy remotePluginObject = new PyroProxy(ns.lookup("plugin"));

int length = 5;
double[] values = new double[] { 0.5, 0.3, 0.6, 05, 0.4 };
double a = 6.94;
double b = 2.17;

remoteObject = new PyroProxy(ns.lookup("test.object"));
remoteObject.call("setValues", values, length);

Object result = remoteObject.call("calculate", remoteObject, a, b);

System.out.println(result.toString());

remotePluginObject.close();             
remoteObject.close();
ns.close();

python server code:

class TestObject(object):
values=[]
length=0

def setValues(self, valuesArray, lengthValue):
    values=valuesArray
    length=lengthValue    

class Plugin(object):
def calculate(self, obj, a, b):
    result = example.calculate(obj, a, b)
    return result

plugin=Plugin()
obj=TestObject()

daemon=Pyro4.Daemon()
ns=Pyro4.locateNS()

pluginURI=daemon.register(plugin)
ns.register("plugin", pluginURI)

objURI=daemon.register(obj)
ns.register("test.object", objURI)

daemon.requestLoop()
user1584120
  • 1,169
  • 2
  • 23
  • 44
  • code has been updated to show how it now works. object is created on python side and then its requested via proxy on java side, values set, and then used in call to python method. – user1584120 May 14 '15 at 14:13
  • I spoke too soon. Above code does not work. Gets the following error: TypeError: 'float' object is not iterable. I have stripped out all prameters from call to python leaving just the object and it appears to be something with that? – user1584120 May 14 '15 at 14:49

1 Answers1

0

Try setting the serializer to pickle:

Pyro4.config.SERIALIZER = 'pickle'

Be aware that this has security implications.

And this in Java:

Config.SERIALIZER = Config.SerializerType.pickle; 
Mike Müller
  • 82,630
  • 20
  • 166
  • 161