struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <lukaszlen...@apache.org>
Subject Re: Validation with DefaultActionValidatorManager throws NullPointerExeption
Date Wed, 26 Feb 2014 12:48:55 GMT
2014-02-26 13:35 GMT+01:00 Thomas Hermann <thermann@mtg.de>:
> Hello,
>
> In a JUnit-Test and in a Ajax-Server I try to validate an Object with
> com.opensymphony.xwork2.validator.DefaultActionValidatorManager (Version
> 2.3.15.3).
>
> The MyObject-validation.xml file is provided in the same directory as the
> MyObject-Class (no action alias used).
>
> I instantiate the validator manually with the new operator because the
> ActionValidatorManagerFactory is no longer supported in the version
> 2.3.15.3:
>
> --------------------------------------
> DefaultActionValidatorManager validator = new
> DefaultActionValidatorManager();
> validator.validate(myObject, null);
> --------------------------------------
>
> but at runtime I get a NullPointerException:
>
> --------------------------------------
> java.lang.NullPointerException
>     at
> com.opensymphony.xwork2.validator.DefaultActionValidatorManager.loadFile(DefaultActionValidatorManager.java:342)
>     at
> com.opensymphony.xwork2.validator.DefaultActionValidatorManager.buildClassValidatorConfigs(DefaultActionValidatorManager.java:245)
>     at
> com.opensymphony.xwork2.validator.DefaultActionValidatorManager.buildValidatorConfigs(DefaultActionValidatorManager.java:324)
>     at
> com.opensymphony.xwork2.validator.DefaultActionValidatorManager.buildValidatorConfigs(DefaultActionValidatorManager.java:305)
>     at
> com.opensymphony.xwork2.validator.DefaultActionValidatorManager.buildValidatorConfigs(DefaultActionValidatorManager.java:305)
>     at
> com.opensymphony.xwork2.validator.DefaultActionValidatorManager.getValidators(DefaultActionValidatorManager.java:93)
>     at
> com.opensymphony.xwork2.validator.DefaultActionValidatorManager.validate(DefaultActionValidatorManager.java:127)
>     at
> com.opensymphony.xwork2.validator.DefaultActionValidatorManager.validate(DefaultActionValidatorManager.java:119)
>     at
> com.opensymphony.xwork2.validator.DefaultActionValidatorManager.validate(DefaultActionValidatorManager.java:114)
> --------------------------------------
>
> The problem seems to be caused by the fileManager, that is set to NULL.
>
> Has anyone an idea how to solve the problem?
> How is the DefaultActionValidatorManager used correctly?

You must inject FileManagerFactory - manually via setter (new
DefaultFileManagerFactory()) - but as far I understand you use
DefaultActionValidatorManager outside struts, right? If in struts
action, you can use @Inject to inject proper instance.


Regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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


Mime
View raw message