Formal Framework please!

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Formal Framework please!

mythz
Hi Groovy people!

First of all just want to say kudos to a great language! This is the first time I have been excited about anything in the java landscape for years. I've been itching for an excuse to get off the Java framework for years, but the cross platformability and libraries cannot be beat! I was this | | close to converting to Rublam, Finally I can stop looking for alternatives.

Anyway, it still has some short comings that I think we should at least try to document.

I have looked through all the scripts and there doesnt seem to be a 'formal way' (that I know of) to import other groovy scripts/classes without compiling. (e.g. import test.groovy) i can see import test.groovy to be a problem so maybe a new keyword like:

require test.groovy

Some other nice language features in this area might be:

import package.class from "dir/lib.jar"

Also before we go 1.0 - maybe we could finally include the shortcut:

groovy -cp "dir/*.jar" script.groovy

for a recursive inclusion of jars in the class path.

Let us know what you think!

BTW, im thinking it must be a bug but I cant seem to import a custom class (from WEB-INF/classes or WEB-INF/src) from a groovlet, and there are no examples that demonstrate this fundamental requirement.

Cheers,
Demis



Reply | Threaded
Open this post in threaded view
|

Re: Formal Framework please!

Jochen Theodorou
Demis Bellot schrieb:

> Hi Groovy people!
>
> First of all just want to say kudos to a great language! This is the
> first time I have been excited about anything in the java landscape for
> years. I've been itching for an excuse to get off the Java framework for
> years, but the cross platformability and libraries cannot be beat! I was
> this | | close to converting to Rublam, Finally I can stop looking for
> alternatives.

you are very welcom. especially if you want to contribute usable code ;)

> Anyway, it still has some short comings that I think we should at least
> try to document.

groovy isn't perfect, yes.

> I have looked through all the scripts and there doesnt seem to be a
> 'formal way' (that I know of) to import other groovy scripts/classes
> without compiling. (e.g. import test.groovy) i can see import
> test.groovy to be a problem so maybe a new keyword like:
>
> require test.groovy

depends on what semantics you expect from this! Define it and we will
see if it is a problem.

> Some other nice language features in this area might be:
>
> import package.class from "dir/lib.jar"

I also thought about using import-from, but in another context. What you
do here is mixing compile time and run time in a way that is problematic
to support.

It is one of the limitations auf the java VM that a class may load other
classes when loaded. So if "package.class" is required to be loaded
while loading the class itself, then there is no way I know to
accomplish this. The only support we could give would be to check the
cases where "packge.class" can be loaded lazy or not. And because of
this I would name it:

import lazy package.class from "dir/lib.jar"

I am sure you know a better name, but I really want to mark that. Mark
it for the compiler and for the reader

> Also before we go 1.0 - maybe we could finally include the shortcut:
>
> groovy -cp "dir/*.jar" script.groovy
>
> for a recursive inclusion of jars in the class path.

recursive? you mean not the whole dir, also subdirs? again I would
modify it a little

"dir/**.jar"

follows the ant style. I don't think that would be much work

> BTW, im thinking it must be a bug but I cant seem to import a custom
> class (from WEB-INF/classes or WEB-INF/src) from a groovlet, and there
> are no examples that demonstrate this fundamental requirement.

tell us the error message or the symptoms please ;)

bye blackdrag
Reply | Threaded
Open this post in threaded view
|

Re: Formal Framework please!

mythz
> depends on what semantics you expect from this! Define it and we
> will see if it is a problem.

well basically i want to be able to re-use classes from another
groovy script, e.g.

foo.groovy:

package foo
class Foo {
    String niceUtil() {}
}

bar.groovy:

package bar
import foo.groovy //obvious reasons why this wont work
//perhaps, instead:
require "foo.groovy"
import foo.Foo

def foo = new Foo()
println foo.niceUtil()



> I also thought about using import-from, but in another context.
> What you do here is mixing compile time and run time in a way that
> is problematic to support.
>
> It is one of the limitations auf the java VM that a class may load
> other classes when loaded. So if "package.class" is required to be
> loaded while loading the class itself, then there is no way I know
> to accomplish this. The only support we could give would be to
> check the cases where "packge.class" can be loaded lazy or not. And
> because of this I would name it:
>
> import lazy package.class from "dir/lib.jar"
>
> I am sure you know a better name, but I really want to mark that.
> Mark it for the compiler and for the reader
>

