Question

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" />
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top