How to solve the generation error "Invalid method Code length" error
From Wiki
The "java.lang.ClassFormatError: Invalid method Code length" error, is an error that you can get generating the layout of your Web project. It means that you used a template in the Web project that is too large to be compiled.
It often happens in cell templates, when the template handles the rendering of a large number of units.
To solve the problem, you have to break down the template into smaller templates. At the end of this process you will have one main template (unit, cell, and so on) and different "helper" templates, which are called from the main one. Here are some guidelines:
- locate a piece of code that can be placed in an independent file
- create a "helper" template in the same directory of the main template which will contain this piece of code
- place the portion of code in the helper template
- declare all the Groovy variables that the helper template needs to get successfully compiled
- in the main template declare this Groovy variable that represents the directory in which the main template is placed. If the error is not related to a cell template, you only have to change the following Groovy variables in order to get the layout of the element to which the template is related to and the correspondent directory.
def cellLayout = getCellLayout(cell) def templateDir = getElementLayoutFile(cellLayout.path, ".cell.template").parentFile def templatePath = templateDir.absolutePath + "/helperTemplateName.Helper.template" def templateParams= null
- in the main template remove the piece of code copied into the helper template and write the following code that calls the helper template
<wr:PrintTemplate var="templateParams" template="templatePath"/>
