I have a rather unique issue when using servlets with connection pools and dynamically loading classes with forName. Hopefully someone else has had this problem and can offer some advise. The problem is that is I don't synchronize the processing part of the Servlet, the responses do not match the requests sent in.

Here is the high level
1. Servlet doget/dopost methods dynamically load the appropriate handler class as defined in a properties file
2. Servlet references a JNDI/JDBC connection pool for deal with database information
3. Servlet references an AS400ConnectionPool Object from the jt400.jar IBM library

The connection pools are established in the init() portion of the servlet.

I have dug through the Internet (and this forum) and cannot determine why this is occurring. I am not using any shared variables except the references to the connection pools.

Let me please bore you with the synchronized portion of this code, any input would be greatly appreciated.

Java Code:
	public synchronized String processTransaction(String xmlString,PrintWriter out,Connection conn)
	 throws ClassNotFoundException,NoSuchMethodException,IllegalAccessException,InstantiationException,
  	//--- here is where I set the class
    Class transClass = Class.forName(this.transactionClassString);
    String xmlResponse=null;;

    //--- define these objects and fill them with or without a jndi connection
    Constructor transConstructor;
    Object transObj;

    Method setConnectionPropertiesMethod=null; //--- used to set stand alone props
    Method setAS400ConnectionPoolManagerMethod=null; //--- used to set AS400Connection Pool Manager if available

    //  --- check if AS400Connection Properties was set, if so call it.
    if (this.connectionProps != null)
     	//--- used to get properties to XMLTransaction class
      			new Class[] {Properties.class});
    	logger.info("Setting AS400Connection.properties");
    	//--- used to set AS400ConnectionPoolManager in XMLTransaction class
	    			new Class[] {AS400ConnectionPoolManager.class});
    if (this.jndi_enabled == false)
    	logger.debug ("Performing transaction without JNDI");
    	//--- jndi is not enabled, just pass the request as an XML string
      transConstructor = 
      transClass.getConstructor(new Class[] {String.class});
      transObj = transConstructor.newInstance(new Object[] {xmlString});
      logger.debug("Instantiated constructor without JNDI");
    	//--- jndi is enabled pass a connection from the pool
      logger.debug("Opening JNDI Connection");
      transConstructor = 
    	  transClass.getConstructor(new Class[] {String.class,Connection.class});
        transObj = transConstructor.newInstance(new Object[] {xmlString,conn});
    if (this.connectionProps != null)
    		logger.info("Invoking setConnectionProperties");
    				new Object[] {this.connectionProps}
    		logger.info("Success doing setConnectionProperties");
    	catch (InvocationTargetException ite)
    		String errorString="InvocationTargetException "+this.toString()+" "+ite.getCause();
    } //--- end if connection props aren't null
    //  --- Set the AS400ConnectionPoolManager if successully read in
		if (as400ConnectionPoolManager != null)
			logger.info("Setting AS400 (System) Connection Pool"+
				" Active Connections:"+as400ConnectionPoolManager.getActiveConnectionCount(connectionProps.getProperty("server"), connectionProps.getProperty("username")));
					new Object[] {as400ConnectionPoolManager});
    Method respMethod=transClass.getMethod("getXMLResponse",new Class[] {});
    xmlResponse=(String)respMethod.invoke(transObj,new Object[] {});
    return (xmlResponse);
Is it possible that I need to set one or more of the variables used by this code as static? I have tried this approach, but it did not resolve the issue.

Thanks so much,