2

We are upgrading struts from 2.0.11 to 2.3.16.

In our code while trying to get DefaultActionValidatorManager.getValidators(getClass(), null), it throws a NullPointerException from DefaultActionValidatorManager.loadFile() while it tries to load java/lang/Object-validation.xml.

Searching on internet I found a similar issue was reported as WW-3850. It says the issue is fixed in xwork 2.3.7. I took a look at xwork 2.3.7 source and it has the mentioned changed (additional null check fileUrl != null). This check is present till xwork 2.3.14.3 and is removed from 2.3.15 onward.

Any idea if this is a regression and needs to fixed in 2.3.15 onwards? Or there is another way of using DefaultActionValidatorManager.getValidators() starting 2.3.15? How to get around this problem in 2.3.16?

Roman C
  • 49,761
  • 33
  • 66
  • 176
Sanket Meghani
  • 885
  • 2
  • 14
  • 22
  • Similar issue was reported for 2.3.4 [here](http://stackoverflow.com/questions/20262241/annotationactionvalidatormanager-caught-exception-while-loading-file-java-lang) – Sanket Meghani Jan 18 '14 at 08:06
  • This is invalid issue, see details here https://issues.apache.org/jira/browse/WW-3850 – Lukasz Lenart Jan 20 '14 at 07:42

1 Answers1

1

The fix still present in Struts 2.3.16, but moved to the DefaultFileManager::fileNeedsReloading(URL fileUrl).

With respect to ClassLoader::getResource(String name) can return null value. See description of javadoc

A URL object for reading the resource, or null if the resource could not be found or the invoker doesn't have adequate privileges to get the resource.

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • Thanks. That explains. However in my case I am still getting NullPointerException for java/lang/Object-validation.xml as fileUrl is null for it. Any idea what I might be missing? Seems like I am missing some configuration. – Sanket Meghani Jan 18 '14 at 09:45
  • There should be action class simple name or combined with action name. I think I'm not able to reproduce it because this is a glaring mistake and exception is a legit way to inform you about it. – Roman C Jan 18 '14 at 10:02