You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Zepernick <pz...@commercebenefitsgroup.com> on 2010/09/13 15:58:02 UTC

getConfiguration() Outside Of An Action

I am trying to get the Struts configuration outside of an action.  I am looking to populate a table in our DB of all the current Struts actions which we are going to end up using for our system security.  I have been able to access the configuration inside of an action by doing:

final Map<String, Map<String,ActionConfig>> namespaceMap = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();

This returns a NPE when I attempt to call this outside of an action.  I have also tried to create my own configuration by doing:

		final ConfigurationManager cm = new ConfigurationManager();
		final ConfigurationProvider configprovider = new StrutsXmlConfigurationProvider(false);
		cm.addConfigurationProvider(configprovider); 
		final Map<String, Map<String,ActionConfig>> namespaceMap =cm.getConfiguration().getRuntimeConfiguration().getActionConfigs();


The following error is raised when I try to create my own configuration object

com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public static void com.opensymphony.xwork2.ObjectFactory.setObjectFactory(com.opensymphony.xwork2.ObjectFactory).
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:157)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMethods(ContainerImpl.java:126)
	at com.opensymphony.xwork2.inject.ContainerImpl.injectStatics(ContainerImpl.java:111)
	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 com.jweb.security.GetStrutsActions.getActions(GetStrutsActions.java:43)
	at com.mr.tasks.AddActionsToDb.run(AddActionsToDb.java:31)
	at java.util.TimerThread.mainLoop(Timer.java:512)
	at java.util.TimerThread.run(Timer.java:462)
Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public static void com.opensymphony.xwork2.ObjectFactory.setObjectFactory(com.opensymphony.xwork2.ObjectFactory).
	at com.opensymphony.xwork2.inject.ContainerImpl.createParameterInjector(ContainerImpl.java:239)
	at com.opensymphony.xwork2.inject.ContainerImpl.getParametersInjectors(ContainerImpl.java:229)
	at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.<init>(ContainerImpl.java:282)
	at com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:130)
	at com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:128)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:154)
	... 9 more

Is it possible to get the configuration information outside of an action?

Thanks,

Paul Zepernick



The information contained in this transmission contains confidential  information that is legally privileged. This information is intended only for the use of the individual or entity named above. The authorized recipient of this information is prohibited from disclosing this information to any other party unless required to do so by law or regulation and is required to destroy the information after its stated need has been fulfilled.
If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or action taken in reliance on the contents of these documents is strictly prohibited. If you have received this information in error, please notify the sender immediately by return email and arrange for the return or destruction of these documents.