[Py4j-users] Exception when printing a returned List<String> object
Status: Beta
Brought to you by:
barthe
From: <hg...@it...> - 2014-12-23 11:55:10
|
Hi, The method in my gateway server will return a List<String> object. When I access it in my python client code, the server has exception and then closed. The following is part of the exceptions ▒Q▒G▒▒ 23, 2014 5:18:14 ▒U▒▒ py4j.reflection.MethodInvoker invoke ĵ▒i: Exception occurred in client code. java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:231) at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:379) at py4j.Gateway.invoke(Gateway.java:259) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:133) at py4j.commands.CallCommand.execute(CallCommand.java:79) at py4j.GatewayConnection.run(GatewayConnection.java:207) at java.lang.Thread.run(Thread.java:745) Caused by: java.util.NoSuchElementException at java.util.AbstractList$Itr.next(AbstractList.java:364) ... 11 more What I do in client code is the following: >>>ret = gateway.entry_point.getMyStringList(inputStr) # it's ok to run this line >>>print ret # when running to this line, the server raised exception Below is the method in server side: public List<String> getMyStringList(String input) throws IOException { List<String> strList = new ArrayList<String>(); strList = segmenter.segmentString(input); // this is some 3rd party API for string tokenization and has been tested OK in console, the return object is List<String> return strList; } It's OK to access "ret" using indices and len(), but when I just type "ret" or "print ret", then it would display the content of "ret", but then the server poped Exception and stopped. What would be the problemt? Thanks for any help! Frank Yang ==================================================================== 本信件可能包含工研院機密資訊,非指定之收件者,請勿使用或揭露本信件內容,並請銷毀此信件。 This email may contain confidential information. Please do not use or disclose it in any way and delete it if you are not the intended recipient. |