Build Failed: Plugin was not found

Hi,
First time gradle user trying to build an application. Having searched the forums and the documentation, I have not been able to resolve my issue. Looking for some guidance. Thanks in advance.

I have a very simple application and gradle build. I created the project using gradle init and have made simple additions to the gradle.build.
The build fails with an exception:

Plugin [id: ‘org.gretty’, version: ‘4.0.3’] was not found in any of the following sources:

  • Gradle Core Plugins (plugin is not in ‘org.gradle’ namespace)
  • Plugin Repositories (could not resolve plugin artifact ‘org.gretty:org.gretty.gradle.plugin:4.0.3’)
    Searched in the following repositories:
    Gradle Central Plugin Repository

I have checked the gradle plugin portal and the plugin is there.
The gradle.build file was created using gradle init with some small additions. Build file is as follows:

/*

  • This file was generated by the Gradle ‘init’ task.
  • This generated file contains a sample Java application project to get you started.
  • For more details take a look at the ‘Building Java & JVM projects’ chapter in the Gradle
  • User Manual available at Building Java & JVM projects
    */

plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id ‘application’
// to embed container
id “org.gretty” version “4.0.3”
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
// Use JUnit Jupiter for testing.
testImplementation ‘org.junit.jupiter:junit-jupiter:5.7.2’
// This dependency is used by the application.
implementation ‘com.google.guava:guava:30.1.1-jre’

implementation 'javax.websocket:javax.websocket-api:1.1'

}

application {
// Define the main class for the application.
mainClass = ‘java_websockets.App’
}

tasks.named(‘test’) {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

gretty {
servletContainer = ‘tomcat9’
contextPath = ‘/’
}

Any guidance appreciated. Thanks in advance.

Kevin.

I literally copy&pasted your example into my play project and it works fine.
(Well until it comes to the state where it says that “tomcat9” is not supported)
Do you have maybe some proxy or firewall or similar, that intercepts the HTTP traffic and needs some configuration?

Hi,
Thanks for your response.
There is no proxy. I’ve looked at my firewall configuration and there is no interception of HTTP traffic happening.
The other point that may be relevant/help is that maven can get to maven central to get artifacts.
I should have said a bit more about my environment in the original post.
I’m running Ubuntu 22.04 LTS as a virtual machine (hosted on Windows 10 with firewall and proxy response as above) using VMWare Player will java 11 and gradle 7.2. I do not have a firewall enabled in the Ubuntu VM nor is there a proxy that I can see in the network settings.
Based on your response, I downloaded gradle for Windows (v7.2 as in my ubuntu environment) and ran gradle appRun on the same java project and received what looks to be the same problem as you reported.

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ‘:app’.

Failed to notify project evaluation listener.
Unsupported servlet container: tomcat9


So, the plugin not being found seems to be an artifact of use inside a VM?
I had another look in the forum and found a post from May 2018 that looks exactly the same but with no response.
Any further thoughts.
Thanks again.

Kevin.

Hi again,

I’ve done some more work. I’ve sorted out the unsupported tomcat problem and can fix that. I moved on to the next step which was to create a war file for a trivial web app.

Using Ubuntu, a similar problem occurred which may have the same root cause as the plugin not found. This time it was a resource from maven central which could not be accessed. I was executing gradle war.

In this case, gradle could not access resources from maven central.

kevin@virtual-machine:~/Projects/java_websockets$ gradle --info war
Initialized native services in: /home/kevin/.gradle/native
Initialized jansi services in: /home/kevin/.gradle/native
The client will now receive all logging from the daemon (pid: 3036). The daemon log file: /home/kevin/.gradle/daemon/7.2/daemon-3036.out.log
Starting 7th build in daemon [uptime: 26 mins 45.597 secs, performance: 99%, non-heap usage: 21% of 256 MiB]
Using 3 worker leases.
Now considering [/home/kevin/Projects/java_websockets] as hierarchies to watch
Watching the file system is configured to be enabled if available
File system watching is active
Starting Build
Settings evaluated using settings file ‘/home/kevin/Projects/java_websockets/settings.gradle’.
Projects loaded. Root project using build file ‘/home/kevin/Projects/java_websockets/build.gradle’.
Included projects: [root project ‘java_websockets’, project ‘:app’]

Configure project :
Evaluating root project ‘java_websockets’ using build file ‘/home/kevin/Projects/java_websockets/build.gradle’.

Configure project :app
Evaluating project ‘:app’ using build file ‘/home/kevin/Projects/java_websockets/app/build.gradle’.
Compiling build file ‘/home/kevin/Projects/java_websockets/app/build.gradle’ using SubsetScriptTransformer.
Compiling build file ‘/home/kevin/Projects/java_websockets/app/build.gradle’ using BuildScriptTransformer.
All projects evaluated.
Selected primary task ‘war’ from project :
Tasks to be executed: [task ‘:app:compileJava’, task ‘:app:processResources’, task ‘:app:classes’, task ‘:app:war’]
Tasks that were excluded:
:app:compileJava (Thread[Execution worker for ‘:’,5,main]) started.

Task :app:compileJava FAILED
:app:compileJava (Thread[Execution worker for ‘:’,5,main]) completed. Took 0.037 secs.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:compileJava’.

Could not resolve all files for configuration ‘:app:compileClasspath’.
Could not resolve com.google.guava:guava:31.1-jre.
Required by:
project :app
Could not resolve com.google.guava:guava:31.1-jre.
Could not get resource ‘https://repo.maven.apache.org/maven2/com/google/guava/guava/31.1-jre/guava-31.1-jre.pom’.
java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 933ms
1 actionable task: 1 executed
Watching 1 directories to track changes
kevin@virtual-machine:~/Projects/java_websockets$

In the above, there is the following:
Could not get resource ‘https://repo.maven.apache.org/maven2/com/google/guava/guava/31.1-jre/guava-31.1-jre.pom

If I double click on that link, the browser opens and the file is there.

Directly below that is the line:
> java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)

This did not appear in the output when the plugin was not found in the initial attempt.

Again, I tried this in my Windows environment and the war file was created without problem.

I’m hoping the java.security issue provides a clue as to what the problem is.

My Ubuntu VM does not include a firewall nor is there a proxy.

Any help or guidance appreciated.

Thanks.

Kevin.

downloaded gradle for Windows (v7.2 as in my ubuntu environment) and ran gradle appRun

You should actually not install any Gradle version to run a Gradle build in almost all cases.
Each Gradle build that does not contain the 4 Gradle wrapper files imho has a bug.
And if it is there, you should use it (gradlew) to execute the build, as then the Gradle version the build is written with / designed for / known working with is used to run the build and there can be no problem due to wrong Gradle version.

So, the plugin not being found seems to be an artifact of use inside a VM?

Not the fact that you are running from inside a VM, no.
Something in your local setup of that VM that is probably blocking the requests or something maybe.
You might be able to find a hint in the --info or --debug output.

Again, I tried this in my Windows environment and the war file was created without problem.
I’m hoping the java.security issue provides a clue as to what the problem is.
My Ubuntu VM does not include a firewall nor is there a proxy.

Ah, important information added now, yes. :slight_smile:
Most probably the same root cause as the problem with the plugin.
Your Java seems to have a problem to establish the HTTPS connection.
Try to reinstall Java or to use a different Java installation.
You miss some security things or certificates or something that causes the HTTPS connection to fail.