1
votes

I'm trying to learn grails and followed tutorial.

http://grails.org/doc/latest/guide/gettingStarted.html#creatingAnApplication

grails create-app helloworld command works fine and its creating project. But when i enter "grails" inside helloworld directory, i'm getting below error. Could'nt understand the root cause for this:

| Loading Grails 2.4.4
| Error java.lang.reflect.InvocationTargetException
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error         at java.lang.reflect.Method.invoke(Method.java:606)
| Error         at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
| Error         at org.codehaus.groovy.grails.cli.support.GrailsStarter.rootLoader(GrailsStarter.java:236)
| Error         at org.codehaus.groovy.grails.cli.support.GrailsStarter.main(GrailsStarter.java:264)
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error         at java.lang.reflect.Method.invoke(Method.java:606)
| Error         at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
| Error         at org.codehaus.groovy.grails.cli.support.GrailsStarter.rootLoader(GrailsStarter.java:236)
| Error         at org.codehaus.groovy.grails.cli.support.GrailsStarter.main(GrailsStarter.java:264)
| Error Caused by: java.lang.NumberFormatException: For input string: "true"
| Error         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
| Error         at java.lang.Integer.parseInt(Integer.java:492)
| Error         at java.lang.Integer.valueOf(Integer.java:582)
| Error         at org.codehaus.groovy.runtime.StringGroovyMethods.toInteger(StringGroovyMethods.java:3503)
| Error         at org.codehaus.groovy.grails.resolve.maven.aether.config.RepositoriesConfiguration.configureRepository(RepositoriesConfiguration.groo
vy:131)
| Error         at org.codehaus.groovy.grails.resolve.maven.aether.config.RepositoriesConfiguration.grailsCentral(RepositoriesConfiguration.groovy:154
)
| Error         at org.codehaus.groovy.grails.resolve.maven.aether.config.RepositoriesConfiguration.grailsCentral(RepositoriesConfiguration.groovy)
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error         at java.lang.reflect.Method.invoke(Method.java:606)
| Error         at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
| Error         at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
| Error         at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
| Error         at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1158)
| Error         at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
| Error         at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
| Error         at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
| Error         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
| Error         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:137)
| Error         at BuildConfig$_run_closure1_closure3.doCall(BuildConfig.groovy:41)
| Error         at BuildConfig$_run_closure1_closure3.doCall(BuildConfig.groovy)
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error         at java.lang.reflect.Method.invoke(Method.java:606)
| Error         at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
| Error         at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
| Error         at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
| Error         at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
| Error         at groovy.lang.Closure.call(Closure.java:423)
| Error         at groovy.lang.Closure.call(Closure.java:417)
| Error         at org.codehaus.groovy.grails.resolve.maven.aether.config.AetherDsl.repositories(AetherDsl.groovy:196)
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error         at java.lang.reflect.Method.invoke(Method.java:606)
| Error         at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
| Error         at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
| Error         at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
| Error         at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1158)
| Error         at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
| Error         at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
| Error         at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
| Error         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
| Error         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
| Error         at BuildConfig$_run_closure1.doCall(BuildConfig.groovy:35)
| Error         at BuildConfig$_run_closure1.doCall(BuildConfig.groovy)
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error         at java.lang.reflect.Method.invoke(Method.java:606)
| Error         at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
| Error         at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
| Error         at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
| Error         at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
| Error         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
| Error         at groovy.lang.Closure.call(Closure.java:423)
| Error         at groovy.lang.Closure.call(Closure.java:417)
| Error         at org.codehaus.groovy.grails.resolve.maven.aether.AetherDependencyManager.parseDependencies(AetherDependencyManager.groovy:317)
| Error         at org.codehaus.groovy.grails.resolve.DependencyManager$parseDependencies.call(Unknown Source)
| Error         at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
| Error         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
| Error         at org.codehaus.groovy.grails.resolve.DependencyManagerConfigurer.prepareAetherDependencies(DependencyManagerConfigurer.groovy:116)
| Error         at org.codehaus.groovy.grails.resolve.DependencyManagerConfigurer.configureAether(DependencyManagerConfigurer.groovy:59)
| Error         at grails.util.BuildSettings.configureDependencyManager(BuildSettings.groovy:1280)
| Error         at grails.util.BuildSettings.postLoadConfig(BuildSettings.groovy:1220)
| Error         at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1116)
| Error         at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1088)
| Error         at grails.util.BuildSettings.loadConfig(BuildSettings.groovy)
| Error         at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1074)
| Error         at grails.util.BuildSettings.loadConfig(BuildSettings.groovy)
| Error         at grails.util.BuildSettings$loadConfig$0.callCurrent(Unknown Source)
| Error         at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
| Error         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
| Error         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
| Error         at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1054)
| Error         at org.codehaus.groovy.grails.cli.GrailsScriptRunner.loadConfigEnvironment(GrailsScriptRunner.java:250)
| Error         at org.codehaus.groovy.grails.cli.GrailsScriptRunner.main(GrailsScriptRunner.java:210)
| Error         ... 14 more

