[jira] Commented: (NANO-39) groovy scripted nanocontainer fails in servlet context

jira-yCVjj/[email protected] Thu, 19 Feb 2004 23:22:09 -0500 (EST)
Newsgroups gmane.comp.java.nanocontainer.devel
Message-ID <[email protected]>
The following comment has been added to this issue:

     Author: Jacob Kjome
    Created: Thu, 19 Feb 2004 11:22 PM
       Body:
Yep, I actually figured this out on my own after all the changes and hadn't gotten around to mentioning that here.  However, I am also seeing another issue where when using System.out.println() anywhere in the script and running under Tomcat (not sure if the issue happens in other containers?), I get the following stack trace.  This wasn't happening when the script had to be a class that implemented the method buildContainer(parent, assemblyScope).  I was able to System.out to my heart's desire at that time.

I'm not sure whether this should be considered a Nanocontainer issue or a Groovy project issue.  If it is a Groovy project issue, please close this and I'll report it in Groovy's Jira.  Anyway, here's the stack trace....

2004-02-19 22:05:48 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.NoClassDefFoundError: org/apache/tomcat/util/log/SystemLogHandler
	at org.apache.tomcat.util.log.SystemLogHandler$GroovyReflector.invoke(SystemLogHandler$GroovyReflector.java)
	at groovy.lang.MetaMethod.invoke(MetaMethod.java:84)
	at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:830)
	at groovy.lang.MetaClass.invokeMethod(MetaClass.java:242)
	at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:130)
	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:101)
	at nanocontainer.run(nanocontainer.groovy:15)
	at org.nanocontainer.script.groovy.GroovyContainerBuilder.createContainerFromScript(GroovyContainerBuilder.java:57)
	at org.nanocontainer.script.ScriptedContainerBuilder.createContainer(ScriptedContainerBuilder.java:37)
	at org.nanocontainer.integrationkit.LifecycleContainerBuilder.buildContainer(LifecycleContainerBuilder.java:24)
	at org.nanocontainer.servlet.ServletRequestContainerLauncher.startContainer(ServletRequestContainerLauncher.java:48)
	at org.nanocontainer.servlet.ServletRequestContainerFilter.doFilter(ServletRequestContainerFilter.java:36)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
	at java.lang.Thread.run(Thread.java:534)


Jake
---------------------------------------------------------------------
View this comment:
  http://jira.codehaus.org/secure/ViewIssue.jspa?key=NANO-39&page=comments#action_16971

---------------------------------------------------------------------
View the issue:
  http://jira.codehaus.org/secure/ViewIssue.jspa?key=NANO-39

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: NANO-39
    Summary: groovy scripted nanocontainer fails in servlet context
       Type: Bug

     Status: Unassigned
   Priority: Major

 Original Estimate: Unknown
 Time Spent: Unknown
  Remaining: Unknown

    Project: NanoContainer
 Components: 
             Core
   Versions:
             1.0-beta-1

   Assignee: 
   Reporter: Jacob Kjome

    Created: Fri, 13 Feb 2004 1:51 AM
    Updated: Thu, 19 Feb 2004 11:22 PM
Environment: servlet container, scripting of nanocontainer done with Groovy

Description:
When setting up the nanocontainer servlet in web.xml using the context-param "nanocontainer.groovy", it only seems to work for the first container that is configured, or, the first compositionScope.  If any other scope is provided such as a ServletRequest or HttpSession, it fails with the following message...

"Caused by: groovy.lang.MissingMethodException: No such method: buildContainer for class: nanocontainer with arguments: [org.picocontainer.defaults.DefaultPicoContainer-Le89R2mpRr8@public.gmane.org, org.apache.coyote.tomcat5.CoyoteRequestFacade@952905]"

I know it is working the for the first container (in the ServletContext compositionScope) because I print out the compositionScope as soon as the "buildContainer" method is entered and it says...

"compositionScope is: org.apache.catalina.core.ApplicationContextFacade-m6hyCi5e6VU@public.gmane.org"

Here is the script...

class DemoBuilder {
    buildContainer(parent, compositionScope) {
        System.out.println("compositionScope is: " + compositionScope);
        pico = new org.picocontainer.defaults.DefaultPicoContainer(parent)
        if (compositionScope instanceof javax.servlet.ServletRequest) {
            System.out.println("I got here to register a component in the servlet request scope!!!!")
            pico.registerComponentImplementation("util", SomeRequestUtil.class)
        }
        else if (compositionScope instanceof javax.servlet.http.HttpSession) {
            System.out.println("I got here to register a component in the servlet session scope!!!!")
            pico.registerComponentImplementation("counter", SomeCounter.class)
        }
        else if (compositionScope instanceof javax.servlet.ServletContext) {
            //nothing to do for now
        }
        else {
            //nothing to do for now
        }
        return pico
    }
}


Here's the full stack trace....


org.nanocontainer.integrationkit.PicoCompositionException
	at org.nanocontainer.script.groovy.GroovyContainerBuilder.createContainer(GroovyContainerBuilder.java:57)
	at org.nanocontainer.integrationkit.LifecycleContainerBuilder.buildContainer(LifecycleContainerBuilder.java:25)
	at org.nanocontainer.servlet.ServletRequestContainerLauncher.startContainer(ServletRequestContainerLauncher.java:48)
	at org.nanocontainer.servlet.ServletRequestContainerFilter.doFilter(ServletRequestContainerFilter.java:36)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
	at java.lang.Thread.run(Thread.java:534)
Caused by: groovy.lang.MissingMethodException: No such method: buildContainer for class: nanocontainer with arguments: [org.picocontainer.defaults.DefaultPicoContainer-Le89R2mpRr8@public.gmane.org, org.apache.coyote.tomcat5.CoyoteRequestFacade@952905]
	at groovy.lang.MetaClass.invokeStaticMethod(MetaClass.java:291)
	at groovy.lang.MetaClass.invokeMethod(MetaClass.java:247)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:765)
	at groovy.lang.MetaClass.invokeMethod(MetaClass.java:214)
	at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:130)
	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:98)
	at nanocontainer.invokeMethod(nanocontainer.groovy)
	at org.nanocontainer.script.groovy.GroovyContainerBuilder.createContainer(GroovyContainerBuilder.java:55)
	... 27 more


Jake


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira