diff --git a/src/macaron/repo_finder/repo_finder_java.py b/src/macaron/repo_finder/repo_finder_java.py
index 8d106d1ea..e6f349d3b 100644
--- a/src/macaron/repo_finder/repo_finder_java.py
+++ b/src/macaron/repo_finder/repo_finder_java.py
@@ -52,13 +52,13 @@ def find_repo(self, purl: PackageURL) -> str:
 
         if not version:
             logger.info("Version missing for maven artifact: %s:%s", group, artifact)
-            purl = DepsDevRepoFinder().get_latest_version(purl)
-            if not purl.version:
+            latest_purl = DepsDevRepoFinder().get_latest_version(purl)
+            if not latest_purl or not latest_purl.version:
                 logger.debug("Could not find version for artifact: %s:%s", purl.namespace, purl.name)
                 return ""
-            group = purl.namespace or ""
-            artifact = purl.name
-            version = purl.version
+            group = latest_purl.namespace or ""
+            artifact = latest_purl.name
+            version = latest_purl.version
 
         while group and artifact and version and limit > 0:
             # Create the URLs for retrieving the artifact's POM
diff --git a/tests/integration/cases/repo_finder_remote_calls/repo_finder.py b/tests/integration/cases/repo_finder_remote_calls/repo_finder.py
index 16de2c7d5..f529cb771 100644
--- a/tests/integration/cases/repo_finder_remote_calls/repo_finder.py
+++ b/tests/integration/cases/repo_finder_remote_calls/repo_finder.py
@@ -71,12 +71,13 @@ def test_repo_finder() -> int:
     if not parsed_url or not repo_validator.resolve_redirects(parsed_url):
         return os.EX_UNAVAILABLE
 
-    # Test Java package whose SCM metadata only points to the repo in the later versions than is provided here.
+    # Test Java package whose SCM metadata only points to the repo in later versions than is provided here.
     purl = PackageURL.from_string("pkg:maven/io.vertx/vertx-auth-common@3.8.0")
     repo = find_repo(purl)
     if repo == "https://github.com/eclipse-vertx/vertx-auth":
         return os.EX_UNAVAILABLE
     latest_purl = DepsDevRepoFinder().get_latest_version(purl)
+    assert latest_purl
     repo = find_repo(latest_purl)
     if repo != "https://github.com/eclipse-vertx/vertx-auth":
         return os.EX_UNAVAILABLE