Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails 1.3.7 / Java 7 Compatibility

Tags:

java

grails

Has anyone had luck running a Grails 1.3.7 app with Java 7? I created a brand new Grails 1.3.7 app and tried running it under Java 7. I get the below error but the app appears to run ok. We have a few 1.3.7 apps that we're reluctant to upgrade to Grails 2.x, so any ideas would be much appreciated.

Unable to use direct char[] access of java.lang.String
java.lang.NoSuchFieldException: count
    at java.lang.Class.getDeclaredField(Class.java:1899)
    at org.codehaus.groovy.grails.web.util.StringCharArrayAccessor.<clinit>(StringCharArrayAccessor.java:53)
    at org.codehaus.groovy.grails.web.util.StreamCharBuffer.readAsString(StreamCharBuffer.java:531)
    at org.codehaus.groovy.grails.web.util.StreamCharBuffer.toString(StreamCharBuffer.java:552)
    at org.codehaus.groovy.grails.web.pages.FastStringWriter.getValue(FastStringWriter.java:59)
    at org.codehaus.groovy.grails.web.pages.FastStringWriter.toString(FastStringWriter.java:55)
    at org.codehaus.groovy.grails.web.pages.GroovyPageParser.startTag(GroovyPageParser.java:1119)
    at org.codehaus.groovy.grails.web.pages.GroovyPageParser.page(GroovyPageParser.java:801)
    at org.codehaus.groovy.grails.web.pages.GroovyPageParser.generateGsp(GroovyPageParser.java:380)
    at org.codehaus.groovy.grails.web.pages.GroovyPageParser.parse(GroovyPageParser.java:326)
    at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.buildPageMetaInfo(GroovyPagesTemplateEngine.java:584)
    at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.createTemplate(GroovyPagesTemplateEngine.java:493)
    at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.createTemplateWithResource(GroovyPagesTemplateEngine.java:473)
    at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.createTemplate(GroovyPagesTemplateEngine.java:246)
    at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.createTemplateForUri(GroovyPagesTemplateEngine.java:373)
    at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.createTemplateForUri(GroovyPagesTemplateEngine.java:345)
    at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.createTemplate(GroovyPagesTemplateEngine.java:262)
    at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.renderWithTemplateEngine(GroovyPageView.java:146)
    at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.renderMergedOutputModel(GroovyPageView.java:81)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.renderViewForUrlMappingInfo(UrlMappingsFilter.java:260)
    at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:189)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:245)
    at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:134)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.codehaus.groovy.grails.web.servlet.filter.GrailsReloadServletFilter.doFilterInternal(GrailsReloadServletFilter.java:104)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:69)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:69)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:722)
like image 877
Kevin Vaughn Avatar asked Jan 24 '13 21:01

Kevin Vaughn


3 Answers

Set the JAVA_OPTS system property:
Windows: SET JAVA_OPTS=-Dstringchararrayaccessor.disabled=true
Unix: export JAVA_OPTS=-Dstringchararrayaccessor.disabled=true

like image 144
gumble42 Avatar answered Oct 07 '22 11:10

gumble42


That's annoying but safe to ignore, and fixed in 2.1.1 and 2.2 - see https://github.com/grails/grails-core/issues/2359 for details.

like image 38
Burt Beckwith Avatar answered Oct 07 '22 12:10

Burt Beckwith


From what I see in the source code, you can set the JVM property stringchararrayaccessor.disabled to true.

like image 43
rimero Avatar answered Oct 07 '22 12:10

rimero