There are two things you need to do: 1) Make sure that component interceptor is in your stack. You need to do this using WebWork or just XWork no matter what. 2) If you aren't using WebWork, take a look at the LifecycleListener classes in WebWork to get an idea how the three scopes are constructing a DefaultComponentManager.
If you only want one scope, just create a DCM, dump it in a static method, and then make sure that the DCM is in the ActionContext where the component interceptor expects it. Patrick > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > VisualJeff > Sent: Thursday, February 19, 2004 5:19 PM > To: [EMAIL PROTECTED] > Subject: Re: [OS-webwork] xwork and components and NullPointerExceptions > > But what if I'm not using a web container just xwork? > > Jeff > > At 02:54 PM 2/19/2004 -0800, you wrote: > >do you have these listeners and filters setup in your web.xml? > > > > <filter> > > <filter-name>container</filter-name> > > > ><filter- > class>com.opensymphony.webwork.lifecycle.RequestLifecycleFilter</filter- > class> > > </filter> > > > > <filter-mapping> > > <filter-name>container</filter-name> > > <url-pattern>/*</url-pattern> > > </filter-mapping> > > > > <listener> > > > ><listener- > class>com.opensymphony.webwork.lifecycle.ApplicationLifecycleListener</l is > tener-class> > > </listener> > > > > <listener> > > > ><listener- > class>com.opensymphony.webwork.lifecycle.SessionLifecycleListener</liste ne > r-class> > > </listener> > > > > > >Gilbert, Jeffrey wrote: > > > >>It looks to me as if xwork is not loading my component? > >> > >><components> > >> > >> <component> > >> > >> <scope>application</scope> > >> > >> <class>com.gilbert.providers.impl.TestProviderImpl</class> > >> > >> <enabler>com.gilbert.providers.TestProviderAware</enabler> > >> > >> </component> > >> > >></components> > >> > >> > >>My action is implements TestProviderAware and my xwork.xml implements > the > >>components interceptor (in the defaultStack). > >> > >><interceptor name="component" > >>class="com.opensymphony.xwork.interceptor.component.ComponentIntercept or > " /> > >> > >><interceptor-stack name="defaultStack"> > >> > >><interceptor-ref name="component"/> > >> > >> <interceptor-ref name="model-driven"/> > >> > >> <interceptor-ref name="static-params"/> > >> > >> <interceptor-ref name="params"/> > >> > >></interceptor-stack> > >> > >> > >>So why when I try to invoke a method in my component am I receiving a > >>NullPointerException? > >>package com.gilbert; > >> > >>import com.opensymphony.xwork.ActionSupport; > >> > >>import com.opensymphony.xwork.ModelDriven; > >> > >>import com.gilbert.models.Person; > >> > >>import com.gilbert.providers.TestProviderAware; > >> > >>import com.gilbert.providers.TestProvider; > >> > >>import org.apache.commons.logging.LogFactory; > >> > >>import org.apache.commons.logging.Log; > >> > >>/** > >> > >> * <p>Testing Components in xwork</p> > >> > >> * > >> > >> * Created by: > >> > >> * User: JG > >> > >> * Date: Feb 12, 2004 > >> > >> * Time: 8:31:47 PM > >> > >> */ > >> > >>public class HelloWorld extends ActionSupport implements ModelDriven, > >>TestProviderAware { > >> > >> private static Log log = LogFactory.getLog(HelloWorld.class); > >> > >> private Person person = new Person(); > >> > >> private String greeting; > >> > >> private TestProvider testProvider; > >> > >> public String getGreeting() { > >> > >> return this.greeting; > >> > >> } > >> > >> public String execute() throws Exception { > >> > >> if (log.isDebugEnabled()) log.debug("execute called"); > >> > >> testProvider.testMethod("testMethod in testProvider called!"); > >> > >> greeting = "Hello, " + person.getName(); > >> > >> return this.SUCCESS; > >> > >> } > >> > >> public Object getModel() { > >> > >> return this.person; > >> > >> } > >> > >> public void setTestProvider(TestProvider testProvider) { > >> > >> this.testProvider = testProvider; > >> > >> } > >> > >>} > >> > >> > >>What am I doing wrong??? > >> > >>Thanks, > >> > >>Jeff > > > > > > > >------------------------------------------------------- > >SF.Net is sponsored by: Speed Start Your Linux Apps Now. > >Build and deploy apps & Web services for Linux with > >a free DVD software kit from IBM. Click Now! > >http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > >_______________________________________________ > >Opensymphony-webwork mailing list > >[EMAIL PROTECTED] > >https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > Opensymphony-webwork mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork