tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johnny Kewl" <>
Subject Re: Interapp Communications
Date Mon, 15 Sep 2008 10:15:26 GMT

----- Original Message ----- 
From: "Darryl Pentz" <>
To: "Tomcat Users List" <>
Sent: Monday, September 15, 2008 10:37 AM
Subject: Interapp Communications

> Some time back I needed to communicate between two apps running in the 
> same Tomcat instance. I decided on using a simple HTTP call with Apache 
> Commons HttpClient. For some reason use of this class is causing PermGen 
> errors (I should add that I use a dynamic language in the mix, which might 
> impact that in some way) so I want to abandon that approach anyway, 
> because it just doesn't 'feel right' :-).
> So I was wondering, is JMS the way to go with something like this? I see 
> Tomcat is able to use JMS via a JNDI read-only lookup.
> Many thanks,
> Darryl Pentz

Well, the way you doing it is also good for cross machine, cross domain.... 
you using simple SOAP... Axis "your way"...
That HTTPd client is quite heavy, maybe Java's URL Connection will do what 
you need

I dont bother too much with the stuff out there... JMS is a way, but you 
looking for JNDI registries now.
Not sure if TC built in JNDI... targeting tomcat... will be enuf?
Some very rough code for you to play with... Java really makes http very 
very easy

private byte[] loadURLFileBytes(String urlPlusFile) {

        byte[] data = new byte[0];
    try {
        URL url = new URL(urlPlusFile);

        URLConnection connection = url.openConnection();

        connection.setDoInput(true);    //GET
        connection.setUseCaches(false); // get fresh from server
        InputStream in = connection.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(in);

        int length = connection.getContentLength();

            int len;
            byte[] buffer = new byte[512];
            while ((len = != -1) {
                data = appendBlock(data,buffer,len);



    } catch(Exception ex) {
        //JOptionPane.showMessageDialog(null, ex.getMessage() , "Error 
during data download", JOptionPane.WARNING_MESSAGE);
        return null;

    return data;

That all your HTTP is doing for you...
Then Tomcat can do cross contexts as well... theres a cross context flag to 
set and some code that looks like this..
The post also describes the issue...

One day when your site is huge, you making millions... maybe your cross 
machine way will sound good again ;)

Theres SOA/EJB as well... ;)

Have fun...
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action :

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message