0

Step1 - I have created a jar out of sample java code- MyPythonGateway.jar

Java Class-

import py4j.GatewayServer;
public class MyPythonGateway{

    public int findMyNum(String input){
        return(1);
    }

    public static void main(String[] args){
        GatewayServer server = new Gatewayserver(new MyPythonGateway())
        server.start();
    }
}

Step2- I am invoking pyspark by mentioning this jar- MyPythonGateway.jar in executor.extraClassPath and driver.extraClassPath

pyspark is launched well.

Step3- trying to invoke java code from pyspark now

Error: Py4jNetworkError: An Error occurred while trying to connect to the Java server (127.0.0.1:25335)

I used other ports also like- 25340 , 25338 but getting same error every time

M Reza
  • 18,350
  • 14
  • 66
  • 71
  • also tried using next available port- 'from py4j.java_gateway import ( JavaGateway, CallbackServerParameters, GatewayParameters, launch_gateway) port = launch_gateway() ' . *getting error-Py4jError:could not find py4j jar at* – Amit_Bhardwaj Jan 21 '19 at 04:23
  • also tried using next available port- `from py4j.java_gateway import ( JavaGateway, CallbackServerParameters, GatewayParameters, launch_gateway) port = launch_gateway()` . **getting error-Py4jError:could not find py4j jar at** – Amit_Bhardwaj Jan 21 '19 at 04:30
  • @Barthelemy - can you please help on this – Amit_Bhardwaj Jan 21 '19 at 04:34

0 Answers0