Selenium Java NoClassDefFoundError occurs

79 views
Skip to first unread message

Kim Mark

unread,
May 1, 2017, 5:02:01 PM5/1/17
to Selenium Users
## Meta -
OS:  Win7
<!-- Windows 10? OSX? -->
Selenium Version:  
 - selenium-server: 3.4.0
 - selenium-java: 3.4.0
 - selenium-remote-driver: 3.4.0
 - selenium-api: 3.4.0
 - selenium-server-standalone: 2.53.0 (not managed by maven)

## Expected Behavior -
when i try to execute my java code using this source 
```
WebDriver driver = new RemoteWebDriver(remoteURL, DesiredCapabilities.chrome());
driver.get("http://www.google.com");
```
without referencing selenium-server-standalone-2.53.0.jar into my project, it will compile and run without errors.

## Actual Behavior -
when i try to execute my java code using this source 
```
WebDriver driver = new RemoteWebDriver(remoteURL, DesiredCapabilities.chrome());
driver.get("http://www.google.com");
```

below error will occur on console log
```
java.lang.NoClassDefFoundError: com/google/common/base/Function
    at com.at.regression.service.BrowserService.start(BrowserService.java:33) ~[classes/:na]
    at com.at.regression.RegressionToolApplication.run(RegressionToolApplication.java:26) [classes/:na]
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:760) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
    at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:747) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
    at com.at.regression.RegressionToolApplication.main(RegressionToolApplication.java:20) [classes/:na]
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
    at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_111]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_111]
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[na:1.8.0_111]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_111]
    ... 7 common frames omitted
```
without referencing selenium-server-standalone-2.53.0.jar, the above result will occur. But when i reference that jar file into my project above error will NOT occur. 

Now, i came to here to clarify since i posted this on SO, i was told this was a problem on 3.4.0. so maybe you guys here in selenium can confirm.

## Steps to reproduce -
 - On your IDE, create a java project
 - modify pom.xml file, add the above dependencies (see Selenium Version) EXCEPT for selenium-server-standalone-2.53.0.jar
 - on main(), add the following source, modifiy remoteURL accordingly


WebDriver driver = new RemoteWebDriver(remoteURL, DesiredCapabilities.chrome());
driver.get("http://www.google.com");



Thomas Sallaberger

unread,
May 9, 2017, 12:37:52 PM5/9/17
to Selenium Users
I've just started using Selenium and had a problem which wasn't the same as yours, however it was somehow similar.

I solved it by adding
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>21.0</version>
</dependency>


to my maven dependencies

Reply all
Reply to author
Forward
0 new messages