3

Im running my sruts 2 (2.1.8.1) applications in a jboss AS (5.1.0-GA). Im placing a.war and b.war in the same /server/default/deploy path and im placing the struts 2 libs in the /server/default/lib path.

There is no error message in the app or the server, but when i type http://localhost:8080/b/ for some reason im getting in the b.jsp page, the messages in the message resources of the application a.

So, my question is: placing the struts jars in the /lib of the server creates only one instance of the value stack that all the applications have to use the same? If so, what can i do to have different instances for every aplication but keeping the jars in the server paht?

Should i take back the struts jars into the war?

Thanks

im using the struts tag to get the system title

<s:property value="%{getText('system.title')}"/>

this is my configuration for a.war:

/WEB-INF/classes/a-message-resources.properties

system.title=Namefor system A

in the struts.xml i have

<constant name="struts.custom.i18n.resources" value="a-message-resources" />

This is the configuration for b.war

/WEB-INF/classes/b-message-resources.properties

system.title=Namefor system B

in the struts.xml i have

<constant name="struts.custom.i18n.resources" value="b-message-resources" />
Ferdinand
  • 33
  • 4
  • 1
    I like your question because it is weird. I can not see how struts2 could be at fault for this. Can you create two new minimal struts2 applications, with one jsp each, one resource file each, with one message and verify that you can recreate this issue? – Quaternion May 04 '12 at 23:54
  • hi Quaternion, thanks for the interest. I already did it, not with 2, but 3 simple aplications:a.war,b.war,c.war. What happened was the next: a.war started first and showed correctly the text in the jsp, the app b showed the message, but not the one in its own properties, but the one in the a app, and the 3th app didnt show any message, just "system.title.c" because it couldnt find the key name, with this now i can see that struts is loading only 1 properties file, that is the first loaded. – Ferdinand May 05 '12 at 03:56

1 Answers1

4

I think I might know what is going on here.

The struts.custom.i18n.resources value is tokenized and each token is added to the LocalizedTextUtil.DEFAULT_RESOURCE_BUNDLES. This is a static final list of strings. Before adding an item to the list (such as system.title), list.remove() is called on the same token, removing any prior entries for system.title.

Because this field is static, and because it allows only one entry for each message, whichever of your system.title properties is loaded first is then being overwritten by the next one.

As well, it appears that your JBoss instance is loading this class in a manner that is causing the static variables to be shared. You may be able to configure your JBoss to load this class separately for each app. This might be a good place start.

rees
  • 1,566
  • 1
  • 12
  • 19
  • thank u very much, i think ill look for trying Jboss load separately the static variables. ill let u know the results. – Ferdinand May 05 '12 at 04:06