Struts 2.3.16 - DefaultActionValidatorManager.loadFile() throws NullPointerException while loading Object-validation.xml

StackOverflow https://stackoverflow.com/questions/21201629

سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top