ClassNotFoundException & GaelykBindings

97 views
Skip to first unread message

Nilovsky

unread,
Feb 8, 2012, 12:44:53 PM2/8/12
to Gaelyk
Hi all,

I have a class under src/main/groovy annotated with @GaelykBindings
annotation, however while trying to compile this class I receive a
weird ClassNotFoundException. Any clues? (the stacktrace follows)


:compileGroovy
[ant:groovyc] >>> a serious error occurred: javax/servlet/http/
HttpServletRequest
[ant:groovyc] >>> stacktrace:
[ant:groovyc] java.lang.NoClassDefFoundError: javax/servlet/http/
HttpServletRequest
[ant:groovyc] at java.lang.Class.getDeclaredMethods0(Native Method)
[ant:groovyc] at java.lang.Class.privateGetDeclaredMethods(Class.java:
2427)
[ant:groovyc] at java.lang.Class.getDeclaredMethods(Class.java:1791)
[ant:groovyc] at
org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:
328)
[ant:groovyc] at
org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:262)
[ant:groovyc] at
org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:
974)
[ant:groovyc] at
org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:
969)
[ant:groovyc] at
org.codehaus.groovy.ast.ClassNode.getSuperClass(ClassNode.java:963)
[ant:groovyc] at
org.codehaus.groovy.ast.ClassNode.getPlainNodeReference(ClassNode.java:
1362)
[ant:groovyc] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
[ant:groovyc] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
[ant:groovyc] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
[ant:groovyc] at java.lang.reflect.Method.invoke(Method.java:597)
[ant:groovyc] at
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:
90)
[ant:groovyc] at
groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
[ant:groovyc] at groovy.lang.MetaClassImpl
$GetBeanMethodMetaProperty.getProperty(MetaClassImpl.java:3465)
[ant:groovyc] at
org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:
61)
[ant:groovyc] at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:
227)
[ant:groovyc] at
groovyx.gaelyk.GaelykBindingsTransformation.makeServiceGetter(GaelykBindingsTransformation.groovy:
114)
[ant:groovyc] at
groovyx.gaelyk.GaelykBindingsTransformation.addGetterIfNotExists(GaelykBindingsTransformation.groovy:
109)
[ant:groovyc] at groovyx.gaelyk.GaelykBindingsTransformation.this
$2$addGetterIfNotExists(GaelykBindingsTransformation.groovy)
[ant:groovyc] at groovyx.gaelyk.GaelykBindingsTransformation$this
$2$addGetterIfNotExists.callCurrent(Unknown Source)
[ant:groovyc] at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:
46)
[ant:groovyc] at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:
133)
[ant:groovyc] at
groovyx.gaelyk.GaelykBindingsTransformation.visit(GaelykBindingsTransformation.groovy:
90)
[ant:groovyc] at
org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:
129)
[ant:groovyc] at
org.codehaus.groovy.transform.ASTTransformationVisitor
$2.call(ASTTransformationVisitor.java:172)
[ant:groovyc] at
org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:
964)
[ant:groovyc] at
org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:
549)
[ant:groovyc] at
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:
527)
[ant:groovyc] at
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:
504)
[ant:groovyc] at
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:
483)
[ant:groovyc] at
org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:
60)
[ant:groovyc] at
org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:
216)
[ant:groovyc] at
org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:
149)
[ant:groovyc] at
org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:
179)
[ant:groovyc] at
org.codehaus.groovy.ant.FileSystemCompilerFacade.main(FileSystemCompilerFacade.java:
27)
[ant:groovyc] Caused by: java.lang.ClassNotFoundException:
javax.servlet.http.HttpServletRequest
[ant:groovyc] at java.net.URLClassLoader$1.run(URLClassLoader.java:
202)
[ant:groovyc] at java.security.AccessController.doPrivileged(Native
Method)
[ant:groovyc] at
java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[ant:groovyc] at java.lang.ClassLoader.loadClass(ClassLoader.java:
307)
[ant:groovyc] at sun.misc.Launcher
$AppClassLoader.loadClass(Launcher.java:301)
[ant:groovyc] at java.lang.ClassLoader.loadClass(ClassLoader.java:
248)
[ant:groovyc] ... 37 more

Guillaume Laforge

unread,
Feb 8, 2012, 2:39:29 PM2/8/12
to gae...@googlegroups.com
Hi Nilovsky,

Do you have a concrete full-blown example showing this?

Guillaume


