0

I am facing this problem since yesterday, Burp started showing the error below when trying to import the .jar file of the plugin, but Netbeans has no issues compiling it. I imported Selenium through the Maven dependency in the pom.xml file and each time I load the plugin into Burp i run the Clean and build option to avoid any issue

However, the code I run is like this:

void runBrowserAutomatization(File fileDriver, String seleniumTrack, boolean isHeadless) {

        WebDriver driver;

        if (gui.usedBrowser().toLowerCase().contains("chrome")) {
            ChromeOptions options = new ChromeOptions();
            Proxy proxy = new Proxy();
            proxy.setHttpProxy("localhost:8080");
            proxy.setSslProxy("localhost:8080");

            options.setCapability(CapabilityType.PROXY, proxy);
            options.setHeadless(isHeadless);
            System.setProperty("webdriver.chrome.driver", fileDriver.getPath());

            driver = new ChromeDriver(options);

        } else if (gui.usedBrowser().toLowerCase().contains("firefox")) {
            FirefoxOptions options = new FirefoxOptions();
            Proxy proxy = new Proxy();
            proxy.setHttpProxy("localhost:8080");
            proxy.setSslProxy("localhost:8080");

            options.setCapability(CapabilityType.PROXY, proxy);
            options.setHeadless(isHeadless);
            System.setProperty("webdriver.gecko.driver", fileDriver.getPath());

            driver = new FirefoxDriver(options);
        } else {
            printMsg("No browser selected...");
            return;
        }

       /// other stuff here

        driver.close();

    }

The error that is shown is the following

java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:436)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:416)
    at burp.ehm.a(Unknown Source)
    at burp.ehm.<init>(Unknown Source)
    at burp.b6.a(Unknown Source)
    at burp.c3u.lambda$panelLoaded$0(Unknown Source)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:830)

The awkward thing is that if I comment the two implementations of the driver object, Burp shows no error importing it. It seems like it has problem in implementing the WebDriver object, but not in declaring it, which is very strange for a ClassNotFoundException. Another tool, whose code has the same structure with these components, has no errors if it is loaded and runs fine.

Stefano
  • 327
  • 1
  • 4
  • 17
  • Does Netbeans have dependencies mapped as jar files instead of pulling dependencies from the pom file? – fpezzini May 02 '20 at 05:40
  • @fpezzini hi, I can confirm there aren't. Now I try to create a new project and to copy my files to check if it works, but I really have no clue about what's happening there :S if you have other suggestions let me know, thanks – Stefano May 02 '20 at 09:40
  • Yeah, that class is missing from the class path when you execute your program from the terminal. It likely depends on a dependency JAR file, which you can either add to your own generated FAT jar file, or you have to specify it on the command line using the -cp argument to the java command or by adding the CLASSPATH environment variable that points to that JAR. See [here](https://stackoverflow.com/questions/22265463/what-exactly-is-a-class-path-in-java) for more info. – fpezzini May 02 '20 at 12:27
  • Wouldn't this show an error when netbeans tries to build the jar? Because I can build the project, the error is shown when the plugin is imported into Burp. I will try to set the classpath tho, I'll let you know. Thanks. – Stefano May 02 '20 at 12:34
  • Depends if Netbeans has that dependency JAR setup somewhere. At least in my experience in the past, when it failed outside the IDE is because the IDE had it mapped somewhere in the project config. Even if not the JAR itself, you could have added a certain library that contained it. – fpezzini May 02 '20 at 12:37
  • Clearly I don't have the .jar file since it is a maven dependency... but I read that adding the tag compile inside should allow the library to be available at runtime. I did that but it didn't resolve my problem. – Stefano May 02 '20 at 15:53
  • Did you check if perhaps the jar download by maven failed? Are you able to see the corresponding jar file in your ~/.m2 folder? Sometimes the Maven build can fail to download new dependencies if you are using Java below 1.8, or because the download did not complete well (the file becomes malformed). – fpezzini May 02 '20 at 17:49
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/212978/discussion-between-stefano-and-fpezzini). – Stefano May 02 '20 at 18:31

1 Answers1

0

Adding this plugin to the pom.xml file fixed the error for me, it includes Maven dependencies in the jar when building the project.

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.2.3</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>

The latest version of the plugin can be found here https://maven.apache.org/plugins/maven-shade-plugin/usage.html

Stefano
  • 327
  • 1
  • 4
  • 17