I imagine it would be a dirty hack though i figured you would just  
add some metadata to the class and before you load it, load its libs,  
so a class like:

import pkg.Foo from "dir/lib.jar"

Class Bar
{
    Bar()
    {
      def foo = new Foo()
    }
}

would be compiled in byte code. something like:

Class Bar
{
    void Bar()
    {
    }
    static String[] __loadDynamicLibs = new String[]{"dir/lib.jar"}
}

and then before Groovy loads the class it would load/define the lib?


> recursive? you mean not the whole dir, also subdirs? again I would
> modify it a little
> "dir/**.jar"

Sounds Good - The more the merrier!

>
> tell us the error message or the symptoms please ;)
>


Ok here are my files:

Here I am trying to load a groovy class in a groovlet:

/groovy/WEB-INF/src/test/FooG.groovy:
package test
class FooG {
    @Property bar
}

/groovy/exampleG.groovy:
def foo = new test.FooG()
foo.bar = "test"
println foo.bar

//in tomcat (http://localhost:8080/groovy/exampleG.groovy) produces:
groovy.util.ScriptException: Could not parse script: /exampleG.groovy
java.lang.RuntimeException: groovy.util.ScriptException: Could not  
parse script: /exampleG.groovy
        at groovy.servlet.GroovyServlet$1.call(GroovyServlet.java:139)
        at org.codehaus.groovy.runtime.GroovyCategorySupport.use  
(GroovyCategorySupport.java:151)
        at groovy.servlet.GroovyServlet.service(GroovyServlet.java:144)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
..............
Caused by: groovy.util.ScriptException: Could not parse script: /
exampleG.groovy
        at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java:250)
        at groovy.servlet.GroovyServlet$1.call(GroovyServlet.java:135)
        ... 17 more
Caused by: /exampleG.groovy: 1: unable to resolve class test.FooG
   @ line 1, column 11.
1 Error

If I then compile test.FooG so that there exists: WEB-INF/classes/
test/FooG.class (and restart tomcat) I get the exact same Exception

I then try to consume the groovy class in an Example servlet
/groovy/WEB-INF/src/test/ExampleServlet.java:
    protected void doGet(HttpServletRequest request,  
HttpServletResponse response) throws ServletException, IOException
    {
      FooG foo = new test.FooG();
      fooG.setBar("test FooG");
      response.getWriter().println(foo.getBar());
    }

which gives me this Exception:
java.lang.Error: Unresolved compilation problems:
        FooG cannot be resolved to a type
        test.FooG cannot be resolved to a type
        fooG cannot be resolved

        test.ExampleServlet.doGet(ExampleServlet.java:16)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

This tells me there is something wrong with the generated test/
FooG.class, so I try to consume a .java class in my groovlet:

/groovy/WEB-INF/src/test/FooJ.java (there is also a compiled class
in /classes/test/FooJ.java):
package test;

class FooJ
{
    String bar;

    public void setBar(String bar)
    {
      this.bar = bar;
    }

    public String getBar()
    {
      return bar;
    }
}

/groovy/exampleJ.groovy:
def foo = new test.FooJ()
foo.bar = "test"
println foo.bar

//in tomcat (http://localhost:8080/groovy/exampleJ.groovy) i get this:
........
        at java.lang.Thread.run(Thread.java:613)
Caused by: groovy.util.ScriptException: Could not parse script: /
exampleJ.groovy
        at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java:250)
        at groovy.servlet.GroovyServlet$1.call(GroovyServlet.java:135)
        ... 17 more
Caused by: /exampleJ.groovy: 1: unable to resolve class test.FooJ
   @ line 1, column 11.
1 Error

//I then give up on groovy and go back to my trusty (but way too  
verbosy) Servlet:
.....
    protected void doGet(HttpServletRequest request,  
HttpServletResponse response) throws ServletException, IOException
    {
      FooJ foo = new test.FooJ();
      foo.setBar("test FooJ");
      response.getWriter().println(foo.getBar());
    }

and with a little xml in web.xml
tomcat (http://localhost:8080/groovy/ExampleServlet) greets me with:
test FooJ


So I basically want to know what is the recommended way of
1) using a class defined in groovy, in a Groovlet or Servlet; and
2) using a class defined in WEB-INF/classes in a Groovlet

If someone has working code that does the above can they send it to
me and i will try it out..

While on the subject i would like to propose another implicit  
variable in the Groovlet: 'param' so we can use familiar JSP 2.0/el  
syntax:

