My 'resolving dependencies' is up around 30 seconds for a lightening fast computer and network.
I've looked at this question Grails: Very slow deploy time. 'Resolving Dependencies...' takes 10+ seconds, and I don't appear to have any 'snapshot' dependencies. I've cleared out my ivy cache and forced a redownload of everything, no help. Enabling logging, these few lines are the offenders. Nothing is being downloaded, but it appears that attempts are made to look for something remotely every time, given my network traffic. Note these are the ONLY entries that have the [some number] version before them, and then a different one after - that can't be coincidence - what does it mean? How can I stop grails from trying to find these slightly different versions?
.... these lines take 20+seconds, everything else is in the milliseconds ...
found commons-logging#commons-logging;1.1.1 in grailsPlugins
[1.1.1] commons-logging#commons-logging;[1.1, 2.0)
found org.apache.httpcomponents#httpclient;4.1.2 in default
[4.1.2] org.apache.httpcomponents#httpclient;[4.1, 5.0)
found org.apache.httpcomponents#httpcore;4.1.2 in default
found org.codehaus.jackson#jackson-core-asl;1.9.1 in default
[1.9.1] org.codehaus.jackson#jackson-core-asl;[1.4,)
found javax.mail#mail;1.4.4 in default
[1.4.4] javax.mail#mail;[1.4,)
I am using two plugins that must be the offenders, and have listed their dependencies.groovy below. I've tried commenting out any explicit remote URLs.
SimpleDB:
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.dependency.resolution = {
inherits "global"
log "warn"
String datastoreVersion = "1.0.0.M9"
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
mavenRepo "http://repo.grails.org/grails/core" //tried commenting this out, no help
mavenLocal()
mavenCentral()
mavenRepo 'http://repository.codehaus.org' //tried commenting this out, no help
}
dependencies {
def excludes = {
transitive = false
}
compile("org.grails:grails-datastore-gorm-simpledb:$datastoreVersion",
"org.grails:grails-datastore-gorm-plugin-support:$datastoreVersion",
"org.grails:grails-datastore-gorm:$datastoreVersion",
"org.grails:grails-datastore-core:$datastoreVersion",
"org.grails:grails-datastore-simpledb:$datastoreVersion",
"org.grails:grails-datastore-web:$datastoreVersion") {
transitive = false
}
runtime("stax:stax:1.2.0", excludes)
runtime('com.amazonaws:aws-java-sdk:1.2.0')
test("org.grails:grails-datastore-gorm-test:$datastoreVersion",
"org.grails:grails-datastore-simple:$datastoreVersion") {
transitive = false
}
}
plugins {
build ":release:1.0.0.RC3", {
exported = false
}
}
}
Ajax uploader:
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.release.scm.enabled=false
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
mavenLocal()
mavenCentral()
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
test 'org.gmock:gmock:0.8.1'
}
plugins {
//build ':release:1.0.0.RC3'
}
}
and I've found the culprit. If a plugin you use relies on a library in maven that has 'open ended' dependencies, grails will go and look each time if there are newer versions to download in the range. I have no idea why anyone would specify it like this. It seems it would lead to unreliable behaviour. For me, the culprit is Amazon's java aws library, naturally required by the simpledb plugin that talks to Amazon's cloud.
http://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk/1.2.10
note how some of its dependencies are like this
org.apache.httpcomponents httpclient [4.1, 5.0)
it appears that every time, grails is looking for a newer version (and downloading if it exists, I just noticed 4.2-alpha1 of httpclient come down when I ran this time).
By removing that dependency from the plugin and manually adding the required libraries to my .lib folder, I reduced my startup time from >30sec to <1sec
If you run grails --offline run-app, then dependency resolution gets (at least partially) disabled and startup time is much quicker.
Of course you have to be sure that you don't need any new dependencies to be downloaded - I've had spent time scrounging around for a solution for a problem which turned out to be because I was running grails offline. I learnt quickly though :)
I agree that Grails startup times are horribly slow, luckily the rest of the framework improves productivity - mostly to the point where you're more productive than plain old java :-)
Related
I started a brand new grails 2.2 app. I want to add qrcode plugin.
https://plugins.grails.org/plugin/technipelago/qrcode
the documentation says for grails 2 app use
grails.project.dependency.resolution = {
// ...
plugins {
compile ':qrcode:0.7'
// ...
}
}
here is my buildconfig after adding qrcode plugin
grails.servlet.version = "2.5" // 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.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
// uncomment (and adjust settings) to fork the JVM to isolate classpaths
//grails.project.fork = [
// run: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256]
//]
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsCentral()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.20'
}
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.8.3"
runtime ":resources:1.1.6"
build ":tomcat:$grailsVersion"
runtime ":database-migration:1.2.1"
compile ':cache:1.0.1'
compile ':qrcode:0.7'
}
}
when i build
it says
|Loading Grails 2.2.0
|Configuring classpath
Error |
Failed to resolve dependencies (Set log level to 'warn' in BuildConfig.groovy for more information):
- org.grails.plugins:qrcode:0.7
I appreciate any help as to integrating qrcode plugin. I dont need latest version. I just need to make qrcode plugin to work. Old version will do.
Thanks for the help!
First add local maven repo (mavenLocal()) to your in BuildConfig.groovy:
repositories {
inherits true
grailsPlugins()
mavenLocal()
mavenCentral()
}
Then add dependency in BuildConfig.groovy:
dependencies {
compile "org.grails.plugins:qrcode:0.7"
}
If by adding in dependency not work then add it to plugins:
plugins {
compile(':qrcode:0.7')
}
You can refer repo of this plugin where you can see available versions.
Hope this helps you.
Try version 0.7.1
I looks
It is also for Grails 2.x and should load just fine by putting it in the plugins {} section like you did.
I want to learn Grails, so I started with a Hello-World Projekt.
I tried everything in the cmd.exe and in STS. I have Windows7.
First i wrote grails create-app helloworld command
Then i swaped in the new helloworld\ directory and wrote grails run-app
But the command-line doesn't go furthen then Configuring classpath
I watched in other forums but nothing helped.
I am sitting in a companys-internet. Does this cause the fault ?
Fault if log level is set on verbose (only the last few lines - before were about 500 other lines)
| Error Failed to resolve dependencies (Set log level to 'warn' in BuildConfig.groovy for more information):
org.apache.tomcat.embed:tomcat-embed-core:7.0.42
org.apache.tomcat.embed:tomcat-embed-logging-log4j:7.0.42
org.eclipse.jdt.core.compiler:ecj:3.7.2
org.apache.tomcat:tomcat-catalina-ant:7.0.42
org.apache.tomcat.embed:tomcat-embed-logging-juli:7.0.42
org.apache.tomcat.embed:tomcat-embed-jasper:7.0.42
Edit: I use Grails 2.2.4 and heres my BuildConfig.groovy:
grails.servlet.version = "2.5" // 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.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
// uncomment (and adjust settings) to fork the JVM to isolate classpaths
//grails.project.fork = [
// run: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256]
//]
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsCentral()
mavenLocal()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.22'
}
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.8.3"
runtime ":resources:1.2"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.5"
build ":tomcat:$grailsVersion"
runtime ":database-migration:1.3.2"
compile ':cache:1.0.1'
}
}
Be sure you are not behind a proxy.
Check on the command line grails list-plugins.
If this call fails: add and set the proxy and check the correct entries in the ProxySettings.groovy.
May this helps.
Please check internet and plugin download links are accessible or not..
I am sitting in a companys-internet
I faced the same problems with my company's proxy server.
On a Windows machine in grails-version_number\bin\ there is a startGrails.bat. Here the settings for your proxy server could be set via JAVA_OPTS (towards the bottom of the file). But it would not be a good to do so, because when you upgrade Grails a year or so from now your customs settings will be lost. And you'll be scratching your head about why Grails no longer works and/or you cannot remember the syntax for setting the proxy server info.
So, in the same bin\ directory make a new file called setenv.bat. In that add
#rem Java proxy properties for connecting to proxy server
set JAVA_OPTS=%JAVA_OPTS% -Dhttp.proxySet=true -Dhttp.proxyHost="proxyServerName" -Dhttp.proxyPort="0123" -Dhttp.username="userName" -Dhttp.password="userPassWord"
I would remove the helloworld directory you just created and then again run
grails create-app helloworld
I am getting failed download error when trying to install new-doc plugin. The error message I get looks like:
==== http://repo.grails.org/grails/libs-releases-local: tried
http://repo.grails.org/grails/libs-releases-local/net/sf/json-lib/json
-lib/2.4/json-lib-2.4.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: FAILED DOWNLOADS ::
:: ^ see resolution messages for details ^ ::
::::::::::::::::::::::::::::::::::::::::::::::
:: net.sf.json-lib#json-lib;2.4!json-lib.jar
::::::::::::::::::::::::::::::::::::::::::::::
| Error Failed to resolve dependencies (Set log level to 'warn' in BuildConfig.groovy for more information):
- net.sf.json-lib:json-lib:2.4
My BuildConfig.groovy looks like:
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.plugins.dir = "plugins"
grails.project.war.file = "target/${appName}.war"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
//mavenLocal()
mavenCentral()
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
compile 'org.apache.poi:poi:3.9'
compile 'org.apache.poi:poi-ooxml:3.9'
compile 'com.google.guava:guava:12.0'
}
plugins {
compile ":new-doc:0.3.2"
}
}
I am fairly new to groovy/grails so I am not sure what should I do next to resolve this issue. Or can anyone suggest me any other code documentation plugin for grails?
Thanks,
Dee
NOTE
When I ran "grails doc" it generated all the documentation code in target/docs folder. It has index.html page which I thought would list all the api functions, but it didn't have any information on the api documents there - so I wrongly concluded that grails doc was not generating the API documentation. I should have looked into target/docs/gapi folder instead to get the generated API documents for grails. I apologize for my noob problem, and not being able to see the solution that was right there in front of me. Thanks.
I've been racking my brain for hours trying to figure this out. Whenever I try to perform any kind of action to my newly created Grails project (with a fresh Grails install), I get this error message:
Error There was an error loading the BuildConfig: ivy pattern must be absolute:
${HOME}/.m2/alpha/repository/[organisation]/[module]/[revision]/[module]-[revision](-
[classifier]).pom (Use --stacktrace to see the full trace)
I can deduce that there's a problem with my installation, but its a fresh install as I said so I'm not sure what could have caused this problem already.
I'm running Win7. Any help would be much appreciated.
EDIT:
grails.servlet.version = "2.5" // 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.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsCentral()
mavenLocal()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
// runtime 'mysql:mysql-connector-java:5.1.20'
}
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.7.1"
runtime ":resources:1.1.6"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"
build ":tomcat:$grailsVersion"
runtime ":database-migration:1.1"
compile ':cache:1.0.0.RC1'
}
}
Problem solved for now.
It was a Maven problem, which I didn't consider initially. For some reason, the localRepository tag in /Users/USERNAME/.mp2/settings.xml couldn't resolve the path to HOME, so replacing ${HOME} with the C:/Users/USERNAME did the trick. Strange but it works for now. If anyone has a better solution let me know!
My solution was a little different:
(1) Create a variable that points to your .m2 repository location:
def localMavenRepo = "file://" + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
(2) Create a repository entry:
repositories {
...
mavenRepo name: 'Local', root: localMavenRepo
}
I also got the same problem.
I think it's not Maven problem, it's Apache Ivy's problem.
I think Apache Maven 2/3 works well, it's just that Apache Ivy didn't pick the correct Maven folder. The Apache Ivy didn't expand the ${user.home} as it should.
I solved this by setting my M2_REPO environment variable to an absolute path. On linux:
export M2_HOME=/home/chris/.m2/repository/
On windows you can set environment variables in the System Properties dialog (shortcut to System Properties is WindowsKey+PauseKey). Go to System Properties -> Advanced -> Environment Variables.
I've got a problem with NoClassDefFound exception in Grails 2.0 when I tried to use library from external JAR.
I've checked that declared JARs are inside of created WAR, also grials dependecies-report do not marks any issues with that.
Locally added JARs or downloaded from Maven repo seems no difference. I've also tried to clean IVY cache and clean grails project without success.
Did you got any ideas how to fix it?
BuildConfig.groovy (part of)
grails.project.dependency.resolution = {
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsCentral()
mavenCentral()
mavenLocal()
mavenRepo "http://snapshots.repository.codehaus.org"
mavenRepo "http://repository.codehaus.org"
mavenRepo "http://download.java.net/maven/2/"
mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
compile ( "javax:activation:1.0",
"javax:mail:1.0",
"com.google.gdata:gdata-core:1.0",
"com.google.gdata:gdata-client:1.0",
"com.google.gdata:gdata-media:1.0",
"com.google.gdata:gdata-youtube:2.0"
)
runtime ( "javax:activation:1.0",
"javax:mail:1.0",
"com.google.gdata:gdata-core:1.0",
"com.google.gdata:gdata-client:1.0",
"com.google.gdata:gdata-media:1.0",
"com.google.gdata:gdata-youtube:2.0"
)
}
...
}
LibraryController.groovy
import com.google.gdata.client.youtube.YouTubeService
import com.google.gdata.data.youtube.VideoEntry
import com.google.gdata.util.ServiceException
class LibraryController {
private YouTubeService service
private static final API_URL = "http://gdata.youtube.com/feeds/api/videos/"
def index = {
service = new YouTubeService("app")
}
}
Exception
Class
java.lang.NoClassDefFoundError
Message
Could not initialize class com.google.gdata.client.youtube.YouTubeServiceClass
java.lang.NoClassDefFoundError
Message
Could not initialize class com.google.gdata.client.youtube.YouTubeService
NoClassDefFoundError is not the same as ClassNotFoundException. Getting a ClassNotFoundException means the class isn't there, so you have a straightforward jar/dependency problem. NoClassDefFoundError means that the specified class was found, but that a class that it references wasn't found. It's a much more frustrating issue to track down because the JVM doesn't tell you what's missing.
You need to make sure that you have all of the dependencies of the class that's failing to load, and all of their dependencies, etc.
You have all your dependencies declared both in compile and runtime scope. Each dependency should be declared only once. If you declare a dependency in compile scope, it will also be available runtime. Since you need this class for compilation, you should keep com.google.gdata:gdata-youtube:2.0 under 'compile', and remove it from 'runtime'
A description of the available scopes, taken from the user documentation:
build: Dependencies for the build system only
compile: Dependencies for the compile step
runtime: Dependencies needed at runtime but not for compilation (see above)
test: Dependencies needed for testing but not at runtime (see above)
provided: Dependencies needed at development time, but not during WAR deployment