Tried every link found here related to grails. Lookslike no one got the issue i'm facing. Maybe some environment or configuration issue which i'm missing.

Below are details about my environment:

JAVA_HOME=C:\Program Files\Java\jdk1.7.0_55
GRAILS_HOME=D:\Softwares\grails-2.4.4
GROOVY_HOME=D:\Softwares\groovy-2.3.7

I'm behind corporate proxy which i set as per below tutorial:

http://grails.org/doc/latest/ref/Command%20Line/set-proxy.html

Surprisingly, if i enter the same command, grails, inside any directory other than grails created app directory, its working fine and entering into grails console.

Can any one who successfully created app, please help me out.

BuildConfig.groovy (file generated default)

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.fork = [
    // configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
    //  compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],

    // configure settings for the test-app JVM, uses the daemon by default
    test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
    // configure settings for the run-app JVM
    run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    // configure settings for the run-war JVM
    war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    // configure settings for the Console UI JVM
    console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]

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 "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()
        mavenLocal()
        grailsCentral()
        mavenCentral()
        // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
        //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.29'
        // runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
        test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
    }

    plugins {
        // plugins for the build system only
        build ":tomcat:7.0.55"

        // plugins for the compile step
        compile ":scaffolding:2.1.2"
        compile ':cache:1.1.8'
        compile ":asset-pipeline:1.9.9"

        // plugins needed at runtime but not for compilation
        runtime ":hibernate4:4.3.6.1" // or ":hibernate:3.6.10.18"
        runtime ":database-migration:1.4.0"
        runtime ":jquery:1.11.1"

        // Uncomment these to enable additional asset-pipeline capabilities
        //compile ":sass-asset-pipeline:1.9.0"
        //compile ":less-asset-pipeline:1.10.0"
        //compile ":coffee-asset-pipeline:1.8.0"
        //compile ":handlebars-asset-pipeline:1.3.0.3"
    }
}
1
the error could indicate something odd in your BuildConfig.groovy, where a number was expected true is given. - cfrick
I din't modify anything in default files generated by "create-app" command. Will post the file content in my question. - kaluva
Got it. Looks like its proxy setting issue. When i checked at home where there is no proxy, it worked fine. - kaluva

1 Answers

2
votes

Finally got the issue. Looks like there is problem with below proxy setting commands: http://grails.org/doc/latest/ref/Command%20Line/set-proxy.html

grails add-proxy client --host=my_proxy_server --port=my_proxy_port --username=my_uname --password=my_pwd
grails set-proxy client

Though i use proper proxy details, it is inserting entries in 'C:\Users\.grails\ProxySettings.groovy' file as shown below.

client=['http.proxyHost':true, 'http.proxyPort':true, 'http.proxyUser':true, 'http.proxyPassword':true, 'http.nonProxyHosts':'']
currentProxy='client'

When i changed "true" to proper values in this file, its working fine. Hope this helps others if they face same issue.

If you want to use windows command to update proxy settings properly, use below command:

grails add-proxy myproxy "--host=my_host" "--port=my_port"
grails set-proxy myproxy

You will need to enclose parameters with double quotes. Then it is updating the proxySettings.groovy file properly. Source:

http://lalitagarw.blogspot.in/2011/06/grails-configuration-proxy-settings.html