Skip to main content

communication between web applications

7 replies [Last post]
wierob
Offline
Joined: 2007-03-26

Hi,

I have two web applications that run in the same server and need to exchange some data. It's not much data and it don't need to be persistent, so a database seems a bit extreme. Ideally one web application would access an object in the other one.

So, what is the best/easiest way to establish a communication between the web apps?

thanks in advance

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kayal
Offline
Joined: 2013-04-10

Sorry for the delayed response; But I came across the same issue and found a solution to it. Please check my post http://kayalvizhiameen.blogspot.com/2013/04/cross-context-communication-...

cf126330
Offline
Joined: 2005-03-29

JMS

whartung
Offline
Joined: 2003-06-13

It kind of depends on what kind communication you're looking for.

JMS is a fine choice. It's portable and not a total bear to set up (at least in GF, it's different in something like Tomcat which doesn't provide JMS).

It's also good if you using it to broadcast notifications or even queries from one webapp to the other.

But if you're looking for something like shared state between the two webapps, then you might want to look at some of the caching libraries, and putting those libraries higher up the classloader chain (specifically outside of your webapps) so they can actually share the implementation.

darrylguanche
Offline
Joined: 2010-12-16

Good to see you're going to keep on bring us the good stuff, even if it is from another site. I'm headin there now!
Keep up the good work .
hummingbird feeder

wierob
Offline
Joined: 2007-03-26

Thanks for your answers.

JMS seems to be a choice but maybe to complicated.

"caching libraries" sounds good, can you please provide a link to a documentation. I can't find infos about that.

To render my problem more precisely:
I have some web service handler that write some state into an instance variable.
Now I like to have a second web app (e.g. jsp) that displays the information stored in this instance variable. If i try to access this instance variable from the jsp via static method the instance variable is empty. As far as I know this is due to the fact that the web services and the jsp are loaded by different class loaders.

any suggestions are welcome

whartung
Offline
Joined: 2003-06-13

Yes, that's precisely what's wrong.

A simple workaround would be to create a simple wrapper class with your static variable in it, but you do not deploy that class with your webapps. Rather you plop the class in to a jar, and then place that jar "outside" the container (say $domain/lib/ext). Then everything within the app server can see any classes in that jar, so both your web service and your JSP will both be able to access the variable from the static instance.

Sivakumar Thyagarajan

> "caching libraries" sounds good, can you please provide a link to a documentation. I can't find infos about that.

A non-portable Glassfish specific mechanism is to use --libraries. Please see
https://glassfish.dev.java.net/javaee5/docs/DG/beade.html#gatej for more information

Thanks
--Siva.

glassfish@javadesktop.org wrote:
> Yes, that's precisely what's wrong.
>
> A simple workaround would be to create a simple wrapper class with your static variable in it, but you do not deploy that class with your webapps. Rather you plop the class in to a jar, and then place that jar "outside" the container (say $domain/lib/ext). Then everything within the app server can see any classes in that jar, so both your web service and your JSP will both be able to access the variable from the static instance.
> [Message sent by forum member 'whartung' (whartung)]
>
> http://forums.java.net/jive/thread.jspa?messageID=242526
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net