py4j-users Mailing List for Py4J (Page 5)
Status: Beta
Brought to you by:
barthe
You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
|
Feb
(1) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
2011 |
Jan
(6) |
Feb
(1) |
Mar
(8) |
Apr
(6) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
|
Dec
(4) |
2012 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
(7) |
Jun
(9) |
Jul
(10) |
Aug
|
Sep
|
Oct
(6) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
|
Dec
(1) |
2014 |
Jan
(3) |
Feb
|
Mar
(3) |
Apr
|
May
(5) |
Jun
|
Jul
(2) |
Aug
(3) |
Sep
|
Oct
(1) |
Nov
|
Dec
(21) |
2015 |
Jan
(2) |
Feb
(5) |
Mar
(4) |
Apr
|
May
|
Jun
(5) |
Jul
(12) |
Aug
|
Sep
(1) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
From: Eleftherios A. <ele...@df...> - 2012-06-22 13:24:21
|
Dear all, I would like your help with a particular issue which occurs when I am trying to use python multiprocessing, along with Py4j Java objects. def singlethread(gateway): print "Thread starting" #create a new view for the jvm meteor_view = gateway.new_jvm_view() #import required packages java_import(meteor_view, 'edu.cmu.meteor.scorer.*') #initialize the java object scorer = meteor_view.MeteorScorer() print "object initialized" #run object function stats = scorer.getMeteorStats("Test sentence", "Test sentence !"); print stats.score if __name__ == '__main__': socket_no = 25336 gatewayclient = GatewayClient('localhost', socket_no) print "Gclient started" gateway = JavaGateway(gatewayclient, auto_convert=True, auto_field=True) print "Gateway started" p = multiprocessing.Pool(2) print "Multipool initialized" p.map(singlethread, [gateway, gateway, gateway]) output: Gclient started Gateway started Multipool initialized Exception in thread Thread-2: Traceback (most recent call last): File "/usr/local/lib/python2.7/threading.py", line 552, in __bootstrap_inner self.run() File "/usr/local/lib/python2.7/threading.py", line 505, in run self.__target(*self.__args, **self.__kwargs) File "/usr/local/lib/python2.7/multiprocessing/pool.py", line 313, in _handle_tasks put(task) File "/usr/local/lib/python2.7/site-packages/py4j/java_gateway.py", line 432, in __call__ self.target_id, self.name) File "/usr/local/lib/python2.7/site-packages/py4j/protocol.py", line 271, in get_return_value raise Py4JError('An error occurred while calling %s%s%s. Trace:\n%s\n' % (target_id, '.', name, value)) Py4JError: An error occurred while calling t.__getnewargs__. Trace: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1949) at java.lang.String.substring(String.java:1916) at py4j.Gateway.invoke(Gateway.java:250) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:124) at py4j.commands.CallCommand.execute(CallCommand.java:81) at py4j.GatewayConnection.run(GatewayConnection.java:175) at java.lang.Thread.run(Thread.java:636) I would be happy if somebody can help me find out what exactly the error may be, or if you can indicate where I should look for the problem. Interestingly enough, this problem doesn't occur when running without multiprocessing. It also runs fine with other Java programs. But how can I specify which aspect of the Java program causes the error? best Eleftherios -- MSc. Inf. Eleftherios Avramidis DFKI GmbH, Alt-Moabit 91c, 10559 Berlin Tel. +49-30 238 95-1806 Fax. +49-30 238 95-1810 ------------------------------------------------------------------------------------------- Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH Firmensitz: Trippstadter Strasse 122, D-67663 Kaiserslautern Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster (Vorsitzender) Dr. Walter Olthoff Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes Amtsgericht Kaiserslautern, HRB 2313 ------------------------------------------------------------------------------------------- |
From: Barthelemy D. <ba...@cs...> - 2012-06-15 08:54:55
|
Hi, Sorry about the delay in responding and thanks for using Py4J! The first line looks good except that you need to use the fully qualified name of the class containing the static method (unless the class is in the java.lang package). For example: lp = gateway.jvm.package1.package2.ConvertFunction.convert("") The error you are seeing seems to point into that direction as well. Barthélémy On 2012-06-13, at 6:25 AM, Disley, Jareth wrote: > Hello, > > I am having an issue calling a static method within a Java class and package from within Python. > > The background is that the method is declared static and has no constructor. I believe that the class / package has been imported correctly. > > I have tried all of the following approaches: > > Ip = gateway.jvm.class.ConvertFunction.convert(“10.10.0.0”) > > Klass = gateway.jvm.class.ConvertFunction() > Ip =Klass.convert(“10.10.0.0”) > > Klass = gateway.jvm.class.ConvertFunction > Ip =Klass.convert(“10.10.0.0”) > > Every time I get the “Trying to call a package” error. Which one of these methods is correct? > > Regards > Jareth Disley > > > -- > > > Queen's Award for Enterprise and Innovation 2011 > > Roke Manor Research Ltd > Romsey, Hampshire, SO51 0ZN, United Kingdom > http://www.roke.co.uk > > Part of the Chemring Group > Registered in England & Wales at: > Chemring Group PLC, Chemring House, 1500 Parkway, > Whiteley, Fareham, Hampshire PO15 7AF, England. > Registered No: 267550 > > The information contained in this e-mail and any attachments is > proprietary to Roke Manor Research Ltd and must not be passed to any > third party without permission. This communication is for information > only and shall not create or change any contractual relationship. > > Please consider the environment before printing this email > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |
From: Disley, J. <Jar...@ro...> - 2012-06-13 10:26:35
|
Hello, I am having an issue calling a static method within a Java class and package from within Python. The background is that the method is declared static and has no constructor. I believe that the class / package has been imported correctly. I have tried all of the following approaches: Ip = gateway.jvm.class.ConvertFunction.convert("10.10.0.0") Klass = gateway.jvm.class.ConvertFunction() Ip =Klass.convert("10.10.0.0") Klass = gateway.jvm.class.ConvertFunction Ip =Klass.convert("10.10.0.0") Every time I get the "Trying to call a package" error. Which one of these methods is correct? Regards Jareth Disley -- Queen's Award for Enterprise and Innovation 2011 Roke Manor Research Ltd Romsey, Hampshire, SO51 0ZN, United Kingdom http://www.roke.co.uk Part of the Chemring Group Registered in England & Wales at: Chemring Group PLC, Chemring House, 1500 Parkway, Whiteley, Fareham, Hampshire PO15 7AF, ENGLAND. Registered No: 267550 ------------------------------------------------------------------------ The information contained in this e-mail and any attachments is proprietary to Roke Manor Research Ltd and must not be passed to any third party without permission. This communication is for information only and shall not create or change any contractual relationship. ------------------------------------------------------------------------ Please consider the environment before printing this email |
From: Goodwin, J. - 0. - M. <jgo...@ll...> - 2012-05-11 17:36:27
|
All other tests pass except BufferGatewayTest, the test fails with the following message: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432) at java.net.Socket.connect(Socket.java:529) at java.net.Socket.connect(Socket.java:478) at java.net.Socket.<init>(Socket.java:375) at java.net.Socket.<init>(Socket.java:189) at py4j.EchoClient.connect(EchoClient.java:70) at py4j.BufferGatewayTest.testBufferedGateway1(BufferGatewayTest.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) EchoClientTest and EchoClientServer both succeed just fine. My machine is behind a proxy but the test is for 'localhost', some reason I cannot connect to the gateway even through the python code. Justin |
From: Dave M. <dav...@se...> - 2012-05-03 13:45:39
|
That's it! Thank you, I'm off to the races now (until I stumble and fall again). I have another plane ride tonight might get a chance to try some stuff. Thanks again. ________________________________________ From: Barthelemy Dagenais [ba...@cs...] Sent: Wednesday, May 02, 2012 4:51 PM To: Support and Comments about Py4J Subject: Re: [Py4j-users] Getting Started Trouble with the java jar file Hi, the classpath must specify a jar file or a directory containing .class files. You probably need something like C:\Python27\share\py4j\py4j0.7.jar Barthélémy On 2012-05-01, at 5:53 PM, Dave McComb wrote: > Thanks again, so I tried with the classpath as follows (I could easily have some syntactic problem here) > > Is there any way to tell whether the jar file called py4j0.7.jar actually has the package inside it call examples and that in turn has GatewayServer in it? > > > D:\LocalArchives\My Dropbox\python\pythonJava>javac -classpath "C:\Python27\shar > e\py4j" OperatorExample.java > OperatorExample.java:2: cannot find symbol > symbol : class GatewayServer > location: package py4j > import py4j.GatewayServer; > ^ > 1 error > > > -----Original Message----- > From: Barthelemy Dagenais [mailto:ba...@cs...] > Sent: Tuesday, May 01, 2012 7:18 AM > To: Support and Comments about Py4J > Subject: Re: [Py4j-users] Getting Started Trouble with the java jar file > > Hi Dave, > > I would need more information about the way you run your java program. Is it from an IDE, from the command line? What exact command are you using? Usually, when you run a java program, you can specify where to find the jar files with the -classpath option, e.g., java -classpath /path/to/py4j.jar fully.qualified.name.MainClass > > Barthélémy > > > On 2012-04-30, at 7:51 PM, Dave McComb wrote: > >> I hate to be such a noob (but there is no avoiding it sometimes). >> >> I've been working for several hours on the first couple of examples from the py4J documentation (much of it on the airplane which makes it more difficult when you get stuck) but I'm not getting anywhere. >> >> I'm a very so-so python developer and have done very little java development. My intention is to use call some existing open source java libraries for some work I'm doing in python. >> >> I get error code 10061 when I try to run the first example, which I now realize is likely because I don' t have the java programming running that is to catch my socket requests. >> >> I managed to write a very simple java program, but any time I had to >> include anything from package py4j.examples it claims it can't find >> it. I've put the jar file py4j0.7.jar (which I'm hoping contains the >> examples package which I also hope is the essential bit of this >> exercise) just about every place I can think of, including: a) where >> easy_install put it >> (C:\Python27\Lib\site-packages\py4j-0.7-py2.7.egg\share\py4j) b) >> where the documentation said to put it (C:\Python27\share\py4j) c) in >> the directory where I'm writing the java classes (D:\LocalArchives\My >> Dropbox\python\pythonJava) and d) in the directory where the other jar >> files are for my jdk install (C:\Program Files\Java\jdk1.6.0_31\lib ) >> >> I'm guessing there is another place to put this file that hasn't >> occurred to me yet (which is probably common knowledge but I don't >> have it) >> >> Thanks in advance. >> >> PS the other possibility is that py4j.examples isn't the literal package name, but meant as an example, in which case, what is the package name? >> ---------------------------------------------------------------------- >> -------- >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. >> Discussions will include endpoint security, mobile security and the >> latest in malware threats. >> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_____________ >> __________________________________ >> Py4j-users mailing list >> Py4...@li... >> https://lists.sourceforge.net/lists/listinfo/py4j-users > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Py4j-users mailing list Py4...@li... https://lists.sourceforge.net/lists/listinfo/py4j-users |
From: Barthelemy D. <ba...@cs...> - 2012-05-02 22:51:42
|
Hi, the classpath must specify a jar file or a directory containing .class files. You probably need something like C:\Python27\share\py4j\py4j0.7.jar Barthélémy On 2012-05-01, at 5:53 PM, Dave McComb wrote: > Thanks again, so I tried with the classpath as follows (I could easily have some syntactic problem here) > > Is there any way to tell whether the jar file called py4j0.7.jar actually has the package inside it call examples and that in turn has GatewayServer in it? > > > D:\LocalArchives\My Dropbox\python\pythonJava>javac -classpath "C:\Python27\shar > e\py4j" OperatorExample.java > OperatorExample.java:2: cannot find symbol > symbol : class GatewayServer > location: package py4j > import py4j.GatewayServer; > ^ > 1 error > > > -----Original Message----- > From: Barthelemy Dagenais [mailto:ba...@cs...] > Sent: Tuesday, May 01, 2012 7:18 AM > To: Support and Comments about Py4J > Subject: Re: [Py4j-users] Getting Started Trouble with the java jar file > > Hi Dave, > > I would need more information about the way you run your java program. Is it from an IDE, from the command line? What exact command are you using? Usually, when you run a java program, you can specify where to find the jar files with the -classpath option, e.g., java -classpath /path/to/py4j.jar fully.qualified.name.MainClass > > Barthélémy > > > On 2012-04-30, at 7:51 PM, Dave McComb wrote: > >> I hate to be such a noob (but there is no avoiding it sometimes). >> >> I've been working for several hours on the first couple of examples from the py4J documentation (much of it on the airplane which makes it more difficult when you get stuck) but I'm not getting anywhere. >> >> I'm a very so-so python developer and have done very little java development. My intention is to use call some existing open source java libraries for some work I'm doing in python. >> >> I get error code 10061 when I try to run the first example, which I now realize is likely because I don' t have the java programming running that is to catch my socket requests. >> >> I managed to write a very simple java program, but any time I had to >> include anything from package py4j.examples it claims it can't find >> it. I've put the jar file py4j0.7.jar (which I'm hoping contains the >> examples package which I also hope is the essential bit of this >> exercise) just about every place I can think of, including: a) where >> easy_install put it >> (C:\Python27\Lib\site-packages\py4j-0.7-py2.7.egg\share\py4j) b) >> where the documentation said to put it (C:\Python27\share\py4j) c) in >> the directory where I'm writing the java classes (D:\LocalArchives\My >> Dropbox\python\pythonJava) and d) in the directory where the other jar >> files are for my jdk install (C:\Program Files\Java\jdk1.6.0_31\lib ) >> >> I'm guessing there is another place to put this file that hasn't >> occurred to me yet (which is probably common knowledge but I don't >> have it) >> >> Thanks in advance. >> >> PS the other possibility is that py4j.examples isn't the literal package name, but meant as an example, in which case, what is the package name? >> ---------------------------------------------------------------------- >> -------- >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. >> Discussions will include endpoint security, mobile security and the >> latest in malware threats. >> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_____________ >> __________________________________ >> Py4j-users mailing list >> Py4...@li... >> https://lists.sourceforge.net/lists/listinfo/py4j-users > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |
From: Dave M. <dav...@se...> - 2012-05-01 21:54:15
|
Thanks again, so I tried with the classpath as follows (I could easily have some syntactic problem here) Is there any way to tell whether the jar file called py4j0.7.jar actually has the package inside it call examples and that in turn has GatewayServer in it? D:\LocalArchives\My Dropbox\python\pythonJava>javac -classpath "C:\Python27\shar e\py4j" OperatorExample.java OperatorExample.java:2: cannot find symbol symbol : class GatewayServer location: package py4j import py4j.GatewayServer; ^ 1 error -----Original Message----- From: Barthelemy Dagenais [mailto:ba...@cs...] Sent: Tuesday, May 01, 2012 7:18 AM To: Support and Comments about Py4J Subject: Re: [Py4j-users] Getting Started Trouble with the java jar file Hi Dave, I would need more information about the way you run your java program. Is it from an IDE, from the command line? What exact command are you using? Usually, when you run a java program, you can specify where to find the jar files with the -classpath option, e.g., java -classpath /path/to/py4j.jar fully.qualified.name.MainClass Barthélémy On 2012-04-30, at 7:51 PM, Dave McComb wrote: > I hate to be such a noob (but there is no avoiding it sometimes). > > I've been working for several hours on the first couple of examples from the py4J documentation (much of it on the airplane which makes it more difficult when you get stuck) but I'm not getting anywhere. > > I'm a very so-so python developer and have done very little java development. My intention is to use call some existing open source java libraries for some work I'm doing in python. > > I get error code 10061 when I try to run the first example, which I now realize is likely because I don' t have the java programming running that is to catch my socket requests. > > I managed to write a very simple java program, but any time I had to > include anything from package py4j.examples it claims it can't find > it. I've put the jar file py4j0.7.jar (which I'm hoping contains the > examples package which I also hope is the essential bit of this > exercise) just about every place I can think of, including: a) where > easy_install put it > (C:\Python27\Lib\site-packages\py4j-0.7-py2.7.egg\share\py4j) b) > where the documentation said to put it (C:\Python27\share\py4j) c) in > the directory where I'm writing the java classes (D:\LocalArchives\My > Dropbox\python\pythonJava) and d) in the directory where the other jar > files are for my jdk install (C:\Program Files\Java\jdk1.6.0_31\lib ) > > I'm guessing there is another place to put this file that hasn't > occurred to me yet (which is probably common knowledge but I don't > have it) > > Thanks in advance. > > PS the other possibility is that py4j.examples isn't the literal package name, but meant as an example, in which case, what is the package name? > ---------------------------------------------------------------------- > -------- > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. > Discussions will include endpoint security, mobile security and the > latest in malware threats. > http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_____________ > __________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Py4j-users mailing list Py4...@li... https://lists.sourceforge.net/lists/listinfo/py4j-users |
From: Dave M. <dav...@se...> - 2012-05-01 18:38:20
|
Thanks. I'm just trying to run the simple example in the py4j documentation, (the Stack example) so I wrote the class in notepad and running it from the command line ( windows). I'll try the classpath arg when I get back to it Sent from my iPhone On May 1, 2012, at 9:37 AM, "Barthelemy Dagenais" <ba...@cs...> wrote: > Hi Dave, > > I would need more information about the way you run your java program. Is it from an IDE, from the command line? What exact command are you using? Usually, when you run a java program, you can specify where to find the jar files with the -classpath option, e.g., java -classpath /path/to/py4j.jar fully.qualified.name.MainClass > > Barthélémy > > > On 2012-04-30, at 7:51 PM, Dave McComb wrote: > >> I hate to be such a noob (but there is no avoiding it sometimes). >> >> I’ve been working for several hours on the first couple of examples from the py4J documentation (much of it on the airplane which makes it more difficult when you get stuck) but I’m not getting anywhere. >> >> I’m a very so-so python developer and have done very little java development. My intention is to use call some existing open source java libraries for some work I’m doing in python. >> >> I get error code 10061 when I try to run the first example, which I now realize is likely because I don’ t have the java programming running that is to catch my socket requests. >> >> I managed to write a very simple java program, but any time I had to include anything from package py4j.examples it claims it can’t find it. I’ve put the jar file py4j0.7.jar (which I’m hoping contains the examples package which I also hope is the essential bit of this exercise) just about every place I can think of, including: a) where easy_install put it (C:\Python27\Lib\site-packages\py4j-0.7-py2.7.egg\share\py4j) b) where the documentation said to put it (C:\Python27\share\py4j) c) in the directory where I’m writing the java classes (D:\LocalArchives\My Dropbox\python\pythonJava) and d) in the directory where the other jar files are for my jdk install (C:\Program Files\Java\jdk1.6.0_31\lib ) >> >> I’m guessing there is another place to put this file that hasn’t occurred to me yet (which is probably common knowledge but I don’t have it) >> >> Thanks in advance. >> >> PS the other possibility is that py4j.examples isn’t the literal package name, but meant as an example, in which case, what is the package name? >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ >> Py4j-users mailing list >> Py4...@li... >> https://lists.sourceforge.net/lists/listinfo/py4j-users > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |
From: Barthelemy D. <ba...@cs...> - 2012-05-01 13:37:34
|
Hi Dave, I would need more information about the way you run your java program. Is it from an IDE, from the command line? What exact command are you using? Usually, when you run a java program, you can specify where to find the jar files with the -classpath option, e.g., java -classpath /path/to/py4j.jar fully.qualified.name.MainClass Barthélémy On 2012-04-30, at 7:51 PM, Dave McComb wrote: > I hate to be such a noob (but there is no avoiding it sometimes). > > I’ve been working for several hours on the first couple of examples from the py4J documentation (much of it on the airplane which makes it more difficult when you get stuck) but I’m not getting anywhere. > > I’m a very so-so python developer and have done very little java development. My intention is to use call some existing open source java libraries for some work I’m doing in python. > > I get error code 10061 when I try to run the first example, which I now realize is likely because I don’ t have the java programming running that is to catch my socket requests. > > I managed to write a very simple java program, but any time I had to include anything from package py4j.examples it claims it can’t find it. I’ve put the jar file py4j0.7.jar (which I’m hoping contains the examples package which I also hope is the essential bit of this exercise) just about every place I can think of, including: a) where easy_install put it (C:\Python27\Lib\site-packages\py4j-0.7-py2.7.egg\share\py4j) b) where the documentation said to put it (C:\Python27\share\py4j) c) in the directory where I’m writing the java classes (D:\LocalArchives\My Dropbox\python\pythonJava) and d) in the directory where the other jar files are for my jdk install (C:\Program Files\Java\jdk1.6.0_31\lib ) > > I’m guessing there is another place to put this file that hasn’t occurred to me yet (which is probably common knowledge but I don’t have it) > > Thanks in advance. > > PS the other possibility is that py4j.examples isn’t the literal package name, but meant as an example, in which case, what is the package name? > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |
From: Dave M. <dav...@se...> - 2012-05-01 00:06:34
|
I hate to be such a noob (but there is no avoiding it sometimes). I've been working for several hours on the first couple of examples from the py4J documentation (much of it on the airplane which makes it more difficult when you get stuck) but I'm not getting anywhere. I'm a very so-so python developer and have done very little java development. My intention is to use call some existing open source java libraries for some work I'm doing in python. I get error code 10061 when I try to run the first example, which I now realize is likely because I don' t have the java programming running that is to catch my socket requests. I managed to write a very simple java program, but any time I had to include anything from package py4j.examples it claims it can't find it. I've put the jar file py4j0.7.jar (which I'm hoping contains the examples package which I also hope is the essential bit of this exercise) just about every place I can think of, including: a) where easy_install put it (C:\Python27\Lib\site-packages\py4j-0.7-py2.7.egg\share\py4j) b) where the documentation said to put it (C:\Python27\share\py4j) c) in the directory where I'm writing the java classes (D:\LocalArchives\My Dropbox\python\pythonJava) and d) in the directory where the other jar files are for my jdk install (C:\Program Files\Java\jdk1.6.0_31\lib ) I'm guessing there is another place to put this file that hasn't occurred to me yet (which is probably common knowledge but I don't have it) Thanks in advance. PS the other possibility is that py4j.examples isn't the literal package name, but meant as an example, in which case, what is the package name? |
From: Alex G. <ale...@ne...> - 2012-03-09 16:09:25
|
09.03.2012 03:23, Barthelemy Dagenais kirjoitti: > Hi Stephen, > > Py4J cannot handle the starting of a JVM, but there are many workarounds. If the JVM is on the same machine, you could use Python to start the JVM (with subprocess or popen2 module… or better yet, the envoy library). Is there a reason why it can't just open a subprocess and communicate through pipes? Why is a TCP connection necessary? > > Otherwise, if your JVM lives on another machine, you could just create a small java program accepting py4j requests that starts other JVMs. I use the example application for this so I don't have to write any Java code. > > This is a feature requested by many users so I may try to implement something that ease this task in the future, but the way to start a JVM is so different in each case that I'm not sure how to make it generic enough… > > Barthélémy |
From: Barthelemy D. <ba...@cs...> - 2012-03-09 11:23:52
|
Hi Stephen, Py4J cannot handle the starting of a JVM, but there are many workarounds. If the JVM is on the same machine, you could use Python to start the JVM (with subprocess or popen2 module… or better yet, the envoy library). Otherwise, if your JVM lives on another machine, you could just create a small java program accepting py4j requests that starts other JVMs. This is a feature requested by many users so I may try to implement something that ease this task in the future, but the way to start a JVM is so different in each case that I'm not sure how to make it generic enough… Barthélémy On 2012-03-07, at 2:26 PM, Stephen Molloy wrote: > Hi Bartélémy, > Your pointers were just what I needed to read, thanks. > > The problem, as you suggested, was that I was trying to use the same objects in each process, and so the multiprocessing module was trying to pickle everything to properly share it. I re-wrote the code so that each process communicates with its own dedicated JVM server so as to maximise the isolation between them, and everything is working perfectly now. > > On a related note, is it possible to start the JVM server running from within Python, and close it again when I am finished with it? If so, this would simplify the process of having my colleagues use the code, since I wouldn't have to provide them instructions with how to start and stop the necessary servers. > > Many thanks for your help. > > Steve > > On 7 Mar 2012, at 14:04, Barthelemy Dagenais wrote: > >> Hi Stephen, >> >> Here are a few pointers: >> >> 1. You should be able to use multiprocessing with py4j (multi-threading certainly works). Just make sure that you create a new JavaGateway instance in each process (don't reuse an instance that was created outside the process) and that you do not share JavaObject instances (objects returned by the Java side) across processes. I think you may be doing this in your code. Essentially, when you are sharing an instance across processes, you end up sharing a socket, which is tricky and probably won't work with the way sockets are initialized by py4j. >> >> 2. __getnewargs__ is usually used by python to pickle an object. If I remember correctly, pickle is used by multiprocessing to transfer/share objects across processes. >> >> 3. If you really want to "share" an object, you should probably save it somewhere on the Java side and request the object in each Python process. >> >> Hope this helps, >> Barthélémy >> >> On 2012-03-06, at 5:37 PM, Stephen Molloy wrote: >> >>> Hi all, >>> I have a working implementation of some Java code I inherited, wrapped up in Python using Py4J. Due to the long time for the calculations to complete, and the embarrassingly parallel nature of my problem, I am trying to use the Python multiprocessing module to speed things up. >>> >>> In particular, I create a pool of processes, and then submit jobs to them. Each job is almost identical, and Py4J to create a new Java object in the JVM server, and performs the necessary calculations. The problem is that it fails very quickly inside a Py4J call. >>> >>> There is a lot of code involved in this, but the following is the function that fails. The class "AJDiskAnalysis" contains the call to the JVM server that you can see in the klysOutputPower() function. >>> def klysOutputPower(Pin, AJDiskAnalObj): >>> """Returns the output power of the klystron for a given input power.""" >>> AJDiskAnalObj.klysanal.setInputPower(float(Pin)) >>> AJDiskAnalObj.simulate(disks=20) >>> return AJDiskAnalObj.klysanal.getSimulatedOutputPower() >>> >>> def powerScan(Pin, filename): >>> Pout, result, AJobj = [], [], [] >>> pool = mp.Pool(processes=12) >>> for power in Pin: >>> AJobj.append(AJDiskAnalysis(DSKParsObj=DSKParser(fname=filename))) >>> result.append(pool.apply_async(klysOutputPower, (power, AJobj[-1]))) >>> for i in result: >>> Pout.append(i.get()) >>> return Pout >>> >>> if __name__=="__main__": >>> Pin = arange(0, 150, 10) >>> Pout = powerScan(Pin, "ess-new-704.dsk") >>> >>> This results in the following error: >>> >>> Exception in thread Thread-1: >>> Traceback (most recent call last): >>> File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner >>> self.run() >>> File "/usr/lib64/python2.6/threading.py", line 484, in run >>> self.__target(*self.__args, **self.__kwargs) >>> File "/usr/lib64/python2.6/multiprocessing/pool.py", line 225, in _handle_tasks >>> put(task) >>> File "/usr/lib/python2.6/site-packages/py4j-0.7-py2.6.egg/py4j/java_gateway.py", line 432, in __call__ >>> self.target_id, self.name) >>> File "/usr/lib/python2.6/site-packages/py4j-0.7-py2.6.egg/py4j/protocol.py", line 271, in get_return_value >>> raise Py4JError('An error occurred while calling %s%s%s. Trace:\n%s\n' % (target_id, '.', name, value)) >>> Py4JError: An error occurred while calling o19.__getnewargs__. Trace: >>> py4j.Py4JException: Method __getnewargs__([]) does not exist >>> at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:346) >>> at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:355) >>> at py4j.Gateway.invoke(Gateway.java:247) >>> at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:124) >>> at py4j.commands.CallCommand.execute(CallCommand.java:81) >>> at py4j.GatewayConnection.run(GatewayConnection.java:175) >>> at java.lang.Thread.run(Thread.java:662) >>> >>> Is there some problem that prevents Py4J being used alongside the multiprocessing module, or is there something I am doing wrong? >>> I would be very happy for any hints or tips, and will happily provide any more information if it is needed. >>> >>> Steve >>> >>> ------------------------------------------------------------------------------ >>> Keep Your Developer Skills Current with LearnDevNow! >>> The most comprehensive online learning library for Microsoft developers >>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, >>> Metro Style Apps, more. Free future releases when you subscribe now! >>> http://p.sf.net/sfu/learndevnow-d2d_______________________________________________ >>> Py4j-users mailing list >>> Py4...@li... >>> https://lists.sourceforge.net/lists/listinfo/py4j-users >> > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |
From: Stephen M. <sdm...@gm...> - 2012-03-07 19:26:42
|
Hi Bartélémy, Your pointers were just what I needed to read, thanks. The problem, as you suggested, was that I was trying to use the same objects in each process, and so the multiprocessing module was trying to pickle everything to properly share it. I re-wrote the code so that each process communicates with its own dedicated JVM server so as to maximise the isolation between them, and everything is working perfectly now. On a related note, is it possible to start the JVM server running from within Python, and close it again when I am finished with it? If so, this would simplify the process of having my colleagues use the code, since I wouldn't have to provide them instructions with how to start and stop the necessary servers. Many thanks for your help. Steve On 7 Mar 2012, at 14:04, Barthelemy Dagenais wrote: > Hi Stephen, > > Here are a few pointers: > > 1. You should be able to use multiprocessing with py4j (multi-threading certainly works). Just make sure that you create a new JavaGateway instance in each process (don't reuse an instance that was created outside the process) and that you do not share JavaObject instances (objects returned by the Java side) across processes. I think you may be doing this in your code. Essentially, when you are sharing an instance across processes, you end up sharing a socket, which is tricky and probably won't work with the way sockets are initialized by py4j. > > 2. __getnewargs__ is usually used by python to pickle an object. If I remember correctly, pickle is used by multiprocessing to transfer/share objects across processes. > > 3. If you really want to "share" an object, you should probably save it somewhere on the Java side and request the object in each Python process. > > Hope this helps, > Barthélémy > > On 2012-03-06, at 5:37 PM, Stephen Molloy wrote: > >> Hi all, >> I have a working implementation of some Java code I inherited, wrapped up in Python using Py4J. Due to the long time for the calculations to complete, and the embarrassingly parallel nature of my problem, I am trying to use the Python multiprocessing module to speed things up. >> >> In particular, I create a pool of processes, and then submit jobs to them. Each job is almost identical, and Py4J to create a new Java object in the JVM server, and performs the necessary calculations. The problem is that it fails very quickly inside a Py4J call. >> >> There is a lot of code involved in this, but the following is the function that fails. The class "AJDiskAnalysis" contains the call to the JVM server that you can see in the klysOutputPower() function. >> def klysOutputPower(Pin, AJDiskAnalObj): >> """Returns the output power of the klystron for a given input power.""" >> AJDiskAnalObj.klysanal.setInputPower(float(Pin)) >> AJDiskAnalObj.simulate(disks=20) >> return AJDiskAnalObj.klysanal.getSimulatedOutputPower() >> >> def powerScan(Pin, filename): >> Pout, result, AJobj = [], [], [] >> pool = mp.Pool(processes=12) >> for power in Pin: >> AJobj.append(AJDiskAnalysis(DSKParsObj=DSKParser(fname=filename))) >> result.append(pool.apply_async(klysOutputPower, (power, AJobj[-1]))) >> for i in result: >> Pout.append(i.get()) >> return Pout >> >> if __name__=="__main__": >> Pin = arange(0, 150, 10) >> Pout = powerScan(Pin, "ess-new-704.dsk") >> >> This results in the following error: >> >> Exception in thread Thread-1: >> Traceback (most recent call last): >> File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner >> self.run() >> File "/usr/lib64/python2.6/threading.py", line 484, in run >> self.__target(*self.__args, **self.__kwargs) >> File "/usr/lib64/python2.6/multiprocessing/pool.py", line 225, in _handle_tasks >> put(task) >> File "/usr/lib/python2.6/site-packages/py4j-0.7-py2.6.egg/py4j/java_gateway.py", line 432, in __call__ >> self.target_id, self.name) >> File "/usr/lib/python2.6/site-packages/py4j-0.7-py2.6.egg/py4j/protocol.py", line 271, in get_return_value >> raise Py4JError('An error occurred while calling %s%s%s. Trace:\n%s\n' % (target_id, '.', name, value)) >> Py4JError: An error occurred while calling o19.__getnewargs__. Trace: >> py4j.Py4JException: Method __getnewargs__([]) does not exist >> at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:346) >> at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:355) >> at py4j.Gateway.invoke(Gateway.java:247) >> at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:124) >> at py4j.commands.CallCommand.execute(CallCommand.java:81) >> at py4j.GatewayConnection.run(GatewayConnection.java:175) >> at java.lang.Thread.run(Thread.java:662) >> >> Is there some problem that prevents Py4J being used alongside the multiprocessing module, or is there something I am doing wrong? >> I would be very happy for any hints or tips, and will happily provide any more information if it is needed. >> >> Steve >> >> ------------------------------------------------------------------------------ >> Keep Your Developer Skills Current with LearnDevNow! >> The most comprehensive online learning library for Microsoft developers >> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, >> Metro Style Apps, more. Free future releases when you subscribe now! >> http://p.sf.net/sfu/learndevnow-d2d_______________________________________________ >> Py4j-users mailing list >> Py4...@li... >> https://lists.sourceforge.net/lists/listinfo/py4j-users > |
From: Barthelemy D. <ba...@cs...> - 2012-03-07 13:35:34
|
Hi Stephen, Here are a few pointers: 1. You should be able to use multiprocessing with py4j (multi-threading certainly works). Just make sure that you create a new JavaGateway instance in each process (don't reuse an instance that was created outside the process) and that you do not share JavaObject instances (objects returned by the Java side) across processes. I think you may be doing this in your code. Essentially, when you are sharing an instance across processes, you end up sharing a socket, which is tricky and probably won't work with the way sockets are initialized by py4j. 2. __getnewargs__ is usually used by python to pickle an object. If I remember correctly, pickle is used by multiprocessing to transfer/share objects across processes. 3. If you really want to "share" an object, you should probably save it somewhere on the Java side and request the object in each Python process. Hope this helps, Barthélémy On 2012-03-06, at 5:37 PM, Stephen Molloy wrote: > Hi all, > I have a working implementation of some Java code I inherited, wrapped up in Python using Py4J. Due to the long time for the calculations to complete, and the embarrassingly parallel nature of my problem, I am trying to use the Python multiprocessing module to speed things up. > > In particular, I create a pool of processes, and then submit jobs to them. Each job is almost identical, and Py4J to create a new Java object in the JVM server, and performs the necessary calculations. The problem is that it fails very quickly inside a Py4J call. > > There is a lot of code involved in this, but the following is the function that fails. The class "AJDiskAnalysis" contains the call to the JVM server that you can see in the klysOutputPower() function. > def klysOutputPower(Pin, AJDiskAnalObj): > """Returns the output power of the klystron for a given input power.""" > AJDiskAnalObj.klysanal.setInputPower(float(Pin)) > AJDiskAnalObj.simulate(disks=20) > return AJDiskAnalObj.klysanal.getSimulatedOutputPower() > > def powerScan(Pin, filename): > Pout, result, AJobj = [], [], [] > pool = mp.Pool(processes=12) > for power in Pin: > AJobj.append(AJDiskAnalysis(DSKParsObj=DSKParser(fname=filename))) > result.append(pool.apply_async(klysOutputPower, (power, AJobj[-1]))) > for i in result: > Pout.append(i.get()) > return Pout > > if __name__=="__main__": > Pin = arange(0, 150, 10) > Pout = powerScan(Pin, "ess-new-704.dsk") > > This results in the following error: > > Exception in thread Thread-1: > Traceback (most recent call last): > File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner > self.run() > File "/usr/lib64/python2.6/threading.py", line 484, in run > self.__target(*self.__args, **self.__kwargs) > File "/usr/lib64/python2.6/multiprocessing/pool.py", line 225, in _handle_tasks > put(task) > File "/usr/lib/python2.6/site-packages/py4j-0.7-py2.6.egg/py4j/java_gateway.py", line 432, in __call__ > self.target_id, self.name) > File "/usr/lib/python2.6/site-packages/py4j-0.7-py2.6.egg/py4j/protocol.py", line 271, in get_return_value > raise Py4JError('An error occurred while calling %s%s%s. Trace:\n%s\n' % (target_id, '.', name, value)) > Py4JError: An error occurred while calling o19.__getnewargs__. Trace: > py4j.Py4JException: Method __getnewargs__([]) does not exist > at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:346) > at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:355) > at py4j.Gateway.invoke(Gateway.java:247) > at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:124) > at py4j.commands.CallCommand.execute(CallCommand.java:81) > at py4j.GatewayConnection.run(GatewayConnection.java:175) > at java.lang.Thread.run(Thread.java:662) > > Is there some problem that prevents Py4J being used alongside the multiprocessing module, or is there something I am doing wrong? > I would be very happy for any hints or tips, and will happily provide any more information if it is needed. > > Steve > > ------------------------------------------------------------------------------ > Keep Your Developer Skills Current with LearnDevNow! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-d2d_______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |
From: Stephen M. <sdm...@gm...> - 2012-03-06 22:55:17
|
Hi all, I have a working implementation of some Java code I inherited, wrapped up in Python using Py4J. Due to the long time for the calculations to complete, and the embarrassingly parallel nature of my problem, I am trying to use the Python multiprocessing module to speed things up. In particular, I create a pool of processes, and then submit jobs to them. Each job is almost identical, and Py4J to create a new Java object in the JVM server, and performs the necessary calculations. The problem is that it fails very quickly inside a Py4J call. There is a lot of code involved in this, but the following is the function that fails. The class "AJDiskAnalysis" contains the call to the JVM server that you can see in the klysOutputPower() function. def klysOutputPower(Pin, AJDiskAnalObj): """Returns the output power of the klystron for a given input power.""" AJDiskAnalObj.klysanal.setInputPower(float(Pin)) AJDiskAnalObj.simulate(disks=20) return AJDiskAnalObj.klysanal.getSimulatedOutputPower() def powerScan(Pin, filename): Pout, result, AJobj = [], [], [] pool = mp.Pool(processes=12) for power in Pin: AJobj.append(AJDiskAnalysis(DSKParsObj=DSKParser(fname=filename))) result.append(pool.apply_async(klysOutputPower, (power, AJobj[-1]))) for i in result: Pout.append(i.get()) return Pout if __name__=="__main__": Pin = arange(0, 150, 10) Pout = powerScan(Pin, "ess-new-704.dsk") This results in the following error: Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner self.run() File "/usr/lib64/python2.6/threading.py", line 484, in run self.__target(*self.__args, **self.__kwargs) File "/usr/lib64/python2.6/multiprocessing/pool.py", line 225, in _handle_tasks put(task) File "/usr/lib/python2.6/site-packages/py4j-0.7-py2.6.egg/py4j/java_gateway.py", line 432, in __call__ self.target_id, self.name) File "/usr/lib/python2.6/site-packages/py4j-0.7-py2.6.egg/py4j/protocol.py", line 271, in get_return_value raise Py4JError('An error occurred while calling %s%s%s. Trace:\n%s\n' % (target_id, '.', name, value)) Py4JError: An error occurred while calling o19.__getnewargs__. Trace: py4j.Py4JException: Method __getnewargs__([]) does not exist at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:346) at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:355) at py4j.Gateway.invoke(Gateway.java:247) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:124) at py4j.commands.CallCommand.execute(CallCommand.java:81) at py4j.GatewayConnection.run(GatewayConnection.java:175) at java.lang.Thread.run(Thread.java:662) Is there some problem that prevents Py4J being used alongside the multiprocessing module, or is there something I am doing wrong? I would be very happy for any hints or tips, and will happily provide any more information if it is needed. Steve |
From: Barthelemy D. <ba...@cs...> - 2011-12-30 10:00:40
|
Hi Aaron, Sorry for the delay! First, make sure that the java method is indeed blocking. For example, try to get the return value and print it on the python side. Even if the method is void on the Java side, Python will receive a None (there is no "void" in Python). Second, there are two workarounds. Py4J is multi-threaded so you could create multiple threads on the python side and, using the same gateway instance, call multiple blocking Java methods. This is the way to go if you have only a few, short blocking calls. The other workaround is on the Java side: you need to make the method non-blocking, e.g., by launching the app in a thread. Hope this helps, Barthélémy On Wed, December 28, 2011 2:56 pm, Aaron Elder wrote: > I have a method on the java side that launches a java app. If I call this > java method from the python side, the app launches properly, but I am not > able to call any further java methods from the python side. I assume the > gateway is blocking because it thinks the first method called has not > finished execution.What is the recommended way to work around this? > ------------------------------------------------------------------------- > ----- > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! > http://p.sf.net/sfu/Citrix-VDIinabox_____________________________________ > __________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users > > |
From: Aaron E. <aar...@ya...> - 2011-12-28 19:57:04
|
I have a method on the java side that launches a java app. If I call this java method from the python side, the app launches properly, but I am not able to call any further java methods from the python side. I assume the gateway is blocking because it thinks the first method called has not finished execution.What is the recommended way to work around this? |
From: Barthelemy D. <ba...@cs...> - 2011-12-14 12:03:15
|
Hi, JavaObject are not intended to be used directly, unless you want to extend Py4J in some ways. The ids are provided by the Gateway on the java side and are available by calling Gateway.getBindings(). JavaObject instances are created when Java objects are accessed. e.g.,: # in python my_random = gateway.jvm.java.util.Random() my_random is now a JavaObject instance and an id was generated for it. Hope this helps, Barthélémy On 12/13/2011 02:46 PM, Aaron Elder wrote: > I'm new to Java, so I apoligize if my question is dumb. In the py4j > docs, section 4.1.5 JavaObject it mentions one of the parameters it > needs is the target_id for the object from the jvm. Is there an easy way > to get a list of these target_ids from the jvm? > > Thanks, > Aaron > > > ------------------------------------------------------------------------------ > Cloud Computing - Latest Buzzword or a Glimpse of the Future? > This paper surveys cloud computing today: What are the benefits? > Why are businesses embracing it? What are its payoffs and pitfalls? > http://www.accelacomm.com/jaw/sdnl/114/51425149/ > > > > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |
From: Aaron E. <aar...@ya...> - 2011-12-13 19:46:42
|
I'm new to Java, so I apoligize if my question is dumb. In the py4j docs, section 4.1.5 JavaObject it mentions one of the parameters it needs is the target_id for the object from the jvm. Is there an easy way to get a list of these target_ids from the jvm? Thanks, Aaron |
From: Barthelemy D. <ba...@cs...> - 2011-10-24 20:07:27
|
Hi, there is no self-discovery, but unless it does not fit your model, multiple Python clients can connect to the same Java server. The server creates as many threads as required when handling the requests. The client and server are thread-safe, but if you use the entry point, multiple threads might access it concurrently. Barthélémy On 10/24/2011 10:13 AM, bn wrote: > Hi Barthelemy, > > Yes, that did the trick! With the firewall enabled even. > > The actual context is that I'm writing a java plugin to create a python scripting api for the main app. I open up the gateway in java and launch the python script in a subprocess, and the script can then make api calls through the gateway. So both sides are always on the same host. > > The main app is a dlna server itself (http://code.google.com/p/ps3mediaserver/) and when serving multiple dlna clients concurrently will need to run separate py4j instances on different sockets. Is there any gateway discovery magic in the forthcoming py4j that can sort this out automatically, or do I need to pass address:port to python in each instance (which actually wouldn't be hard since it's a subprocess and I can set environment variables). > > Thanks, using py4j has been very smooth sailing apart from this tiny bump in windows. > > -Bahman > > > --- On Mon, 10/24/11, Barthelemy Dagenais<ba...@cs...> wrote: > >> From: Barthelemy Dagenais<ba...@cs...> >> Subject: Re: [Py4j-users] Error when accessing jvm for basic sample (take 2) >> To: "Support and Comments about Py4J"<py4...@li...> >> Date: Monday, October 24, 2011, 6:03 AM >> Hi Bahman, >> >> Just to make sure, are you trying to start both the client >> and the >> server on the same host? >> >> I think this is a bug that I fixed in the forthcoming >> version of Py4J (0.8). >> >> I'm not super familiar with windows networking but I think >> the Java >> server is listening on 192.168.1.39 while the Python client >> is trying to >> connect to 127.0.0.1 (localhost). >> >> In the new version of Py4J, the server always listen to >> localhost by >> default (instead of all interfaces/ips, which was bad >> security), but >> this can be configured. >> >> In the meantime, you could try specifying an ip in the >> Python client: >> >> from py4j.java_gateway import GatewayClient, JavaGateway >> g_client = GatewayClient(address='192.168.1.39') >> gateway = JavaGateway(gateway_client=g_client) >> >> Does that work? >> >> Barthélémy >> > > > ------------------------------------------------------------------------------ > The demand for IT networking professionals continues to grow, and the > demand for specialized networking skills is growing even more rapidly. > Take a complimentary Learning@Cisco Self-Assessment and learn > about Cisco certifications, training, and career opportunities. > http://p.sf.net/sfu/cisco-dev2dev > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |
From: bn <av...@ya...> - 2011-10-24 14:13:27
|
Hi Barthelemy, Yes, that did the trick! With the firewall enabled even. The actual context is that I'm writing a java plugin to create a python scripting api for the main app. I open up the gateway in java and launch the python script in a subprocess, and the script can then make api calls through the gateway. So both sides are always on the same host. The main app is a dlna server itself (http://code.google.com/p/ps3mediaserver/) and when serving multiple dlna clients concurrently will need to run separate py4j instances on different sockets. Is there any gateway discovery magic in the forthcoming py4j that can sort this out automatically, or do I need to pass address:port to python in each instance (which actually wouldn't be hard since it's a subprocess and I can set environment variables). Thanks, using py4j has been very smooth sailing apart from this tiny bump in windows. -Bahman --- On Mon, 10/24/11, Barthelemy Dagenais <ba...@cs...> wrote: > From: Barthelemy Dagenais <ba...@cs...> > Subject: Re: [Py4j-users] Error when accessing jvm for basic sample (take 2) > To: "Support and Comments about Py4J" <py4...@li...> > Date: Monday, October 24, 2011, 6:03 AM > Hi Bahman, > > Just to make sure, are you trying to start both the client > and the > server on the same host? > > I think this is a bug that I fixed in the forthcoming > version of Py4J (0.8). > > I'm not super familiar with windows networking but I think > the Java > server is listening on 192.168.1.39 while the Python client > is trying to > connect to 127.0.0.1 (localhost). > > In the new version of Py4J, the server always listen to > localhost by > default (instead of all interfaces/ips, which was bad > security), but > this can be configured. > > In the meantime, you could try specifying an ip in the > Python client: > > from py4j.java_gateway import GatewayClient, JavaGateway > g_client = GatewayClient(address='192.168.1.39') > gateway = JavaGateway(gateway_client=g_client) > > Does that work? > > Barthélémy > |
From: Barthelemy D. <ba...@cs...> - 2011-10-24 10:30:42
|
Hi Bahman, Just to make sure, are you trying to start both the client and the server on the same host? I think this is a bug that I fixed in the forthcoming version of Py4J (0.8). I'm not super familiar with windows networking but I think the Java server is listening on 192.168.1.39 while the Python client is trying to connect to 127.0.0.1 (localhost). In the new version of Py4J, the server always listen to localhost by default (instead of all interfaces/ips, which was bad security), but this can be configured. In the meantime, you could try specifying an ip in the Python client: from py4j.java_gateway import GatewayClient, JavaGateway g_client = GatewayClient(address='192.168.1.39') gateway = JavaGateway(gateway_client=g_client) Does that work? Barthélémy On 10/23/2011 10:04 PM, bn wrote: > Hi, > > I seem to be having this issue also, having written a small > program which runs fine in linux but gets 'connection refused' in win7 64bit. > > So I tried the AdditionApplication example with the win7 > firewall turned off (see console A output below), then attempted to connect from python where I also get a socket.error 10061 (console B output below). As you can see netstat shows that 192.168.1.39:25333 status is 'LISTENING' after I exit python. > > Trying a different port gives the same error. Initially I thought it may somehow have to do with mixing 32bit java and 64bit python, but switching python to 32bit didn't help. I don't know much about sockets and would appreciate any insight here. > > thanks, > -Bahman > > --------------------------- > console A: > --------------------------- > >> java -version > java version "1.6.0_12" > Java(TM) SE Runtime Environment (build 1.6.0_12-b04) > Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing) > >> netsh advfirewall set allprofiles state off > Ok. > >> java -cp lib\py4j0.7.jar;AdditionApplication-0.1.jar AdditionApplication > > --------------------------- > console B: > --------------------------- > >> python > Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from py4j.java_gateway import JavaGateway >>>> gateway = JavaGateway() >>>> a = gateway.entry_point >>>> a.addition(1,2) > Traceback (most recent call last): > File "<stdin>", line 1, in<module> > File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 430, in __call__ > answer = self.gateway_client.send_command(command) > File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 257, in send_command > connection = self._get_connection() > File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 213, in _get_connection > connection = self._create_connection() > File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 220, in _create_connection > connection.start() > File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 318, in start > self.socket.connect((self.address, self.port)) > File "F:\Programs\Python27\lib\socket.py", line 224, in meth > return getattr(self._sock,name)(*args) > socket.error: [Errno 10061] No connection could be made because the target machine actively refused it >>>> ^Z > >> netstat -an > > Active Connections > > Proto Local Address Foreign Address State > TCP 0.0.0.0:135 0.0.0.0:0 LISTENING > TCP 0.0.0.0:445 0.0.0.0:0 LISTENING > TCP 0.0.0.0:554 0.0.0.0:0 LISTENING > TCP 0.0.0.0:2869 0.0.0.0:0 LISTENING > TCP 0.0.0.0:10243 0.0.0.0:0 LISTENING > TCP 0.0.0.0:49152 0.0.0.0:0 LISTENING > TCP 0.0.0.0:49153 0.0.0.0:0 LISTENING > TCP 0.0.0.0:49154 0.0.0.0:0 LISTENING > TCP 0.0.0.0:49155 0.0.0.0:0 LISTENING > TCP 0.0.0.0:49156 0.0.0.0:0 LISTENING > TCP 0.0.0.0:49157 0.0.0.0:0 LISTENING > TCP 0.0.0.0:49164 0.0.0.0:0 LISTENING > TCP 0.0.0.0:54465 0.0.0.0:0 LISTENING > TCP 127.0.0.1:1299 0.0.0.0:0 LISTENING > TCP 127.0.0.1:49160 0.0.0.0:0 LISTENING > TCP 127.0.0.1:49293 127.0.0.1:49294 ESTABLISHED > TCP 127.0.0.1:49294 127.0.0.1:49293 ESTABLISHED > TCP 127.0.0.1:49297 127.0.0.1:49298 ESTABLISHED > TCP 127.0.0.1:49298 127.0.0.1:49297 ESTABLISHED > TCP 127.0.0.1:49570 127.0.0.1:49160 TIME_WAIT > TCP 192.168.1.39:139 0.0.0.0:0 LISTENING > TCP 192.168.1.39:25333 0.0.0.0:0 LISTENING > TCP 192.168.1.39:49360 168.143.242.112:80 CLOSE_WAIT > TCP 192.168.1.39:49563 72.14.204.147:80 ESTABLISHED > TCP [::]:135 [::]:0 LISTENING > TCP [::]:445 [::]:0 LISTENING > TCP [::]:554 [::]:0 LISTENING > TCP [::]:2869 [::]:0 LISTENING > TCP [::]:10243 [::]:0 LISTENING > TCP [::]:49152 [::]:0 LISTENING > TCP [::]:49153 [::]:0 LISTENING > TCP [::]:49154 [::]:0 LISTENING > TCP [::]:49155 [::]:0 LISTENING > TCP [::]:49156 [::]:0 LISTENING > TCP [::]:49157 [::]:0 LISTENING > TCP [::]:49164 [::]:0 LISTENING > TCP [::]:54465 [::]:0 LISTENING > > --------------------------- > AdditionApplication.java: > --------------------------- > import py4j.GatewayServer; > > public class AdditionApplication { > > public int addition(int first, int second) { > return first + second; > } > > public static void main(String[] args) { > AdditionApplication app = new AdditionApplication(); > // app is now the gateway.entry_point > GatewayServer server = new GatewayServer(app); > server.start(); > } > } > --------------------------- > > > ------------------------------------------------------------------------------ > The demand for IT networking professionals continues to grow, and the > demand for specialized networking skills is growing even more rapidly. > Take a complimentary Learning@Cisco Self-Assessment and learn > about Cisco certifications, training, and career opportunities. > http://p.sf.net/sfu/cisco-dev2dev > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |
From: bn <av...@ya...> - 2011-10-24 02:04:48
|
Hi, I seem to be having this issue also, having written a small program which runs fine in linux but gets 'connection refused' in win7 64bit. So I tried the AdditionApplication example with the win7 firewall turned off (see console A output below), then attempted to connect from python where I also get a socket.error 10061 (console B output below). As you can see netstat shows that 192.168.1.39:25333 status is 'LISTENING' after I exit python. Trying a different port gives the same error. Initially I thought it may somehow have to do with mixing 32bit java and 64bit python, but switching python to 32bit didn't help. I don't know much about sockets and would appreciate any insight here. thanks, -Bahman --------------------------- console A: --------------------------- >java -version java version "1.6.0_12" Java(TM) SE Runtime Environment (build 1.6.0_12-b04) Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing) >netsh advfirewall set allprofiles state off Ok. >java -cp lib\py4j0.7.jar;AdditionApplication-0.1.jar AdditionApplication --------------------------- console B: --------------------------- >python Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from py4j.java_gateway import JavaGateway >>> gateway = JavaGateway() >>> a = gateway.entry_point >>> a.addition(1,2) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 430, in __call__ answer = self.gateway_client.send_command(command) File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 257, in send_command connection = self._get_connection() File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 213, in _get_connection connection = self._create_connection() File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 220, in _create_connection connection.start() File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 318, in start self.socket.connect((self.address, self.port)) File "F:\Programs\Python27\lib\socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 10061] No connection could be made because the target machine actively refused it >>> ^Z >netstat -an Active Connections Proto Local Address Foreign Address State TCP 0.0.0.0:135 0.0.0.0:0 LISTENING TCP 0.0.0.0:445 0.0.0.0:0 LISTENING TCP 0.0.0.0:554 0.0.0.0:0 LISTENING TCP 0.0.0.0:2869 0.0.0.0:0 LISTENING TCP 0.0.0.0:10243 0.0.0.0:0 LISTENING TCP 0.0.0.0:49152 0.0.0.0:0 LISTENING TCP 0.0.0.0:49153 0.0.0.0:0 LISTENING TCP 0.0.0.0:49154 0.0.0.0:0 LISTENING TCP 0.0.0.0:49155 0.0.0.0:0 LISTENING TCP 0.0.0.0:49156 0.0.0.0:0 LISTENING TCP 0.0.0.0:49157 0.0.0.0:0 LISTENING TCP 0.0.0.0:49164 0.0.0.0:0 LISTENING TCP 0.0.0.0:54465 0.0.0.0:0 LISTENING TCP 127.0.0.1:1299 0.0.0.0:0 LISTENING TCP 127.0.0.1:49160 0.0.0.0:0 LISTENING TCP 127.0.0.1:49293 127.0.0.1:49294 ESTABLISHED TCP 127.0.0.1:49294 127.0.0.1:49293 ESTABLISHED TCP 127.0.0.1:49297 127.0.0.1:49298 ESTABLISHED TCP 127.0.0.1:49298 127.0.0.1:49297 ESTABLISHED TCP 127.0.0.1:49570 127.0.0.1:49160 TIME_WAIT TCP 192.168.1.39:139 0.0.0.0:0 LISTENING TCP 192.168.1.39:25333 0.0.0.0:0 LISTENING TCP 192.168.1.39:49360 168.143.242.112:80 CLOSE_WAIT TCP 192.168.1.39:49563 72.14.204.147:80 ESTABLISHED TCP [::]:135 [::]:0 LISTENING TCP [::]:445 [::]:0 LISTENING TCP [::]:554 [::]:0 LISTENING TCP [::]:2869 [::]:0 LISTENING TCP [::]:10243 [::]:0 LISTENING TCP [::]:49152 [::]:0 LISTENING TCP [::]:49153 [::]:0 LISTENING TCP [::]:49154 [::]:0 LISTENING TCP [::]:49155 [::]:0 LISTENING TCP [::]:49156 [::]:0 LISTENING TCP [::]:49157 [::]:0 LISTENING TCP [::]:49164 [::]:0 LISTENING TCP [::]:54465 [::]:0 LISTENING --------------------------- AdditionApplication.java: --------------------------- import py4j.GatewayServer; public class AdditionApplication { public int addition(int first, int second) { return first + second; } public static void main(String[] args) { AdditionApplication app = new AdditionApplication(); // app is now the gateway.entry_point GatewayServer server = new GatewayServer(app); server.start(); } } --------------------------- |
From: Barthelemy D. <ba...@us...> - 2011-06-02 21:32:18
|
Py4J 0.7 has just been released! This release includes the following new features: - Major refactoring to support Python 3. Thanks to Alex Grönholm for his patch. - The build and setup files have been totally changed. Py4J no longer requires Paver to build and everything is done through ant. The setup.py file only uses distutils. - Added support for Java byte[]: byte array are passed by value and converted to bytearray or bytes. - Py4J package name changed from Py4J to py4j. - Bug fixes in the Python callback server and unicode support. The specific issues are discussed on GitHub: https://github.com/bartdag/py4j/issues?labels=v0.7&sort=created&direction=desc&state=closed&page=1 Although I'm still using Py4J everyday, I do not need many more features so future development will be mostly driven by feature requests and bug reports. Feel free to contact me or to write a feature request on GitHub! Cheers, Barthélémy |
From: Barthelemy D. <ba...@cs...> - 2011-04-19 15:27:25
|
Ahhh... sorry, I'm not often working on Windows and I just found out that the doc is incorrect: The jar file should be in: Python27\Lib\site-packages\Py4J-0.6-py2.7.egg\share\py4j I'll have to check whether it is caused by Windows or easy_install (I usually use pip). Barthélémy On Tue, April 19, 2011 11:13 am, Sean Silvestri wrote: > Interesting I did the easy install option but cant seem to find the > py4j.jar file on my system. could it be in another location other than > python27\share as that directory doesnt exist. cheers, Sean > > > On Tue, Apr 19, 2011 at 2:55 AM, Barthelemy Dagenais <ba...@cs...> > wrote: > >> Hi Sean, >> >> >> The way Py4J works is that python code is executed in a Python >> interpreter and Java code is invoked by a Java Virtual Machine. Both the >> Python >> interpreter and the JVM must be started prior to using Py4J. In other >> words, Py4J won't start a JVM to execute code in a jar file. >> >> >> To run the example, first, locate the py4j.jar and your jar and execute >> this command (using the right path): >> >> java -cp path\to\py4j.jar;path\to\yourlib.jar \ >> py4j.examples.AdditionApplication >> >> Then, open a python interpreter and try the example code, it should >> work. >> >> You should also be able to access the code in your jar file. >> >> >> Hope this helps, >> Barthélémy >> >> >> On 04/18/2011 08:43 PM, Sean Silvestri wrote: >> >>> >>> Hi Barthelemy, >>> Interesting, I did not start any Java program. I must have >>> misunderstood the premise of the module. My main goal is to simply call >>> into a java jar file that I've registered e.g. the classpath. >>> >>> Since that was not working I just resorted to the basic sample on the >>> web site using the .java.util.Random class (see below) I'm simply >>> wanting to interface with a jar file in order to call the java >>> methods. gateway = JavaGateway() # connect to the >>> JVM >>> >>>>>> >>>>>> random = gateway.jvm.java.util.Random() # create a >>>>>> java.util.Random instance number1 = random.nextInt(10) >>>>>> # call the Random.nextInt >>>>>> method number2 = random.nextInt(10) print(number1,number2) >>> >>> (2, 7) >>> >>> >>> I had also turned off my firewall but still had gotten the error i >>> had mentiond ( [Errno 10061] No connection could be made because the >>> target machine actively refused it). >>> >>> What would be the steps to be able to call java code situated in a >>> .jar file from a python script using py4j? >>> many thanks, Sean >>> >>> >>> >>> >>> On Mon, Apr 18, 2011 at 5:21 PM, Barthelemy >>> Dagenais<ba...@cs...> >>> wrote: >>> >>>> >>>> Hi Sean, >>>> >>>> >>>> this error means that the python interpreter cannot connect to the >>>> jvm either because: >>>> >>>> 1- The jvm is not yet started so nothing is listening on the >>>> default py4j port. >>>> >>>> 2- You have a firewall blocking the port. >>>> >>>> >>>> You need to start the java program in the example and then, you can >>>> start your python interpreter (not the other way around). >>>> >>>> If you don't have a firewall and if you started the Java program >>>> before running the interpreter, we will need more information to >>>> help you (e.g., how did you start the Java program, what is the >>>> output of the "netstat" command in a command prompt after starting >>>> the Java program, etc.). >>>> >>>> Barthélémy >>>> >>>> >>>> On Mon, April 18, 2011 8:07 pm, Sean Silvestri wrote: >>>> >>>>> >>>>> HI All, >>>>> I'm just getting started with Py4J, basically just trying to call >>>>> a jar. I'm having trouble with the basic sample however: >>>>> >>>>> >>>>>>>> from py4j.java_gateway import JavaGateway gateway = >>>>>>>> JavaGateway() >>>>>>>> # connect to the JVM >>>>>>>> random = gateway.jvm.java.util.Random() # create a >>>>>>>> java.util.Random instance number1 = random.nextInt(10) # >>>>>>>> call the Random.nextInt method number2 = random.nextInt(10) >>>>>>>> print(number1,number2) >>>>> >>>>> (2, 7) >>>>> >>>>> >>>>>>>> addition_app = gateway.entry_point # get the >>>>>>>> AdditionApplication instance >>>>>>>> addition_app.addition(number1,number2) # call the >>>>>>>> addition method >>>>>>>> >>>>> 9 >>>>> >>>>> >>>>> >>>>> I keep getting the following error: [Errno 10061] No connection >>>>> could be made because the target machine actively refused it >>>>> >>>>> I'm on python 2.71 for windows i have jre6 se installed have set >>>>> path. cheers, Sean >>>>> >>>>> >>>>> >>>>> ----------------------------------------------------------------- >>>>> -------- >>>>> ----- >>>>> Benefiting from Server Virtualization: Beyond Initial Workload >>>>> Consolidation -- Increasing the use of server virtualization is a >>>>> top priority.Virtualization can reduce costs, simplify management, >>>>> and improve application availability and disaster protection. >>>>> Learn more about >>>>> boosting the value of server virtualization. >>>>> http://p.sf.net/sfu/vmware-sfdev2dev >>>>> _______________________________________________ >>>>> Py4j-users mailing list >>>>> Py4...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/py4j-users >>>>> >>>>> >>>>> >>>> >>>> >>>> >> >> > |