jastrachan | 12 Aug 09:11 2004
Picon

Re: Struts-bsf and groovy

There seems to be an issue with the byte code generated reflectors,  
though I'm not sure yet what the issue is.

One quick workaround is to call this before you invoke the groovy  
scripts...

groovy.lang.MetaClass.useReflection(true);

which will disable the use of the bytecode generated reflectors and use  
reflection instead.

On 11 Aug 2004, at 21:43, Mark Porter wrote:
> Hello All,
>
> I've been playing around with Struts-Bsf (a way to write struts  
> actions in any bsf language) and seem to be encountering problems  
> trying to access some of the standard 'scripting objects' like  
> session/request and response.  For example the following groovy action  
> code:
>
> session.setAttribute('user',aUser)
>
>
> Produces the following stack trace (using groovy beta 6 and tried beta  
> 7 snapshot, struts 1.1 on tomcat 4.1.30)
>
> java.lang.NoClassDefFoundError:  
> org/apache/catalina/session/StandardSessionFacade
> 	at  
> gjdk.org.apache.catalina.session.StandardSessionFacade_GroovyReflector. 
> invoke(StandardSessionFacade_GroovyReflector.java)
> 	at groovy.lang.MetaMethod.invoke(MetaMethod.java:110)
> 	at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:1398)
> 	at groovy.lang.MetaClass.invokeMethod(MetaClass.java:319)
> 	at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:143)
> 	at  
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.ja 
> va:106)
> 	at  
> C__eclipse_workspace_DAA_2_Prototype_WebContent_WEB_INF_scripts_logon.r 
> un(C__eclipse_workspace_DAA_2_Prototype_WebContent_WEB_INF_scripts_logo 
> n.groovy:16)
> 	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:462)
> 	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:416)
> 	at org.codehaus.groovy.bsf.GroovyEngine.exec(GroovyEngine.java:162)
> 	at org.apache.bsf.BSFManager$6.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at org.apache.bsf.BSFManager.exec(Unknown Source)
> 	at org.twdata.struts.ScriptAction.execute(ScriptAction.java:184)
> 	at  
> org.apache.struts.action.RequestProcessor.processActionPerform(RequestP 
> rocessor.java:484)
> 	at  
> org.apache.struts.action.RequestProcessor.process(RequestProcessor.java 
> :274)
> 	at  
> org.apache.struts.action.ActionServlet.process(ActionServlet.java: 
> 1482)
> 	at  
> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at  
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic 
> ationFilterChain.java:247)
> 	at  
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil 
> terChain.java:193)
> 	at  
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal 
> ve.java:256)
> 	at  
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. 
> invokeNext(StandardPipeline.java:643)
> 	at  
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 
> 480)
> 	at  
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> 	at  
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextVal 
> ve.java:191)
> 	at  
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. 
> invokeNext(StandardPipeline.java:643)
> 	at  
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 
> 480)
> 	at  
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> 	at  
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java: 
> 2422)
> 	at  
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav 
> a:180)
> 	at  
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. 
> invokeNext(StandardPipeline.java:643)
> 	at  
> org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherV 
> alve.java:171)
> 	at  
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. 
> invokeNext(StandardPipeline.java:641)
> 	at  
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav 
> a:163)
> 	at  
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. 
> invokeNext(StandardPipeline.java:641)
> 	at  
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 
> 480)
> 	at  
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> 	at  
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve 
> .java:174)
> 	at  
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. 
> invokeNext(StandardPipeline.java:643)
> 	at  
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 
> 480)
> 	at  
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> 	at  
> org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java: 
> 199)
> 	at  
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java: 
> 828)
> 	at  
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process 
> Connection(Http11Protocol.java:700)
> 	at  
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java: 
> 584)
> 	at  
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPoo 
> l.java:683)
> 	at java.lang.Thread.run(Thread.java:534)
>
> Anyone encounter this before? Anyone able to help ascertain a cause of  
> this problem?
>
>
> Thanks much!
>
> Mark
>
> Mark D. Porter
> Application Architect
> OnX Enterprise Solutions Inc.
> 905.881.4414 x2842
> 1.800.663.6699
> mark.porter@...
>  
>
>
>

James
-------
http://radio.weblogs.com/0112098/


Gmane