Noclassdeffounderror - Only running via Jenkins

Asked

Viewed 30 times

1

Hello,

I have an automation project with Selenium + java + Maven integrated into Jenkins. Today I did a refactor on it moving some classes to new packages.

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

As I am new in 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 compilation and runtime, etc. I do not understand why, on my machine did not give error at runtime also.

I would like to know how to fix this. When I edit the classpath do I not point out the class path on my machine? Since Jenkins downloads the git project and runs on another machine, how would that work?

If someone can explain me the best solution to fix this error, because I don’t know how to work the classpath. How this happened when I made a refactor of Packages there is no way to reset these invalid references?

Thank you!

1 answer

0

Answering my own question...

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

In the end I made a Try catch on a part of the code that I suspected might be causing some error, and in fact misses this, the catch caught an exception of Selenium totally different from the Noclassdeffounderror, took the exception org.openqa.Selenium.remote.Unreachablebrowserexception, then got a problem I found in the capabilities of Chrome driver and everything is ok now.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.