Issue
I'm trying to run a legacy system (using Grails 2.3.7 and JDK 7) for development locally which until now has worked as usual.
I was getting another error that I solved deleting the folders .m2
and .grails
in my home. After that some dependencies are returning the error below:
Full log here.
Error |
Resolve error obtaining dependencies: Failed to read artifact descriptor for org.grails.plugins:tomcat:zip:7.0.52.1
Error |
Resolve error obtaining dependencies: Failed to read artifact descriptor for org.grails.plugins:scaffolding:zip:2.0.2
Caused by: org.apache.http.client.HttpResponseException: Permanent Redirect (308)
at org.eclipse.aether.transport.http.HttpTransporter.handleStatus(HttpTransporter.java:404)
at org.eclipse.aether.transport.http.HttpTransporter.execute(HttpTransporter.java:298)
at org.eclipse.aether.transport.http.HttpTransporter.implGet(HttpTransporter.java:250)
at org.eclipse.aether.spi.connector.transport.AbstractTransporter.get(AbstractTransporter.java:59)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:418)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:337)
... 60 more
Probably I'm missing something but the plugin seems to be on the same place on the repo.grails.org repository.
What I'm asking is for an explanation on how to solve this, so I can get around this problem, if possible.
For the time being, I partially solved the error by copying my coworkers .m2
and .grails
folder but when I change some dependency in the BuildConfid.groovy
this error shows up again. My coworker also deleted the .grails
and .m2
in the home folder, and the same error happens.
BuildConfig.groovy:
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "debug" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
// mavenCentral()
// mavenRepo "http://repository.codehaus.org"
mavenRepo "http://download.java.net/maven/2/"
// mavenRepo "http://repository.jboss.com/maven2/"
mavenRepo "http://download.java.net/maven/2/"
mavenRepo "http://mavensync.zkoss.org/maven2"
mavenRepo "http://insecure.repo1.maven.org/maven2/"
}
dependencies {
compile "net.sf.ehcache:ehcache-core:2.4.6"
}
plugins {
build ":tomcat:7.0.47"
compile ':cache:1.1.1'
runtime ":jquery:1.10.2.2"
runtime ":resources:1.2.1"
compile ":rest-client-builder:2.1.1"
}
}
grails.server.port.http = 8082
Solution
Besides the obvious solution of upgrading Grails, to simply solve this problem it's possible to use Java 8 to download the dependencies and Java 7 to run the application.
1. Replace all Grails and Maven Central http repositories (e.g. grailsCentral()
, grailsPlugins()
) with its https equivalents:
repositories {
mavenLocal()
mavenRepo "https://repo1.maven.org/maven2/"
mavenRepo "https://repo.grails.org/grails/core"
mavenRepo "https://repo.grails.org/grails/plugins"
mavenRepo "https://jaspersoft.jfrog.io/artifactory/third-party-ce-artifacts"
Don't forget to also remove the line with inherits true
.
2. Refresh (download) the dependencies using Java 8:
# Unix
# Change java command to Java 8 full path if needed
G_HOME="</path/to/grails_home>" java -Dgrails.home="$G_HOME" \
-Dgroovy.starter.conf="$G_HOME/conf/groovy-starter.conf" \
-classpath "$G_HOME/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-2.1.9.jar:$G_HOME/dist/grails-bootstrap-2.3.4.jar" \
org.codehaus.groovy.grails.cli.support.GrailsStarter \
--main org.codehaus.groovy.grails.cli.GrailsScriptRunner \
--conf "$G_HOME/conf/groovy-starter.conf" \
"refresh-dependencies"
# Windows cmd (Not tested)
set G_HOME=</path/to/grails_home>
java -Dgrails.home=%G_HOME% ^
-Dgroovy.starter.conf=%G_HOME%/conf/groovy-starter.conf ^
-classpath %G_HOME%/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-2.1.9.jar:%G_HOME%/dist/grails-bootstrap-2.3.4.jar ^
org.codehaus.groovy.grails.cli.support.GrailsStarter ^
--main org.codehaus.groovy.grails.cli.GrailsScriptRunner ^
--conf %G_HOME%/conf/groovy-starter.conf ^
refresh-dependencies
3. Run using Java 7
Intellij
If you want to do this only on Intellij, you can change SDK version at File > Project Structure > Project > SDK. Beware that Intellij may build Grails automatically so it'll be necessary to restart the IDE.
The problem is http://repo.grails.org is redirecting to https and no longer accepting http connections.
I tried using Java 7 and Maven with Grails https repository enabling TLS version 1.2 support and adding Java Cryptography Extension (JCE). Eventually got stuck in a TLS handshake problem which I was short in time to solve.
Answered By - Maicon Mauricio
Answer Checked By - Mary Flores (JavaFixing Volunteer)