jastrachan | 31 Mar 20:41 2005

Re: Parsing errors in groovlets

These kinds of issues normally depend on the classloader hierarchy and 
kinda depend if  you're using the groovy command line scripts (which 
use ClassWorlds) or using GroovyShell / GroovyClassLoader directly - 
which when you construct it you can pass in the parent class loader to 

Depending on your environment, you might wanna use the current thread 
context class loader (such as in app servers) or the class loader which 
loaded your code (or the system class loader) depending on how you're 
embedding groovy into what you're doing.

Unfortunately class loaders are quite painful in Java to get right:(

On 31 Mar 2005, at 17:30, Christof Vollrath wrote:
> I had the same problems when developping GvTags.
>  When using external Groovy classes (external to the web application)
>  I ususally write unit tests as subclasses of GroovyTestCase before
>  calling them from the web app.
>  See the weather database example in GvTags. (http://gvtags.berlios.de)
>  Also I use the groovy compiler groovyc to check the syntax, when I 
> god strange
>  errors.
>  Bye,
>  tof
> G.Schoepp schrieb:
> Hi,
>  I love using groovy for developing small web apps with groovlets. The 
> only annoying thing is tracking down parsing errors when the web app 
> consists of more than one .groovy file.
>  In the attached example I have a groovlet test1.groovy which 
> instantiates a Person class in the Person.groovy file (I omitted a { 
> in the constructor to produce a parsing error).
>  The error message on stdout is: "GroovyServlet Error:  script: 
> 'test1.groovy': groovy.util.ScriptException: Could not parse script: 
> test1.groovy"
>  The messages in the catalina log aren't helpful either:
>  - StandardContext[/groovy]GroovyServlet Error:  script: 
> 'test1.groovy': groovy.util.ScriptException: Could not parse script: 
> test1.groovy
>  - groovy.lang.MissingClassException: No such class: Person in 
> constructor call for class: test1. At [1:8] test1.groovy
>  How are you tracking down those kind of errors?
>    Guido
>  ---test1.groovy (Groovlet)-----
>  pers = new Person(fname:"Will",lname:"Smith")
>  request.setAttribute("person", pers)
>  context.getRequestDispatcher("/test1.jsp").forward(request, response)
>  ---Person.groovy-----
>  public class Person{
>      age
>      fname
>      lname
>      Person () // { omitted to produce parsing error
>      }
>  }