Tuesday, May 16, 2017

Maven: Digging Deeper with -X

While I like many people sometimes I have to run over to StackOverflow to figure out an issue. I have made a habit of working through the issue myself first. So when I encounter an error like this one below.


A lot of times people will just take goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce failed. NullPointerException and place it into the search engine trying to figure out what the issue is, by going through a few of the links seeing if they have solutions. Maybe try them, get down a further whole, etc. Let's do it different this time.

Take the solution into our own hands. The first thing you need to do is just read the rest of the output. If you notice there's an option -X which provides full debug output, so our command should look something like mvn clean install -X where the -X it simply appended to your original command. Now as a forewarning this will output a TON, so be prepared for that. If your cli window starts clipping history too soon you may want to opt for redirecting the output to a file. For example: mvn clean install -X > output.log This should give you the ability to browse through the output and search for potential issues.

Now with the command completed again we can look for the issue. I generally like to start from the bottom. So if you are using vi you can use the :$ command to go the the last line, and begin paging up from there. In most cases since the solution can be found by seeing just the error. In more complex situation you may want to see what warnings occur further up in the output that may clue into what may actually be causing the error. So what is our issue in this case?


It appears that something is wrong with one of our libraries, and it appears to be corrupt. This was likely caused by an incomplete retrieval of the dependency. To solve this simply remove the parent folder with rm -rf /Users/harolddost/.m2/repository/com/sun/jersey/jersey-core/1.5 and then run maven again.


Success!

I hope that this guide has been helpful, and maybe a little bit inspiring to not just look for solutions others have come up with, but to come up with your own.

Happy Troubleshooting!

No comments:

Post a Comment