Skip to main content

Trouble sharing a hashmap between 2 wars on 2 virtual servers in Glassfish4 using context.xml

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2013-11-14

I have created 2 .war files which are deployed on Glassfish4. warA is hosted on virtual server A port 7171 and warB is hosted on virtual server B port 8181. I want warB to access warAs hashmap. I tried the solution on this link, but it didnt work:

Here is what I have tried so far:

1. I am able to get warB to access warAs hashmap when both of them are on the same virtual server however, when I move them to seperate ones, I get a NullPointerException error because warB cant access warAs hashmap.
2. I have added contextXmlDefault property with value ${com.sun.aas.instanceRoot}/config on both my virtual servers.
3. I have tried adding a separate context.xml file in the META-INF folder of each application but it gets erased when I clean and build it.
4. I have created a context.xml under domain1/config of my Glassfish folder. Its contents are:

             <?xml version="1.0" encoding="UTF-8"?>
             <Context crossContext="true">

Is there anything else I need to do? I'm not sure what I'm missing.