--
You've received this message because you've subscribed to the Gaelyk Google Group.
To send an email to the group, please write to: gae...@googlegroups.com
To unsuscribe from this group: gaelyk+un...@googlegroups.com
To show more options: http://groups.google.fr/group/gaelyk?hl=en



--
Guillaume Laforge
Groovy Project Manager
SpringSource, a division of VMware


Nilovsky

unread,
Feb 9, 2012, 1:33:52 PM2/9/12
to Gaelyk
Hi Guillaume,

I got this route forwarding the request to a groovlet under war/WEB-
INF/groovy/myGroovlet.groovy. Both the route and groovlet work just
fine, however I want somehow inject a service on this same groovlet.
So I wrote this groovy class (src/main/groovy, no packaged defined)
with the @GaelykBindings annotation in order to get it 'visible'
within my groovlet. But as I mentioned earlier, I got this
ClassNotFoundException.

I don't know if I got this GaelykBinding idea correctly. In my
understanding, the would be available the same way datastore,
defaultQueue and some other GAE Services do. Example:

@GaelykBinding
class RankingService {
def rank( Player player ) {
//do something with player
}
}

Groovlet code:

def player = ((params.player) as Key).get()

rankingService.rank(player)


Thank you.

Nilovsky
> Twitter: @glaforge <http://twitter.com/glaforge>
> Google+:http://gplus.to/glaforge

Guillaume Laforge

unread,
May 25, 2012, 10:11:46 AM5/25/12
to gae...@googlegroups.com
Resurecting this old thread...

It seems at least that something's missing.

The rankingService instance has to be defined somewhere, and injected
in the binding (normally, that's the job of a plugin to do that).
It's not because a class is annotated with @GaelykBindings that it's
going to be put into the binding of groovlets and templates.
@GaelykBindings injects into the service class various services, but
it's not for injecting the annotated class into the binding of
groovlets and templates.

Then, the stacktrace more specifically seems to indicate that you are
using somehow the servlet request.
But @GaelykBinding doesn't innject the request in the class, as it's
only really innjecting things like the GAE services, etc.

Guillaume
Social: @glaforge / Google+

Vladimír Oraný

unread,
May 25, 2012, 3:31:20 PM5/25/12
to gae...@googlegroups.com
adding Servlet API on the classpath should fix the problem.

2012/5/25 Guillaume Laforge <glaf...@gmail.com>

Gundsambuu Natsagdorj

unread,
Aug 29, 2012, 1:45:09 AM8/29/12
to gae...@googlegroups.com
Hi Guillaume, 

I got this kind of problem when i trying to use GaelykBindings service.
Please help to figure out what i do wrong.

groovy.lang.MissingPropertyException: No such property: baseService for class: SimpleTemplateScript6
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
at SimpleTemplateScript6.run(SimpleTemplateScript6.groovy:22) ....

// Here is the Service that injected

package mn.xenon.service 
import groovyx.gaelyk.GaelykBindings  

@GaelykBindings
class BaseService { 
def list(params) { 
return datastore.execute {
select all from 'Post' sort desc by created limit params.limit?:10
}
}

// on the Groovlet :

def list = baseService.list([limit:2])

 





Guillaume Laforge

unread,
Aug 29, 2012, 4:33:00 AM8/29/12
to gae...@googlegroups.com
Hello,

@GaelykBindings add the various GAE services and other Gaelyk variables into the bindings of Groovlets and Templates.
But it doesn't add your own custom variables into the binding, so it won't add baseService in the binding.

For adding baseService in the binding, you should create a Gaelyk plugin, and add a section with binding { baseService = new BaseService() } in the plugin descriptor.

Please have a look at the documentation related to plugins.

As a side note, we could think of some kind of built-in dependency injection, with perhaps an @Inject annotation or something like that.
But it feels a lot like reinventing the wheel, where people could actually use better solutions like Spring or Guice -- which is already what some Gaelyk users are already doing anyway.

Guillaume

--
You've received this message because you've subscribed to the Gaelyk Google Group.
To send an email to the group, please write to: gae...@googlegroups.com
To unsuscribe from this group: gaelyk+un...@googlegroups.com
To show more options: http://groups.google.fr/group/gaelyk?hl=en

Gundsambuu Natsagdorj

unread,
Aug 29, 2012, 4:35:46 PM8/29/12
to gae...@googlegroups.com
Thanks for your help. ;)
Reply all
Reply to author
Forward
0 new messages