Re: [json-lib-user] StringMetaClass Problem
Brought to you by:
aalmiray
From: Andres A. <aal...@ya...> - 2008-01-07 18:21:40
|
Hi Andrew, The code should work with 1.5.0, as a matter of fact a bug in DelegatingMetaClass was fixed to get it working. Perhaps something was changed again in 1.5.1, I'll give it a look and let you know. Cheers, Andres ------------------------------------------- http://jroller.com/aalmiray http://www.linkedin.com/in/aalmiray -- What goes up, must come down. Ask any system administrator. There are 10 types of people in the world: Those who understand binary, and those who don't. To understand recursion, we must first understand recursion. ----- Original Message ---- From: Andrew Strickland <str...@gm...> To: jso...@li... Sent: Monday, January 7, 2008 9:09:38 AM Subject: [json-lib-user] StringMetaClass Problem Hello, I'm having a problem using the JsonGroovyBuilder. I'm using Json-lib 2.2 and Groovy 1.5.1, they are declared in my POM like so: <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.2</version> <classifier>jdk15</classifier> </dependency> <dependency> <groupId> org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.5.1</version> </dependency> Here's the snippet from my groovy script where I try to do the json creation: def builder = new JsonGroovyBuilder(); if (searchResponse != null) { def orders = builder.orders{ for(ord in ords){ order{ tsrNumber = ord.getTsrNumber() tsoNumber = ord.getTsrNumber() ccsd = ord.getCcsdNumber() status = ord.getStatus() } } } } I get the following exception: ERROR [Groovy] - Servlet.service() for servlet Groovy threw exception java.lang.NoSuchMethodException: groovy.runtime.metaclass.java.lang.StringMetaCl ass.<init>( groovy.lang.MetaClassRegistry, java.lang.Class) at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.getConstructor(Unknown Source) at groovy.lang.MetaClassRegistry.getMetaClassFor (MetaClassRegistry.java: 205) at groovy.lang.MetaClassRegistry.getMetaClass(MetaClassRegistry.java:135 ) at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:118) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod (InvokerHelper. java:111) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Scrip tBytecodeAdapter.java:187) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.isCase(ScriptByteco deAdapter.java:715) at proxy.proxy(proxy.groovy:27) at gjdk.proxy_GroovyReflector.invoke(Unknown Source) at groovy.lang.MetaMethod.invoke(MetaMethod.java:115) at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassH elper.java:713) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurre ntN(ScriptBytecodeAdapter.java :97) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurre nt0(ScriptBytecodeAdapter.java:129) at proxy.run(proxy.groovy:15) at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java :378) at groovy.servlet.GroovyServlet$1.call(GroovyServlet.java:135) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategoryS upport.java:149) at groovy.servlet.GroovyServlet.service (GroovyServlet.java:144) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:213) at org.apache.catalina.core.StandardContextValve.invoke (StandardContextV alve.java:174) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav a:151) at org.apache.coyote.http11.Http11Processor.process (Http11Processor.java :874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p rocessConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket (PoolTcpEndpo int.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol lowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP ool.java:689) at java.lang.Thread.run(Unknown Source) I checked the json-lib source browser for StringMetaClass and noticed a difference between revision 1.1 and 1.2, you can see it here: http://json-lib.cvs.sourceforge.net/json-lib/json-lib/src/main/groovy/groovy/runtime/metaclass/java/lang/StringMetaClass.groovy?r1=1.1&r2=1.2. Notice that the constructor that took a MetaClassRegistry and Class is now gone...and that appears to be the constructor that Groovy is trying to instantiate. Anyone have any idea why this is happening, if there is a fix for it, or how I can get around it? ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |