using CompositeActionMapper

View: New views
6 Messages — Rating Filter:   Alert me  

using CompositeActionMapper

by Allen Lee-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey there,

I'm trying to get the CompositeActionMapper working with Struts 2.1.2
(combining the Restful2ActionMapper and our own custom action mapper to
handle the default index page where the Action name is null in namespace
"/", i.e., http://localhost/our-app/ <http://localhost:8080/our-app/>) and
am encountering some problems with the configuration.  After perusing the
code and searching nabble it appears that the configuration elements
described in the JavaDocs for the CompositeActionMapper are incorrect in two
ways:

1. struts.mapper.composite needs to be set to the bean names, not the FQCN
of the mappers to be composited
2. setting the "struts" bean to be CompositeActionMapper gives an error that
the bean has already been defined (in struts-default.xml)

I'm currently trying to configure our app like so:

<bean type="org.apache.struts2.dispatcher.mapper.ActionMapper"
        name="tdar-action-mapper"
        class="org.tdar.struts.TdarActionMapper"/>
 <constant name="struts.mapper.composite"
value="tdar-action-mapper,restful2" />
 <constant name='struts.mapper.class'
value='org.apache.struts2.dispatcher.mapper.CompositeActionMapper'/>

However, when I load this configuration I get an NPE in
CompositeActionMapper in setActionMappers(), line 102, which seems to
indicate that the com.opensymphony.xwork2.inject.Container (which should be
@Inject-ed) is null.  I'm kind of at a loss at this point.  I'm using Spring
as the objectFactory, could that be the issue?

Has anyone successfully gotten CompositeActionMapper to work and how?

Thanks in advance!

--
Allen Lee
Center for the Study of Institutional Diversity [http://csid.asu.edu]
School of Human Evolution and Social Change [http://shesc.asu.edu]
College of Liberal Arts and Sciences
Arizona State University | P.O. Box 872402 | Tempe, Arizona 85287-2402
480.727.0401 | Fax: 480.965.7671 | e-mail: Allen.Lee@...

Re: using CompositeActionMapper

by Jeromy Evans - Blue Sky Minds :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Allen Lee wrote:
> Hey there,
>
>
> Has anyone successfully gotten CompositeActionMapper to work and how?
>
>  


 <!-- Define the action mappers -->
  <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper"
name="addressMapper"  
class="com.mycompany.actionmapper.CustomActionMapper" />
  <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper"
name="compositeMapper"  
class="org.apache.struts2.dispatcher.mapper.CompositeActionMapper" />

  <!-- configure the composite order (custom mapper and the default rest
plugin action mapper) -->
  <constant name="struts.mapper.composite" value="addressMapper,rest" />

  <!-- enable the composite mapper -->
  <constant name="struts.mapper.class" value="compositeMapper"/>




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: using CompositeActionMapper

by rsilva :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have used the following with success in Mac Os Leopard Tomcat 6.0.18 Struts 2.0.14 Java 1.5.0.19

    <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="waves" class="struts2.urlrewrite.WavesASPActionMapper" />
    <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="hierarchy" class="struts2.urlrewrite.WavesHierarchyActionMapper" />
    <constant name="struts.mapper.composite" value="struts,waves,hierarchy" />
    <constant name="struts.mapper.class" value="composite"/>

When I moved to CentOs Tomcat 6.0.18 Struts 2.0.14 Java 1.6.0_10 it start throwing

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:290)
        at com.opensymphony.xwork2.inject.ContainerImpl$2.call(ContainerImpl.java:117)
        at com.opensymphony.xwork2.inject.ContainerImpl$2.call(ContainerImpl.java:115)
        at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:542)
        at com.opensymphony.xwork2.inject.ContainerImpl.injectStatics(ContainerImpl.java:114)
        at com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:494)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:145)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
        at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:205)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:516)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
        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:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        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:597)
        at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:136)
        at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:49)
        at com.opensymphony.xwork2.inject.ContainerImpl$ParameterInjector.inject(ContainerImpl.java:431)
        at com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:446)
        at com.opensymphony.xwork2.inject.ContainerImpl.access$000(ContainerImpl.java:48)
        at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:288)
        ... 41 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:464)
        at com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:501)
        at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:549)
        at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:499)
        at com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:32)
        at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:134)
        ... 46 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:290)
        at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:400)
        at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:461)
        ... 51 more
Caused by: java.lang.reflect.InvocationTargetException
        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:597)
        at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:288)
        ... 53 more
Caused by: java.lang.NullPointerException
        at org.apache.struts2.dispatcher.mapper.CompositeActionMapper.setActionMappers(CompositeActionMapper.java:108)
        ... 58 more

It seems Struts 2 is not injecting Container reference on CompositeActionMapper.

Really strange.

I tried create another Composite Action Mapper Bean called compositeMapper and using it in struts.mapper.class but do not work too.

Any Thoughts?

Thank you.

Aloha,

afael Sobral


Jeromy Evans - Blue Sky Minds wrote:
Allen Lee wrote:
> Hey there,
>
>
> Has anyone successfully gotten CompositeActionMapper to work and how?
>
>  


 <!-- Define the action mappers -->
  <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper"
name="addressMapper"  
class="com.mycompany.actionmapper.CustomActionMapper" />
  <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper"
name="compositeMapper"  
class="org.apache.struts2.dispatcher.mapper.CompositeActionMapper" />

  <!-- configure the composite order (custom mapper and the default rest
plugin action mapper) -->
  <constant name="struts.mapper.composite" value="addressMapper,rest" />

  <!-- enable the composite mapper -->
  <constant name="struts.mapper.class" value="compositeMapper"/>




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Re: using CompositeActionMapper

by rsilva :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I dont not understand very much about Struts2 inject process but I fixed my problem extending the compositeActionMapper with the following one:

public class DebugCompositeActionMapper extends CompositeActionMapper {

    @Override
    @Inject(StrutsConstants.STRUTS_MAPPER_COMPOSITE)
    public void setActionMappers(String list) {
        if (list != null) {
            String[] arr = list.split(",");
            for (String name : arr) {
                if (container==null) continue; // LINE ADDED
                Object obj = container.getInstance(ActionMapper.class, name);
                if (obj != null) {
                    actionMappers.add((ActionMapper) obj);
                }
            }
        }
    }
}

I worked since it do not throw the Null Pointer Exception and it seem during injection process the function setActionMappers is called twice. One before the container is set and other after.

I hope it help.

Aloha,

Rafael Sobral


I have used the following with success in Mac Os Leopard Tomcat 6.0.18 Struts 2.0.14 Java 1.5.0.19

    <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="waves" class="struts2.urlrewrite.WavesASPActionMapper" />
    <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="hierarchy" class="struts2.urlrewrite.WavesHierarchyActionMapper" />
    <constant name="struts.mapper.composite" value="struts,waves,hierarchy" />
    <constant name="struts.mapper.class" value="composite"/>

When I moved to CentOs Tomcat 6.0.18 Struts 2.0.14 Java 1.6.0_10 it start throwing

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:290)
        at com.opensymphony.xwork2.inject.ContainerImpl$2.call(ContainerImpl.java:117)
        at com.opensymphony.xwork2.inject.ContainerImpl$2.call(ContainerImpl.java:115)
        at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:542)
        at com.opensymphony.xwork2.inject.ContainerImpl.injectStatics(ContainerImpl.java:114)
        at com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:494)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:145)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
        at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:205)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:516)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
        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:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        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:597)
        at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:136)
        at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:49)
        at com.opensymphony.xwork2.inject.ContainerImpl$ParameterInjector.inject(ContainerImpl.java:431)
        at com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:446)
        at com.opensymphony.xwork2.inject.ContainerImpl.access$000(ContainerImpl.java:48)
        at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:288)
        ... 41 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:464)
        at com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:501)
        at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:549)
        at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:499)
        at com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:32)
        at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:134)
        ... 46 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:290)
        at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:400)
        at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:461)
        ... 51 more
Caused by: java.lang.reflect.InvocationTargetException
        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:597)
        at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:288)
        ... 53 more
Caused by: java.lang.NullPointerException
        at org.apache.struts2.dispatcher.mapper.CompositeActionMapper.setActionMappers(CompositeActionMapper.java:108)
        ... 58 more

It seems Struts 2 is not injecting Container reference on CompositeActionMapper.

Really strange.

I tried create another Composite Action Mapper Bean called compositeMapper and using it in struts.mapper.class but do not work too.

Any Thoughts?

Thank you.

Aloha,

afael Sobral


Jeromy Evans - Blue Sky Minds wrote:
Allen Lee wrote:
> Hey there,
>
>
> Has anyone successfully gotten CompositeActionMapper to work and how?
>
>  


 <!-- Define the action mappers -->
  <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper"
name="addressMapper"  
class="com.mycompany.actionmapper.CustomActionMapper" />
  <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper"
name="compositeMapper"  
class="org.apache.struts2.dispatcher.mapper.CompositeActionMapper" />

  <!-- configure the composite order (custom mapper and the default rest
plugin action mapper) -->
  <constant name="struts.mapper.composite" value="addressMapper,rest" />

  <!-- enable the composite mapper -->
  <constant name="struts.mapper.class" value="compositeMapper"/>




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: using CompositeActionMapper

by DNewfield :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

rsilva wrote:

> I dont not understand very much about Struts2 inject process but I fixed my
> problem extending the compositeActionMapper with the following one:
>
> public class DebugCompositeActionMapper extends CompositeActionMapper {
>
>     @Override
>     @Inject(StrutsConstants.STRUTS_MAPPER_COMPOSITE)
>     public void setActionMappers(String list) {
>         if (list != null) {
>             String[] arr = list.split(",");
>             for (String name : arr) {
>                 if (container==null) continue; // LINE ADDED
>                 Object obj = container.getInstance(ActionMapper.class,
> name);
>                 if (obj != null) {
>                     actionMappers.add((ActionMapper) obj);
>                 }
>             }
>         }
>     }
> }
>
> I worked since it do not throw the Null Pointer Exception and it seem during
> injection process the function setActionMappers is called twice. One before
> the container is set and other after.

Do the call stacks during those two calls reveal anything useful about
how/why it's getting called twice (once before it sounds like it should)?

If container is null during one of those calls, won't it be null during
the entire method call?  If so, why not put
"if (container == null) return;" as the first line of the method instead
of re-checking it for each potential mapper specification?

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


RE: using CompositeActionMapper

by mgainty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


good advice

if the container is going null could you provide

a complete dump of log
Directory of $CATALINA_HOME/logs

catalina.2009-07-01.log

display any/all messages that say anything about configuring Web Container e.g.

INFO: Configuring SomeWebApp for Web Container type 'MyTomcat'



all of the contents of HOST.YYYY-MM-DD.log e.g.

07/01/2009  02:42 PM               914 localhost.2009-07-01.log


vendor and version of webapp container you are using

JDK/J2EE version you are implementing e.g. java -version
any tweaks on JAVA_OPTS

as much code as is necessary to reproduce (including web.xml,struts.xml,struts-default.xml)

thanks,
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Thu, 2 Jul 2009 14:08:27 -0400
> From: dale@...
> To: user@...
> Subject: Re: using CompositeActionMapper
>
> rsilva wrote:
> > I dont not understand very much about Struts2 inject process but I fixed my
> > problem extending the compositeActionMapper with the following one:
> >
> > public class DebugCompositeActionMapper extends CompositeActionMapper {
> >
> >     @Override
> >     @Inject(StrutsConstants.STRUTS_MAPPER_COMPOSITE)
> >     public void setActionMappers(String list) {
> >         if (list != null) {
> >             String[] arr = list.split(",");
> >             for (String name : arr) {
> >                 if (container==null) continue; // LINE ADDED
> >                 Object obj = container.getInstance(ActionMapper.class,
> > name);
> >                 if (obj != null) {
> >                     actionMappers.add((ActionMapper) obj);
> >                 }
> >             }
> >         }
> >     }
> > }
> >
> > I worked since it do not throw the Null Pointer Exception and it seem during
> > injection process the function setActionMappers is called twice. One before
> > the container is set and other after.
>
> Do the call stacks during those two calls reveal anything useful about
> how/why it's getting called twice (once before it sounds like it should)?
>
> If container is null during one of those calls, won't it be null during
> the entire method call?  If so, why not put
> "if (container == null) return;" as the first line of the method instead
> of re-checking it for each potential mapper specification?
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>

_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits.
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009