Hi all! I'm working on an ancient homework assignm...
# community-support
j
Hi all! I'm working on an ancient homework assignment for a test automation course (thanks Coursera) and for some reason, my Eclipse IDE is completely unable to access any respository. Specifically I'm trying to get junit 4.13.2 from MavenCentral. Funny thing is, if I click on the url in the error saying that the file is not found in my browser, the pom file loads up as it's supposed to! So I'm scratching my head as obviously the url is not blocked on my browser. I do have a software firewall installed. I tried disabling it completely and still, Eclipse refuses to find the proper file in the Maven central repository. I'm at my wits end on this lol. Has this ever been a thing for anyone? And is there a way to fix it? Here's my build.gradle:
Copy code
/*
 * Gradle build file.
 */

apply plugin: 'java'

// Make sure we are using Java 8.
if(JavaVersion.current() != JavaVersion.VERSION_1_8)
    throw new GradleException("This project requires Java 8, but it's running on "+JavaVersion.current())

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8


repositories {
    //jcenter()
    mavenCentral()
}

dependencies {
    // Use JUnit test framework
	testImplementation 'junit:junit:4.13.2'
}
And here's the error I'm getting:
Copy code
> Could not resolve junit:junit:4.13.2.
      > Could not get resource '<https://repo.maven.apache.org/maven2/junit/junit/4.13.2/junit-4.13.2.pom>'.
         > org.apache.http.ssl.SSLInitializationException: NONE (The system cannot find the file specified)
t
It looks like your JVM/JDK is unable to establish the SSL/TLS connection with Central. Possibly your JDK installation is broken, failing to find the trust-store.
j
Ahhh. Should I try reinstalling my JDK then?
That would explain why it works on my browser and not via the JVM.
So I've tried reinstalling the JDK and the JRE. Still not working.
Actually I forgot to mention... This assignment is super old. The version of Gradle it uses is 4.4.
So that could be a factor in this too.
Okay I'm completely at my wit's end here. I've added the maven central repository key into my cacerts. I've specifically whitelisted java and javaw in my crappy software firewall (which didn't seem to block them anyway). And Gradle still tells me it can't find pom files on mavenCentral().
I'm running out of things to do.
And questioning my life choices (like using coursera to learn about junit).
I also tried just adding the junit 4 library directly to the project in Eclipse. But then Gradle doesn't see it and tells me I can't import Junit libraries.
t
Gradle 4.4 might indeed be the problem here, with a bundled Apache HttpClient version that'd be unable to connect to modern HTTPS.
j
Yeah that would make a TON of sense lol.
I wonder if I could just use a later version of Gradle without messing up the projeect.
t
Try upgrading to the latest minor in the same major (that'd be 4.10.3 first) to check if there's any deprecation warning, then update to the next major (5.6.4, 6.9.4, etc.)
j
Funny you mentioned it. I tried all of those actually hahaha.
Oh I thought the major for 6 was 6.8.3. I'll try that one.
Nope same problem. šŸ˜ž
I'm trying the major for 7. I already tried 8. That one says anything that's below Java 16 is no longer supported.
Same problem.
Not the support part. It's just still giving me file isn't found. Despite me going to the url in my browser and accessing the file.
Alright I'm going to bed. I'll try again tomorrow morning. Thanks for your help thus far. šŸ™‚
n
how did you update the gradle version?
t
If Gradle 7 and 8 don't work, then clearly this points to your JDK installation/configuration. Try some or all of: • running with info or debug logs, hoping you'll get more details that could hint you to a fix • using another JDK 8 vendor (Eclipse Temurin, Azul Zulu, Oracle JDK, etc.) • using another JDK version (after commenting out the check in the Gradle build script) • building a small Java program (without using Gradle) that just tries to open a connection to repo.maven.apache.org (you could use
new java.net.URL("https://…").openConnection()
, if it works, then try using Apache HttpClient instead of
java.net.URL
, find the JAR and dependencies in Gradle itself, e.g.
~/.gradle/wrapper/dists/gradle-4.4-bin/*/gradle-4.4/http*.jar
)
j
So I have a question... If I were to include the library into the project, is there a way to get Gradle to recognize it?
Or better yet, could I create a local version of maven and have it point to that as my repository?
I'm not sure what I did. But after setting JAVA_HOME in my environment variables and resetting my machine... Everything suddenly just started working.
It seems like it's able to get stuff from the repository.
Wow. Just... Wow. I don't know what to say.
Either way, I really appreciate the help given to me. šŸ™‚ Hopefully I won't have any other issues moving forward. In the future I'm going to make sure whatever class I take involving coding utilizes technology built within the last 3 or so years lol.
v
Not only the Gradle version is ancient, also the JUnit version is ancient. Besides that imho Spock is a ton better to write tests and for me is the reason testing became fun again. :-)
j
Oh I believe it! As I mentioned before this is tied to an online course that never updated its assignments in 13 years hahaha. That's a long time and I'm sure there's way better stuff out there!