By Shivam Singh, founder of TesterRank · Updated September 2026
Maven issues will waste hours of your life if you don't know the patterns. The good news: 90% of Maven problems fall into a few categories. Learn these patterns and you'll fix most issues in minutes.
This error means Maven could not download a library. Usually the version number is wrong or there is no internet connection. The comments show the error and the fix.
# Error:
# Could not find artifact org.seleniumhq.selenium:selenium-java:jar:4.18.1
# in central (https://repo.maven.apache.org/maven2)
# Causes:
# 1. Typo in groupId, artifactId, or version
# 2. No internet connection
# 3. Corporate firewall blocking Maven Central
# 4. Version doesn't exist on Maven Central
# Fix:
# Step 1: Verify the exact dependency on mvnrepository.com
# Step 2: Check your internet: ping repo.maven.apache.org
# Step 3: Force re-download:
mvn clean test -UCompilation errors mean your Java code has a mistake, or uses a library that is missing. Read the first error line; it names the file and line number.
# Error:
# [ERROR] COMPILATION ERROR
# [ERROR] /src/test/java/com/testerrank/tests/LoginTest.java:[5,35]
# package org.testng.annotations does not exist
# Cause: Maven can't find the TestNG dependency
# Fixes:
# 1. Check if <dependency> for TestNG is in pom.xml
# 2. Check scope — if you use TestNG in src/main/java but scope is "test", it won't compile
# 3. Reload Maven in IntelliJ: Right-click pom.xml > Maven > Reload Project
# 4. Delete local cache and re-download:
rm -rf ~/.m2/repository/org/testng
mvn clean test"Tests run: 0" means Maven found no tests. The usual causes are a wrong testng.xml path or test classes in the wrong folder.
# Output:
# [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
# Causes:
# 1. testng.xml not found — check the path in suiteXmlFile
# 2. Test classes in wrong directory (not in src/test/java)
# 3. Surefire plugin not configured in pom.xml
# 4. Test class names don't match Surefire naming convention
# Surefire looks for these patterns by default:
# **/Test*.java — starts with Test
# **/*Test.java — ends with Test
# **/*Tests.java — ends with Tests
# **/*TestCase.java — ends with TestCase
# Fix: Rename your class to end with "Test"
# Bad: LoginScenarios.java
# Good: LoginTest.javaThe most common "0 tests run" mistake: your testng.xml references src/test/resources/testng.xml but Surefire is looking for testng.xml in the project root. Set the correct path: <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>. Or put testng.xml in the project root directory.
This happens when two libraries need different versions of the same third library. The commands below show which versions are fighting and how to choose one.
# Error:
# java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.of()
# java.lang.NoClassDefFoundError: org/openqa/selenium/remote/http/HttpClient
# Cause: Two libraries need different versions of the same dependency
# Selenium needs Guava 33, but another library needs Guava 31
# Debug: Find conflicting versions
mvn dependency:tree | grep guava
# Fix: Add explicit version in your pom.xml
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.0.0-jre</version>
</dependency>
# Or exclude the conflicting transitive dependency
<dependency>
<groupId>some.library</groupId>
<artifactId>that-pulls-old-guava</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>Large suites can run out of memory. Give the test process more memory with this setting.
<!-- Add memory settings to Surefire plugin -->
<configuration>
<argLine>-Xmx1024m -Xms512m</argLine>
</configuration>If downloads are broken or half-finished, delete Maven's local cache and let it download everything again. It is slow, but it fixes strange errors.
# When nothing else works — delete the local cache and start fresh
# WARNING: This will re-download ALL dependencies (takes time)
# Delete entire local repository
rm -rf ~/.m2/repository
# Or delete just the problematic library
rm -rf ~/.m2/repository/org/seleniumhq
# Then rebuild
mvn clean test -UBefore deleting ~/.m2/repository, try mvn clean test -U first. The -U flag forces Maven to check for updated snapshots and releases. It often fixes issues without the nuclear option of deleting the entire local cache.
Q: How do you resolve dependency conflicts in Maven?
A: First, I run mvn dependency:tree to see all dependencies and their versions, including transitive ones. If I find conflicting versions, I have three options: (1) Add the correct version as a direct dependency in pom.xml — Maven gives priority to direct dependencies over transitive ones. (2) Use <exclusions> to exclude the conflicting transitive dependency. (3) Use <dependencyManagement> to enforce a specific version across the entire project. The key diagnostic tool is mvn dependency:tree — it shows exactly which library is pulling in which version.
Key Point: Most Maven issues are: wrong paths, missing dependencies, version conflicts, or stale cache. mvn dependency:tree and mvn clean test -U fix 90% of problems.