println "${param.key}"

Cheers,
Demis

Reply | Threaded
Open this post in threaded view
|

Re: Formal Framework please!

Jochen Theodorou
Demis Bellot schrieb:

>> depends on what semantics you expect from this! Define it and we
>> will see if it is a problem.
>
>
> well basically i want to be able to re-use classes from another
> groovy script, e.g.
>
> foo.groovy:
>
> package foo
> class Foo {
>    String niceUtil() {}
> }
>
> bar.groovy:
>
> package bar
> import foo.groovy //obvious reasons why this wont work
> //perhaps, instead:
> require "foo.groovy"
> import foo.Foo
>
> def foo = new Foo()
> println foo.niceUtil()

If I say require "foo.groovy" I still need to look into he file or else
I won't be able to tell what "Foo" means.

And another thing... can you tell me why you don't want groovy to
compile foo.groovy when compiling bar.groovy?

[...]
>> I am sure you know a better name, but I really want to mark that.
>> Mark it for the compiler and for the reader
>
> I imagine it would be a dirty hack though i figured you would just  add
> some metadata to the class and before you load it, load its libs

this requires that the class is loaded through the GroovyClassLoader! We
can't be sure about this. For exmaple if all files are compiler and
stored in a Database, then you have no chance to parse the bytecode to
extract the MetaData you require. The Instrumentation-API is not useable
in 1.4. And even with that, it requires to instrument before the class
is loaded, but may not be always the case.

>,  so a  class like:
>
> import pkg.Foo from "dir/lib.jar"
>
> Class Bar
> {
>    Bar()
>    {
>      def foo = new Foo()
>    }
> }
>
> would be compiled in byte code. something like:
>
> Class Bar
> {
>    void Bar()
>    {
>    }
>    static String[] __loadDynamicLibs = new String[]{"dir/lib.jar"}
> }
>
> and then before Groovy loads the class it would load/define the lib?

creating a String[] is not enough, who should load that lib? normally
the classloader would have to do that, but which classloader. We can't
be sure the ClassLoader used to load that class is a GroovyClassLoader.
And if not, what do we do then? Besides that the GroovyClassLoader would
always have to load such a lib. Normally the GroovyClassLoader isn't at
the top if the ClassLoaderTree. Normally there is an Applicationspecific
ClassLoader before it in case of embedding and a RootClassLoader in
other cases. The job to load a library is normally one for these two
above. How do you prevent loading already loaded classes a secound time?
Testing if the Class is already loaded is not enough, because you could
load a class that is not loaded and then later a ClassLoader higher in
the tree could load the class again because it can't know you have
already loaded it. Such things are leading to these nice problems where

assert foo.class == Foo.class

fils even if foo is an instance of Foo... but not the same Foo.

>> recursive? you mean not the whole dir, also subdirs? again I would
>> modify it a little
>> "dir/**.jar"
>
> Sounds Good - The more the merrier!

RootLoader can load directories, I have to take a look at it, but I
thought RootLoader would get the classpath from the command line. So it
should be no problem to load the whole directory. If it is a problem,
then it is a bug.

>> tell us the error message or the symptoms please ;)
>
> Ok here are my files:
>
> Here I am trying to load a groovy class in a groovlet:
>
> /groovy/WEB-INF/src/test/FooG.groovy:
> package test
> class FooG {
>    @Property bar
> }
>
> /groovy/exampleG.groovy:
> def foo = new test.FooG()
> foo.bar = "test"
> println foo.bar
>
> //in tomcat (http://localhost:8080/groovy/exampleG.groovy) produces:
> groovy.util.ScriptException: Could not parse script: /exampleG.groovy
> java.lang.RuntimeException: groovy.util.ScriptException: Could not  
> parse script: /exampleG.groovy
>     at groovy.servlet.GroovyServlet$1.call(GroovyServlet.java:139)
>     at org.codehaus.groovy.runtime.GroovyCategorySupport.use  
> (GroovyCategorySupport.java:151)
>     at groovy.servlet.GroovyServlet.service(GroovyServlet.java:144)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> ..............
> Caused by: groovy.util.ScriptException: Could not parse script: /
> exampleG.groovy
>     at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java:250)
>     at groovy.servlet.GroovyServlet$1.call(GroovyServlet.java:135)
>     ... 17 more
> Caused by: /exampleG.groovy: 1: unable to resolve class test.FooG
>   @ line 1, column 11.
> 1 Error
>
> If I then compile test.FooG so that there exists: WEB-INF/classes/
> test/FooG.class (and restart tomcat) I get the exact same Exception

ah ok... I remember I wanted to change GroovyClassLoader to use
getRessource instead of that strange directory lookup it does now.. I
think that would solve the problem.

> I then try to consume the groovy class in an Example servlet
> /groovy/WEB-INF/src/test/ExampleServlet.java:
>    protected void doGet(HttpServletRequest request,  HttpServletResponse
> response) throws ServletException, IOException
>    {
>      FooG foo = new test.FooG();
>      fooG.setBar("test FooG");
>      response.getWriter().println(foo.getBar());
>    }
>
> which gives me this Exception:
> java.lang.Error: Unresolved compilation problems:
>     FooG cannot be resolved to a type
>     test.FooG cannot be resolved to a type
>     fooG cannot be resolved
>
>     test.ExampleServlet.doGet(ExampleServlet.java:16)
>     javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
>     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>
> This tells me there is something wrong with the generated test/
> FooG.class, so I try to consume a .java class in my groovlet:
>
> /groovy/WEB-INF/src/test/FooJ.java (there is also a compiled class
> in /classes/test/FooJ.java):
> package test;
>
> class FooJ
> {
>    String bar;
>
>    public void setBar(String bar)
>    {
>      this.bar = bar;
>    }
>
>    public String getBar()
>    {
>      return bar;
>    }
> }
>
> /groovy/exampleJ.groovy:
> def foo = new test.FooJ()
> foo.bar = "test"
> println foo.bar
>
> //in tomcat (http://localhost:8080/groovy/exampleJ.groovy) i get this:
> ........
>     at java.lang.Thread.run(Thread.java:613)
> Caused by: groovy.util.ScriptException: Could not parse script: /
> exampleJ.groovy

/exampleJ ?

as I said, GCL does not use getRessource, it does use the directory. So
/ is your root directory! But Ok, I don't know what GroovyScriptEngine
does here.

[...]
> So I basically want to know what is the recommended way of
> 1) using a class defined in groovy, in a Groovlet or Servlet; and
> 2) using a class defined in WEB-INF/classes in a Groovlet
>
> If someone has working code that does the above can they send it to
> me and i will try it out..

IF really the GCL is used to load and find the class, then I answered
why it doesn't work.

> While on the subject i would like to propose another implicit  variable
> in the Groovlet: 'param' so we can use familiar JSP 2.0/el  syntax:
>
> println "${param.key}"

that's ok to me, öet us here other people. But I don't know what
varibales are predefined. I haven't looked much at the Groovlets.

bye blackdrag

Reply | Threaded
Open this post in threaded view
|

Re: Formal Framework please!

Alan Green-2
In reply to this post by mythz
Demis Bellot wrote:

>>
>> tell us the error message or the symptoms please ;)
>>
>
>
> Ok here are my files:
>
> Here I am trying to load a groovy class in a groovlet:
>
> /groovy/WEB-INF/src/test/FooG.groovy:
> package test
> class FooG {
>    @Property bar
> }
>
> /groovy/exampleG.groovy:
> def foo = new test.FooG()
> foo.bar = "test"
> println foo.bar

The class loader that finds things in WEB-INF is the servlet container's
class loader, which doesn't know about .groovy files.

> If I then compile test.FooG so that there exists: WEB-INF/classes/
> test/FooG.class (and restart tomcat) I get the exact same Exception

This works for me with Groovy jsr-04. Also, do you have all of the
Groovy libs on the servlet's classpath or the servlet container's
classpath? If you still don't have any luck, try posting a message to
the groovy-user list.

> So I basically want to know what is the recommended way of
> 1) using a class defined in groovy, in a Groovlet or Servlet; and
> 2) using a class defined in WEB-INF/classes in a Groovlet
>
> If someone has working code that does the above can they send it to
> me and i will try it out..

You will probably get a better response, if you ask this on the user
list :) but the second thing you tried, putting the class into
WEB-INF/classes is on the right track.

> While on the subject i would like to propose another implicit  variable
> in the Groovlet: 'param' so we can use familiar JSP 2.0/el  syntax:

Sure. Please raise a JIRA issue, so we don't forget this.

Reply | Threaded
Open this post in threaded view
|

Re: Formal Framework please!

mythz
In reply to this post by Jochen Theodorou
> And another thing... can you tell me why you don't want groovy to  
> compile foo.groovy when compiling bar.groovy?

