Java concurrent transactions overwriting

D

Dave Ficken

We have written a Java web service that runs under Apache Tomcat and
AXIS (SOAP/XML). The problem is that simultaneous concurrent
transactions appear to occasionally overwrite each other, and we can't
figure out why. Has anybody come across this problem and can you offer
any suggestion which may help?

I have attached source code below that shows an example of the class
being invoked through AXIS. The method that is invoked by web services
is "doTransaction" which accepts String XML. The problem seems to
occur when private String class member variables of "FooTransaction"
are overwritten by another simultaneous request. FooTransaction also
contains a private vector class member and String data associated with
its elements appear to get overwritten as well.

Any help at all appreciated...
Dave

-----------------
package myPackage;

import java.util.Vector;
import org.apache.xerces.parsers.SAXParser;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import java.io.*;
import java.util.*;

public final class FooEngine implements ContentHandler{

private String XMLFile;

private FooTransactionRequest eReq = new FooTransactionRequest();

private Vector FooTransactions = new Vector();

private FooTransaction eTrans = new FooTransaction();

private CharArrayWriter contents = new CharArrayWriter();

public FooEngine() { }

public String doTransaction(String XMLInput) {

eReq = new FooTransactionRequest();

/* Create the response object that will store the response to the
client **/

FooTransactionResponse response = new FooTransactionResponse();
try {
/* transaction processing here */
/* ....*/
} catch (Exception e) {
/* Return error response. **/
/* ....*/
}

/* Return XML response. */
String XMLResponse = createXMLResponse(response);
return XMLResponse;

}

// the remaining callback handlers

public void setDocumentLocator(Locator locator) {}
public void startDocument() {}
public void endDocument() {}
public void startPrefixMapping(String prefix, String uri) {}
public void endPrefixMapping(String prefix) {}
public void ignorableWhitespace(char[] text, int start, int length)
throws SAXException {}
public void processingInstruction(String target, String data){}
public void skippedEntity(String name) {}
}
 
S

Sudsy

Dave said:
We have written a Java web service that runs under Apache Tomcat and
AXIS (SOAP/XML). The problem is that simultaneous concurrent
transactions appear to occasionally overwrite each other, and we can't
figure out why. Has anybody come across this problem and can you offer
any suggestion which may help?

I don't have the citation at hand but I seem to recall reading that
multiple threads could be using the same instance. I know that's the
case with stateless session EJBs. Solution is to keep all variables
on the stack rather than utilizing instance variables.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top