0

I have a remote method created via Python web2py. How do I test and invoke the method from Java?

I was able to test if the method implements @service.xmlrpc but how do i test if the method implements @service.run?

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
deeshank
  • 4,286
  • 4
  • 26
  • 32

4 Answers4

1

I'd be astonished if you could do it at all. Java RMI requires Java peers.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • 1) Java RMI is over IIOP 2) it's a socket communication, if you want to code it in COBOL, Pascal or whatever you want, you can ;-) – Aubin Oct 15 '12 at 18:01
  • @Aubin Java RMI is over JRMP, IIOP, or JERI actually, and a few other proprietary implementations as well, and if it involves Naming, as you suggested in your answer, it is definitely over JRMP, which in turn is layered over Object Serialization, which requires a JVM. You don't seem to know much about it. – user207421 Oct 15 '12 at 21:04
0

You have to write an interface X extends Remote declaring a method "myMethod()".

X x = (X)Naming.lookup( "//a/b/c" );
x.myMethod();

One of the difficulty is to manage the Naming at server side.

Aubin
  • 14,617
  • 9
  • 61
  • 84
  • try { pyinterface hello = (pyinterface) Naming.lookup ("http://www.py.code.srmri.co.in/depyweb/default/call/run"); System.out.println (hello.m2()); } catch (Exception e) { System.out.println ("Exception: " + e); } I got Exception: java.net.MalformedURLException: invalid URL scheme: http://www.py.code.srmri.co.in/depyweb/default/call/run – deeshank Oct 15 '12 at 06:36
  • See the documentation of URI : http://docs.oracle.com/javase/7/docs/api/java/rmi/Naming.html – Aubin Oct 15 '12 at 18:07
  • I'm aware of how Naming works, thank you. My scepticism is about Python's ability to implement RMI, as I stated in my own answer, starting with its ability to put anything *into* an RMI Registry. I repeat: have you tried it? – user207421 Oct 15 '12 at 20:18
0

This is not possible unless you use some kind of java-python bridge (jython) and that would still be Java RMI i.e. a java program calling another java program which wraps your python scripts.

Community
  • 1
  • 1
Santosh
  • 17,667
  • 4
  • 54
  • 79
  • Python script is interpreted by an engine. This engine is an execution platform which offer a lot of services. – Aubin Oct 15 '12 at 18:10
  • @Aubin Unless those services include a fully functioning JVM the comment is irrelevant. – user207421 Oct 15 '12 at 20:18
0

If the question can be interpreted loosely as "using Java to invoke Python method" (if you do not need to use Java RMI specifically) then there are other frameworks you can use for bridging Java and python. E.g. one open source licensed alternative is Versile (full disclosure: I am one of the developers). See Versile Python and Versile Java documentation for examples of usage.

Versile
  • 308
  • 1
  • 4