NoClassDefFoundError - Only running via Jenkins

1

Hello,

I have an automation project with selenium + java + maven integrated in Jenkins. Today I did a refactor on it by moving some classes to new packages.

In my machine there is no problem of compilation or execution, it runs everything normal. But in jenkins, which is on another machine, when I go to execute this project (always calling mvn clean install) it is giving NoClassDefFoundError to one of the classes that I changed package.

As I am new to java I went to take a look to understand all this, I saw some people saying to add the class in the classpath, I saw the explanations about compiling and runtime, etc. I do not understand why, on my machine I did not get run-time error either.

I'd like to know how to fix this. When I edit the classpath I do not point the path of the class on my machine? Since jenkins downloads the git project and runs on another machine, how would it work?

If someone can explain me the best solution to correct this error, because I do not know how to move the classpath. How did this happen when I did a package refactorer, there are no way to zero these invalid references?

Thank you!

    
asked by anonymous 20.10.2016 / 00:23

1 answer

0

Answering my own question ...

After much searching on the internet, in the code, and everything else, I saw that a comment in a community where a user said that this exception is sometimes not thrown only when the class is not found at runtime, it it said that sometimes this happens because of another code error, which has nothing to do with changing classpath and the like.

In the end I did a try catch in a part of the code that I suspected could be causing some error, and in fact misses this, catch caught a selenium exception totally different from NoClassDefFoundError , got the org.openqa.selenium.remote.UnreachableBrowserException exception, then I fixed a problem I found in the capabilities of the chrome driver and everything is ok now.

    
20.10.2016 / 15:22