(I'm using Pico 1.0-SNAPSHOT, Pico extras 1.0-alpha-1-SNAPSHOT, WebWork
2.0-beta2 and XWork 1.0-beta2)

I modified PicoActionInvocation to validate my assumptions and did:

public class PicoActionInvocation extends DefaultActionInvocation implements
KeyConstants {

    <snip/>

/**
 * Copied and adapted from DefaultActionInvocation.createContextMap().
 */
    private OgnlValueStack getStackSafely() {
        OgnlValueStack stack = getStack();
        if (stack != null) return stack;

        if ((extraContext != null) &&
(extraContext.containsKey(ActionContext.VALUE_STACK))) {
            stack = (OgnlValueStack)
extraContext.get(ActionContext.VALUE_STACK);

            if (stack == null) {
                throw new IllegalStateException("There was a null Stack set
into the extra params.");
            }
        } else {
            // create the value stack
            // this also adds the ValueStack to its context
            stack = new OgnlValueStack();
        }

        // put extraContext in
        if (extraContext != null) {
            stack.getContext().putAll(extraContext);
        }

        return stack;
    }

    private MutablePicoContainer getParentContainer() {
        HttpServletRequest request = (HttpServletRequest)
getStackSafely().getContext().get(WebWorkStatics.HTTP_REQUEST);
        ObjectReference ref = new RequestScopeObjectReference(request,
REQUEST_CONTAINER);
        return (MutablePicoContainer) ref.get();
    }
}

With the above hack, it works. The clean way IMHO would be to break down
createContextMap() in DefaultActionInvocation
so that we have a way in PicoActionInvocation to get (and create if
necessary) the stack without populating the context. Anyway...


Still when the web container shuts down (I use tomcat 4.1.29), I get another
exception:

java.lang.RuntimeException: Cannot shutdown container
        at
org.picoextras.integrationkit.DefaultLifecycleContainerBuilder.killContainer
(DefaultLifecycleContainerBuilder.java:57)
        at
org.picoextras.servlet.ServletContainerListener.sessionDestroyed(ServletCont
ainerListener.java:74)
        at
org.apache.catalina.session.StandardSession.expire(StandardSession.java:659)
        at
org.apache.catalina.session.StandardSession.expire(StandardSession.java:608)
        at
org.apache.catalina.session.StandardManager.processExpires(StandardManager.j
ava:793)
        at
org.apache.catalina.session.StandardManager.run(StandardManager.java:870)
        at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.IllegalStateException: getAttribute: Session already
invalidated
        at
org.apache.catalina.session.StandardSession.getAttribute(StandardSession.jav
a:954)
        at
org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessi
onFacade.java:171)
        at
org.picoextras.servlet.SessionScopeObjectReference.get(SessionScopeObjectRef
erence.java:36)
        at
org.picoextras.integrationkit.DefaultLifecycleContainerBuilder.killContainer
(DefaultLifecycleContainerBuilder.java:46)
        ... 6 more


This makes me ask id anybody has successfully used PicoContainer and XWork
together using the Pico integration jars.
Anyone?

Thanks,
Vincent

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Vincent
> Tence
> Sent: Thursday, November 27, 2003 11:45 AM
> To: [EMAIL PROTECTED]
> Subject: [picocontainer-dev] Pico-WW2/XWork integration generates NPE
>
>
> Hi all,
>
> I'm trying to use Pico container in a WW2/XWork environment.
>
> <disclaimer>First experience with both, so I may be facing a trivial
> issue</disclaimer>
>
> I'm getting a NPE in PicoActionInvocation.getParentContainer() because
> getStack() happens to return null.
>
> Here's how I setup my WW2 environment:
>
> - Added a listener for Pico in web.xml:
>     <!-- PicoContainer Hook -->
>     <listener>
>
> <listener-class>org.picoextras.webwork2.WebWork2ContainerListener<
> /listener-
> class>
>     </listener>
>
> - Replaced default WW2 Servlet Dispatcher in web.xml with:
>
>     <servlet>
>         <servlet-name>webwork</servlet-name>
>         <!-- PicoContainer enabled dispatcher -->
>
> <servlet-class>org.picoextras.webwork2.PicoServletDispatcher</serv
> let-class>
>     </servlet>
>
> - Defined my ContainerAssembler in web.xml:
>
>     <context-param>
>       <param-name>assembler</param-name>
>       <param-value>mypackage.MyContainerAssembler</param-value>
>     </context-param>
>
> So far so good, my assembler is called and sets up the
> PicoContainer (did it
> easy first):
>
>     public void assembleContainer(MutablePicoContainer
> mutablePicoContainer,
>                                   String string) {
>         mutablePicoContainer.registerComponentImplementation(
>                 SomeService.class,
>                 SomeServiceImpl.class);
>     }
>
> Now my XWork Action depends on SomeService, but can't be instanciated. It
> seems that the ognl value stack is not ready when
> PicoActionInvocation.getParentContainer() is called, resulting in a NPE.
>
> I looked briefly at the current DefaultActionInvocation code (in
> CVS) and it
> looks like createAction() is called at construction time, before the stack
> is ready. And PicoActionInvocation uses the stack in createAction(). As I
> said, I just starting using both Pico and WW2, so I may be totally
> off-track.
>
>
> Anyone experienced the same problem and can help?
>
> Thanks,
> - Vincent
>
> _______________________________________________
> picocontainer-dev mailing list
> [EMAIL PROTECTED]
> http://lists.codehaus.org/mailman/listinfo/picocontainer-dev
>



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to