|
Hi all,
I'm trying to create a very simple plugin (in grails 2.0.3), currently consisting of a class and a script. The class is located in 'src/groovy/com/foo/MyClass.groovy', and the script looks like this:
import com.foo.MyClass includeTargets << grailsScript("_GrailsInit")
target(main: "The description of the script goes here!") { def x = new MyClass()
} setDefaultTarget(main) However, when running this, I get a NoClassDefFoundError:
Erik-Pragts-MacBook-Pro:grails-notes erikp$ grails notes --stacktrace | Environment set to development....
| Error Error executing script Notes: com.foo.MyClass (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.) java.lang.NoClassDefFoundError: com.foo.MyClass
at Notes$_run_closure1.class$(Notes) at Notes$_run_closure1.$get$$class$com$foo$MyClass(Notes)
at Notes$_run_closure1.doCall(Notes:6) ...etc. What am I missing here?? Thanks, Erik |
|
Hi Erik,
In a Gant script you'll need to use classLoader.loadClass('my.Class') && depending on compile task. Seb On Wed, May 30, 2012 at 10:51 AM, Erik Pragt <[hidden email]> wrote: > Hi all, > > I'm trying to create a very simple plugin (in grails 2.0.3), currently > consisting of a class and a script. The class is located in > 'src/groovy/com/foo/MyClass.groovy', and the script looks like this: > > import com.foo.MyClass > > includeTargets << grailsScript("_GrailsInit") > > target(main: "The description of the script goes here!") { > def x = new MyClass() > } > > setDefaultTarget(main) > > However, when running this, I get a NoClassDefFoundError: > > Erik-Pragts-MacBook-Pro:grails-notes erikp$ grails notes --stacktrace > | Environment set to development.... > | Error Error executing script Notes: com.foo.MyClass (NOTE: Stack trace has > been filtered. Use --verbose to see entire trace.) > java.lang.NoClassDefFoundError: com.foo.MyClass > at Notes$_run_closure1.class$(Notes) > at Notes$_run_closure1.$get$$class$com$foo$MyClass(Notes) > at Notes$_run_closure1.doCall(Notes:6) > ...etc. > > What am I missing here?? > > Thanks, > > Erik > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Hi Sebas,
Thanks for the quick reply. I tried it, and it still fails: includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript('_GrailsPackage') target(main: "The description of the script goes here!") {
depends(checkVersion, compile) def x = classLoader.loadClass('test.MyClass')
println x } setDefaultTarget(main)
Caused by: Erik-Pragts-MacBook-Pro:todo-test erikp$ grails clean; grails notes | Application cleaned.
| Compiling 38 source files | Compiling 9 source files.
| Environment set to development..... | Error Error executing script Notes: java.lang.ClassNotFoundException: test.MyClass (Use --stacktrace to see the full trace)
What am I missing here? Thanks, Erik On Wed, May 30, 2012 at 10:56 AM, Sebastien Blanc <[hidden email]> wrote: Hi Erik, |
|
Hum,
You should ask Stephane Maldini about it, he was the one who provided the snippet I show you but to be honest I was never able to test it but when I saw your message it remembered my issue. Seb On Wed, May 30, 2012 at 11:25 AM, Erik Pragt <[hidden email]> wrote: > Hi Sebas, > > Thanks for the quick reply. I tried it, and it still fails: > > includeTargets << grailsScript("_GrailsInit") > includeTargets << grailsScript('_GrailsPackage') > > target(main: "The description of the script goes here!") { > depends(checkVersion, compile) > > def x = classLoader.loadClass('test.MyClass') > > println x > } > > setDefaultTarget(main) > > Caused by: > > Erik-Pragts-MacBook-Pro:todo-test erikp$ grails clean; grails notes > | Application cleaned. > | Compiling 38 source files > > | Compiling 9 source files. > | Environment set to development..... > | Error Error executing script Notes: java.lang.ClassNotFoundException: > test.MyClass (Use --stacktrace to see the full trace) > > What am I missing here? Thanks, > > Erik > > > > On Wed, May 30, 2012 at 10:56 AM, Sebastien Blanc <[hidden email]> > wrote: >> >> Hi Erik, >> In a Gant script you'll need to use classLoader.loadClass('my.Class') >> && depending on compile task. >> Seb >> >> >> On Wed, May 30, 2012 at 10:51 AM, Erik Pragt <[hidden email]> wrote: >> > Hi all, >> > >> > I'm trying to create a very simple plugin (in grails 2.0.3), currently >> > consisting of a class and a script. The class is located in >> > 'src/groovy/com/foo/MyClass.groovy', and the script looks like this: >> > >> > import com.foo.MyClass >> > >> > includeTargets << grailsScript("_GrailsInit") >> > >> > target(main: "The description of the script goes here!") { >> > def x = new MyClass() >> > } >> > >> > setDefaultTarget(main) >> > >> > However, when running this, I get a NoClassDefFoundError: >> > >> > Erik-Pragts-MacBook-Pro:grails-notes erikp$ grails notes --stacktrace >> > | Environment set to development.... >> > | Error Error executing script Notes: com.foo.MyClass (NOTE: Stack trace >> > has >> > been filtered. Use --verbose to see entire trace.) >> > java.lang.NoClassDefFoundError: com.foo.MyClass >> > at Notes$_run_closure1.class$(Notes) >> > at Notes$_run_closure1.$get$$class$com$foo$MyClass(Notes) >> > at Notes$_run_closure1.doCall(Notes:6) >> > ...etc. >> > >> > What am I missing here?? >> > >> > Thanks, >> > >> > Erik >> > >> > >> > >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by Erik Pragt-3
> Erik-Pragts-MacBook-Pro:todo-test erikp$ grails clean; grails notes
> | Application cleaned. > | Compiling 38 source files > > | Compiling 9 source files. > | Environment set to development..... > | Error Error executing script Notes: java.lang.ClassNotFoundException: > test.MyClass (Use --stacktrace to see the full trace) > > What am I missing here? Thanks, Verify that target/classes/test/MyClass.class exists. Best guess is that it doesn't. By the way, is this when you run the script from within the plugin project or when you run it from an application that has the plugin installed? -- Peter Ledbrook Grails Advocate SpringSource - A Division of VMware --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
On May 30, 2012, at 5:33 PM, Peter Ledbrook wrote: >> Erik-Pragts-MacBook-Pro:todo-test erikp$ grails clean; grails notes >> | Application cleaned. >> | Compiling 38 source files >> >> | Compiling 9 source files. >> | Environment set to development..... >> | Error Error executing script Notes: java.lang.ClassNotFoundException: >> test.MyClass (Use --stacktrace to see the full trace) >> >> What am I missing here? Thanks, > > Verify that target/classes/test/MyClass.class exists. Best guess is > that it doesn't. By the way, is this when you run the script from > within the plugin project or when you run it from an application that > has the plugin installed? > Thanks for the reply. It seems to be working a little bit now, but only half. I can execute the script now from the main project, when loading the class using 'def x = classLoader.loadClass('test.MyClass')' However, when I execute the script from my test project, which is located in 'test/projects/my-project', I still get the no class def found error. I've attached the project. When you run 'grails notes' from the main project, it works, but if you run 'grails notes' from the test/projects dir, I have no such luck. Thanks again for the help, much appreciated! Erik > -- > Peter Ledbrook > Grails Advocate > SpringSource - A Division of VMware > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
