I have a JAX-RS project which have jetty plugin in gradle. I want to replace jetty plugin with gretty as jetty is not supported in gradle 4 and other versions. I get following errors while running gretty plugin.
Execution failed for task ':appRunWar'.
java.lang.Exception: com/sun/jersey/spi/inject/InjectableProvider
build.gradle code containing jetty plugin
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'eclipse'
jettyRun {
httpPort = 8080
reload = 'automatic'
scanIntervalSeconds = 2
daemon = false
}
//other things....
build.gradle code for replacing jetty with gretty
apply plugin: 'java'
apply plugin: 'war'
apply from: 'https://raw.github.com/akhikhl/gretty/master/pluginScripts/gretty.plugin'
apply plugin: 'eclipse'
gretty {
httpPort = 8080
//contextPath = '/'
servletContainer = 'jetty9'
httpEnabled = true
}
//other things...
First of all, do not use Akhikhl's gretty since its not maintained anymore and shows difficulties with certain jetty versions eg. jetty94 and jetty93. Additionally there is no support for Java versions 9 and 10.
Instead you should rely on the gretty-gradle-plugin which is a direct maintained fork:
plugins {
id 'java'
id 'war'
id 'eclipse'
id 'org.gretty' version '2.1.0'
}
gretty {
//contextPath = '/'
}
//other things...
The configuration you provide for gretty is the default configuration, you can drop it.
The default configuration in the ServerConfig.groovy
looks like the following:
static ServerConfig getDefaultServerConfig(String serverName) {
ServerConfig result = new ServerConfig()
result.jvmArgs = []
result.servletContainer = 'jetty9'
result.managedClassReload = false
result.httpEnabled = true
result.httpsEnabled = false
result.interactiveMode = 'stopOnKeyPress'
result.scanInterval = 1
result.loggingLevel = 'INFO'
result.consoleLogEnabled = true
result.fileLogEnabled = true
result.logFileName = serverName
result.redeployMode = 'restart'
result.logDir = "${System.getProperty('user.home')}/logs" as String
result.scanner = 'jetty'
result.portPropertiesFileName = 'gretty_ports.properties'
result.liveReloadEnabled = false
return result
}
Be aware that the gretty-gradle-plugin can be found at 'org.gretty'
where as Akhikhl's gretty is located at 'org.akhikhl.gretty'
. If your error persists please provide a full stacktrace and update your answer accordingly.