compiling foo.groovy when compiling bar.groovy would be fine as long  
it allows you to develop groovy scripts/groovlets without needing to  
compile (i.e. feed the scripts to the groovy runtime) and include  
other groovy scripts.

> .... We can't be sure the ClassLoader used to load that class is a  
> GroovyClassLoader.  ....

I see your point

> ah ok... I remember I wanted to change GroovyClassLoader to use  
> getRessource instead of that strange directory lookup it does now..  
> I think that would solve the problem.

Sweet, cant wait for the patch :)

> that's ok to me, öet us here other people. But I don't know what  
> varibales are predefined. I haven't looked much at the Groovlets.

Feature Request logged at http://jira.codehaus.org/browse/GROOVY-1200

Cheers,
Demis


On 4 Jan 2006, at 23:24, Jochen Theodorou wrote:

> Demis Bellot schrieb:
>
>>> depends on what semantics you expect from this! Define it and we
>>> will see if it is a problem.
>> well basically i want to be able to re-use classes from another
>> groovy script, e.g.
>> foo.groovy:
>> package foo
>> class Foo {
>>    String niceUtil() {}
>> }
>> bar.groovy:
>> package bar
>> import foo.groovy //obvious reasons why this wont work
>> //perhaps, instead:
>> require "foo.groovy"
>> import foo.Foo
>> def foo = new Foo()
>> println foo.niceUtil()
>
> If I say require "foo.groovy" I still need to look into he file or  
> else I won't be able to tell what "Foo" means.
>
> And another thing... can you tell me why you don't want groovy to  
> compile foo.groovy when compiling bar.groovy?
>
> [...]
>>> I am sure you know a better name, but I really want to mark that.
>>> Mark it for the compiler and for the reader
>> I imagine it would be a dirty hack though i figured you would  
>> just  add some metadata to the class and before you load it, load  
>> its libs
>
> this requires that the class is loaded through the  
> GroovyClassLoader! We can't be sure about this. For exmaple if all  
> files are compiler and stored in a Database, then you have no  
> chance to parse the bytecode to extract the MetaData you require.  
> The Instrumentation-API is not useable in 1.4. And even with that,  
> it requires to instrument before the class is loaded, but may not  
> be always the case.
>
>> ,  so a  class like:
>> import pkg.Foo from "dir/lib.jar"
>> Class Bar
>> {
>>    Bar()
>>    {
>>      def foo = new Foo()
>>    }
>> }
>> would be compiled in byte code. something like:
>> Class Bar
>> {
>>    void Bar()
>>    {
>>    }
>>    static String[] __loadDynamicLibs = new String[]{"dir/lib.jar"}
>> }
>> and then before Groovy loads the class it would load/define the lib?
>
> creating a String[] is not enough, who should load that lib?  
> normally the classloader would have to do that, but which  
> classloader. We can't be sure the ClassLoader used to load that  
> class is a GroovyClassLoader. And if not, what do we do then?  
> Besides that the GroovyClassLoader would always have to load such a  
> lib. Normally the GroovyClassLoader isn't at the top if the  
> ClassLoaderTree. Normally there is an Applicationspecific  
> ClassLoader before it in case of embedding and a RootClassLoader in  
> other cases. The job to load a library is normally one for these  
> two above. How do you prevent loading already loaded classes a  
> secound time? Testing if the Class is already loaded is not enough,  
> because you could load a class that is not loaded and then later a  
> ClassLoader higher in the tree could load the class again because  
> it can't know you have already loaded it. Such things are leading  
> to these nice problems where
>
> assert foo.class == Foo.class
>
> fils even if foo is an instance of Foo... but not the same Foo.
>
>>> recursive? you mean not the whole dir, also subdirs? again I would
>>> modify it a little
>>> "dir/**.jar"
>> Sounds Good - The more the merrier!
>
> RootLoader can load directories, I have to take a look at it, but I  
> thought RootLoader would get the classpath from the command line.  
> So it should be no problem to load the whole directory. If it is a  
> problem, then it is a bug.
>
>>> tell us the error message or the symptoms please ;)
>> Ok here are my files:
>> Here I am trying to load a groovy class in a groovlet:
>> /groovy/WEB-INF/src/test/FooG.groovy:
>> package test
>> class FooG {
>>    @Property bar
>> }
>> /groovy/exampleG.groovy:
>> def foo = new test.FooG()
>> foo.bar = "test"
>> println foo.bar
>> //in tomcat (http://localhost:8080/groovy/exampleG.groovy) produces:
>> groovy.util.ScriptException: Could not parse script: /exampleG.groovy
>> java.lang.RuntimeException: groovy.util.ScriptException: Could  
>> not  parse script: /exampleG.groovy
>>     at groovy.servlet.GroovyServlet$1.call(GroovyServlet.java:139)
>>     at org.codehaus.groovy.runtime.GroovyCategorySupport.use  
>> (GroovyCategorySupport.java:151)
>>     at groovy.servlet.GroovyServlet.service(GroovyServlet.java:144)
>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>> ..............
>> Caused by: groovy.util.ScriptException: Could not parse script: /
>> exampleG.groovy
>>     at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java:
>> 250)
>>     at groovy.servlet.GroovyServlet$1.call(GroovyServlet.java:135)
>>     ... 17 more
>> Caused by: /exampleG.groovy: 1: unable to resolve class test.FooG
>>   @ line 1, column 11.
>> 1 Error
>> If I then compile test.FooG so that there exists: WEB-INF/classes/
>> test/FooG.class (and restart tomcat) I get the exact same Exception
>
> ah ok... I remember I wanted to change GroovyClassLoader to use  
> getRessource instead of that strange directory lookup it does now..  
> I think that would solve the problem.
>
>> I then try to consume the groovy class in an Example servlet
>> /groovy/WEB-INF/src/test/ExampleServlet.java:
>>    protected void doGet(HttpServletRequest request,  
>> HttpServletResponse response) throws ServletException, IOException
>>    {
>>      FooG foo = new test.FooG();
>>      fooG.setBar("test FooG");
>>      response.getWriter().println(foo.getBar());
>>    }
>> which gives me this Exception:
>> java.lang.Error: Unresolved compilation problems:
>>     FooG cannot be resolved to a type
>>     test.FooG cannot be resolved to a type
>>     fooG cannot be resolved
>>     test.ExampleServlet.doGet(ExampleServlet.java:16)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>> This tells me there is something wrong with the generated test/
>> FooG.class, so I try to consume a .java class in my groovlet:
>> /groovy/WEB-INF/src/test/FooJ.java (there is also a compiled class
>> in /classes/test/FooJ.java):
>> package test;
>> class FooJ
>> {
>>    String bar;
>>    public void setBar(String bar)
>>    {
>>      this.bar = bar;
>>    }
>>    public String getBar()
>>    {
>>      return bar;
>>    }
>> }
>> /groovy/exampleJ.groovy:
>> def foo = new test.FooJ()
>> foo.bar = "test"
>> println foo.bar
>> //in tomcat (http://localhost:8080/groovy/exampleJ.groovy) i get  
>> this:
>> ........
>>     at java.lang.Thread.run(Thread.java:613)
>> Caused by: groovy.util.ScriptException: Could not parse script: /  
>> exampleJ.groovy
>
> /exampleJ ?
>
> as I said, GCL does not use getRessource, it does use the  
> directory. So / is your root directory! But Ok, I don't know what  
> GroovyScriptEngine does here.
>
> [...]
>> So I basically want to know what is the recommended way of
>> 1) using a class defined in groovy, in a Groovlet or Servlet; and
>> 2) using a class defined in WEB-INF/classes in a Groovlet
>> If someone has working code that does the above can they send it to
>> me and i will try it out..
>
> IF really the GCL is used to load and find the class, then I  
> answered why it doesn't work.
>
>> While on the subject i would like to propose another implicit  
>> variable in the Groovlet: 'param' so we can use familiar JSP 2.0/
>> el  syntax:
>> println "${param.key}"
>
> that's ok to me, öet us here other people. But I don't know what  
> varibales are predefined. I haven't looked much at the Groovlets.
>
> bye blackdrag
>

Reply | Threaded
Open this post in threaded view
|

Re: Formal Framework please!

Jochen Theodorou
Demis Bellot schrieb:

[...]
>> ah ok... I remember I wanted to change GroovyClassLoader to use  
>> getRessource instead of that strange directory lookup it does now..  I
>> think that would solve the problem.
>
> Sweet, cant wait for the patch :)

sadly I am currently busy with bytecode related to scoping. I hope I can
finish this sunday, but it isn't sure as I don't know about all the
little püresent that are awaiting me ;)

bye blackdrag