Marathon JAVA Driver - Error when running inside an exported JAR file from Eclipse

239 views Asked by At

I have got Marathon JAVA Driver to work in Eclipse and it works fine when I run the code from eclipse. However, When I export the project as runnable JAR file, and then execute the JAR file, I get the below error and the application is not launched.

at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61) Caused by: java.lang.NullPointerException at net.sourceforge.marathon.javadriver.JavaProfile.(JavaProfile.java:205)

import java.io.IOException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import net.sourceforge.marathon.javadriver.JavaDriver;
import net.sourceforge.marathon.javadriver.JavaProfile;
import net.sourceforge.marathon.javadriver.JavaProfile.LaunchMode;
import net.sourceforge.marathon.javadriver.JavaProfile.LaunchType;

public class SwingAutomationSample {
    public static JavaDriver driver;
    public static JavaProfile profile;

@BeforeClass 
public void setUp() throws IOException {

        try {           
        profile = new JavaProfile(LaunchMode.EXECUTABLE_JAR);                   
        profile.setLaunchType(LaunchType.FX_APPLICATION);                
        profile.setExecutableJar("C:/Users/KarthikRaja/Desktop/Projects/xxyy.jar");
        profile.setWorkingDirectory("C:/Users/KarthikRaja/Desktop/Projects");      
        driver = new JavaDriver(profile);      
        }catch(Exception e) {
            System.out.println("java driver error ------------ " + e.toString());
        }
}

@Test
public void Form15CBFill() throws Exception {
    System.out.println("Inside Test Class");
    }
}```
2

There are 2 answers

0
karthik110885 On BEST ANSWER

@Aditya, again, thanks for pointing me in the right direction. The below steps solved the issue for me.

  1. Download selenium-standalone-jar and add it to the project build path
  2. As suggested by Aditya, export the project as runnable JAR file with option "copy required libraries into a sub-folder next to the generated JAR"
  3. In the exported JAR, make sure the manifest file includes the selenium-standalone-jar and other dependencies in the classpath

This resolved the issue for me.

8
Aditya Karra On

Marathon Java driver uses its jar files so that it can set JAVA_TOOL_OPTIONS. So it needs the jar file to be assessable in the file system.

Please check the JavaProfile.java line number 204 for reference.

For a quick fix export marathon jars and add them to class path and write a batch script to execute the test case.