0

I try to migrate from Struts 2.5.10 to 2.5.17 but LocalizedTextUtil class is removed.

See my code below:

URL[] urls;
try {
     String resourceFolder = PropertiesManager.get(Constants.PROP_RESOURCES_FOLDER);
     File file = new File(resourceFolder);
     URL url = file.toURI().toURL();          
     urls = new URL[]{url};
     ClassLoader cl = new URLClassLoader(urls);
     LocalizedTextUtil.setDelegatedClassLoader(cl);
     LocalizedTextUtil.addDefaultResourceBundle("global");
} 
catch (MalformedURLException e) {
    e.printStackTrace();
}

and in struts.xml

<constant name="struts.custom.i18n.resources" value="global" />

Although i used instead the GlobalLocalizedTextProvider and StrutsLocalizedTextProvider, the resource is not added. Also i tried to inject LocalizedTextProvider with the same result. Should I use another technique?

Guillaume S
  • 1,462
  • 2
  • 19
  • 31
kbou
  • 1
  • 4
  • Possible duplicate of [Migrate from Struts 2.3.33 to Struts 2.5.12 LocalizedTextUtil is removed](https://stackoverflow.com/questions/45327141/migrate-from-struts-2-3-33-to-struts-2-5-12-localizedtextutil-is-removed) – Alex A Aug 31 '18 at 09:41
  • Yes it could be @AlexA but here i set also **ClassLoader**. It seems that these methods of **GlobalLocalizedTextProvider** which extends **AbstractLocalizedTextProvider** cannot be used. – kbou Aug 31 '18 at 10:02
  • You might be right, could you give [StrutsLocalizedTextProvider](https://struts.apache.org/maven/struts2-core/apidocs/com/opensymphony/xwork2/util/StrutsLocalizedTextProvider.html#setDelegatedClassLoader(java.lang.ClassLoader)) a try? I can't test right now but it would seem the methods you need are made available. Other than that, use the method described above. – Alex A Aug 31 '18 at 11:38
  • Neither StrutsLocalizedTextProvider @AlexA worked. – kbou Aug 31 '18 at 13:07

0 Answers0