chiquitinxx / grooscript-plugins

Grooscript plugins - Gradle and Grails 3
12 stars 1 forks source link

Exception converting domain class in Windows #6

Closed tepsl closed 8 years ago

tepsl commented 8 years ago

In Windows, both 7 and 8.1 for x64, development mode, the exception occurs in runtime. In OS X, it never happens. Executing "grails generate-remote-domain" results in the same exception. Is there any solution or workaround? The stacktrace of "grails --verbose generate-remote-domain" is:

[Grooscript Plugin] [ERROR] Exception converting domain class (grooscript.sample.Book) file: character to be escaped is missing
Error |
null
java.lang.NullPointerException
    at java.io.Writer.write(Writer.java:157)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.write(ResourceGroovyMethods.java:741)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.setText(ResourceGroovyMethods.java:762)
    at org.codehaus.groovy.runtime.dgm$999.doMethodInvoke(Unknown Source)
    at org.codehaus.groovy.reflection.GeneratedMetaMethod$Proxy.doMethodInvoke(GeneratedMetaMethod.java:73)
    at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2702)
    at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3749)
    at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:199)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:484)
    at generate-remote-domain$_run_closure2.doCall(generate-remote-domain.groovy:22)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
    at groovy.lang.Closure.call(Closure.java:426)
    at groovy.lang.Closure.call(Closure.java:442)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056)
    at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at generate-remote-domain.run(generate-remote-domain.groovy:15)
    at org.grails.cli.profile.commands.script.GroovyScriptCommand.handle(GroovyScriptCommand.groovy:152)
    at org.grails.cli.profile.DefaultProfile.handleCommand(DefaultProfile.groovy:177)
    at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:289)
    at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:270)
    at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:248)
    at org.grails.cli.GrailsCli.main(GrailsCli.groovy:147)
chiquitinxx commented 8 years ago

Thanks for reporting. Something is happening with the file system in windows machines, sadly I don't have a windows machine to test it. No solution or workaround at the moment. I need a window user to test and fix that, any takers?

This is the point of the error: https://github.com/chiquitinxx/grooscript-grails3-plugin/blob/master/src/main/scripts/generate-remote-domain.groovy#L22

2015-11-27 10:05 GMT+01:00 tepsl notifications@github.com:

In Windows, both 7 and 8.1 for x64, development mode, the exception occurs in runtime. In OS X, it never happens. Executing "grails generate-remote-domain" results in the same exception. Is there any solution or workaround? The stacktrace of "grails --verbose generate-remote-domain" is:

[Grooscript Plugin] [ERROR] Exception converting domain class (grooscript.sample.Book) file: character to be escaped is missing Error | null java.lang.NullPointerException at java.io.Writer.write(Writer.java:157) at org.codehaus.groovy.runtime.ResourceGroovyMethods.write(ResourceGroovyMethods.java:741) at org.codehaus.groovy.runtime.ResourceGroovyMethods.setText(ResourceGroovyMethods.java:762) at org.codehaus.groovy.runtime.dgm$999.doMethodInvoke(Unknown Source) at org.codehaus.groovy.reflection.GeneratedMetaMethod$Proxy.doMethodInvoke(GeneratedMetaMethod.java:73) at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2702) at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3749) at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:199) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:484) at generate-remote-domain$_run_closure2.doCall(generate-remote-domain.groovy:22) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) at groovy.lang.Closure.call(Closure.java:426) at groovy.lang.Closure.call(Closure.java:442) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056) at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at generate-remote-domain.run(generate-remote-domain.groovy:15) at org.grails.cli.profile.commands.script.GroovyScriptCommand.handle(GroovyScriptCommand.groovy:152) at org.grails.cli.profile.DefaultProfile.handleCommand(DefaultProfile.groovy:177) at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:289) at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:270) at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:248) at org.grails.cli.GrailsCli.main(GrailsCli.groovy:147)

— Reply to this email directly or view it on GitHub https://github.com/chiquitinxx/grooscript-grails3-plugin/issues/6.

tepsl commented 8 years ago

By my investigation, conversionResult is null. So GrooscriptConverter.convertRemoteDomainClass() must be the matter. I'll dig into it more deeply.

tepsl commented 8 years ago

Finally got a solution.

In Util.groovy, SEP is used for regex. Unfortunately SEP is backslash in Windows. Then backslash is interpreted as escape character and there's no character after backslash, so "character to be escaped is missing". Below is my workaround but there might be better solution.

    private static getFileNameFromDomainClassCanonicalName(String domainClassCanonicalName) {
        "${domainClassCanonicalName.replaceAll(/\./, SEP.replace('\\', '\\\\'))}.groovy"
    }
chiquitinxx commented 8 years ago

Cheers, thank you.

I have commited changes. Please can you update and try again? Just ./gradlew install, and use version 1.1.4-SNAPSHOT in your local windows machine. When you say is Ok, I'll release a new version.

tepsl commented 8 years ago

./gradlew install does not work unless the project folder is named grooscript. As I cloned this repo in my local directory as grooscript-grails3-plugin at first, ./gradlew install placed pom and jar files in %HOME%.m2\repository\org\grails\plugins\grooscript-grails3-plugin\1.1.4-SNAPSHOT and it failed.

Anyway, it works.

chiquitinxx commented 8 years ago

New version 1.1.4 is out.