geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trygve Hardersen" <>
Subject remote ejb scalability issue
Date Wed, 16 Apr 2008 18:39:52 GMT
I've been playing with Geronimo 2.1 for a while, and I find it very
promising. I'm assembling a custom server with my own modules using
the plugin framework and Maven. I've gotten integration tests up and
running, but these uncovered some nasty performance issues, which I'm
unable to overcome. The custom server assembly and the complexity of
my application means there are many things that could potentially
cause these problems, so I've used the Bank EJB example to verify the

The source in
includes a remote test client "BankClient". It demonstrates remote EJB
client-server communication, once. However the problem I'm seeing is
with repeated calls to the server. After about 300 test runs (1000+
calls) in my application the server is starting to refuse connections,
complaining that the "Cannot connect to server:
'ejbd://localhost:4201'.  Exception: : Address
already in use: connect". I interpret this as "another service has
already bound to the port". I can catch the exception, wait 50ms,
retry and it usually works, but connections are refused more
frequently the more calls I make. My test case was initially multi
threaded, but I'm seeing the same problem in single threaded mode.

To verify that the same problem occurs with the Bank EJB sample
application, I've written this test case:

public class BankClientScalabilityTest {

	 * @param args
	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		System.out.println("Running BankClientTest in multi threaded mode
(10000 runs, 1 threads)");
		List<Future<Long>> results = new ArrayList<Future<Long>>();
		ExecutorService exec = Executors.newFixedThreadPool(1);
		BankClientScalabilityTest instance = new BankClientScalabilityTest();
		for(int i = 0; i < 10000; i++){
			results.add(exec.submit( BankClientTest()));
		boolean allDone = false;
			allDone = true;
			Iterator<Future<Long>> iter = results.iterator();
				Future<Long> res =;
					allDone = false;
					Exception ex = null;
					Long ttime = null;
						ttime = res.get();
					}catch (Exception e) {
						ex = e;
					if(ex != null){
						System.err.println("Multi threaded BankClientTest failed");
						System.out.println("Multi threaded BankClientTest finished in
"+ttime.longValue()+" milliseconds");
					res = null;
			try {
			} catch (InterruptedException e) {break;}
		System.out.println("Finished BankClientTest in multi threaded mode
(10000 runs, 1 threads) in "+(System.currentTimeMillis() - time)+"

	private class BankClientTest implements Callable<Long>{

		public Long call() throws Exception {
			long time = System.currentTimeMillis();
	        InitialContext ic = null;
	        BankManagerFacadeRemote bmr = null;
	        try {
		        Properties p = new Properties();
		        p.setProperty(Context.PROVIDER_URL, "ejbd://localhost:4201");
	            ic = new InitialContext(p);
	            bmr =
	            List<ExchangeRate> rates = bmr.getExchangeRates();
	            System.out.println("Exchange Rates");
	            for(int i = 0 ; i < (int)rates.size(); i++) {
	                ExchangeRate rate = rates.get(i);
	                System.out.println("Currency: " + rate.getCurrency());
	                System.out.println("Rate: " + rate.getRate());
	            return new Long(System.currentTimeMillis() - time);
	        } catch(Exception e) {
	            throw e;
	        } finally{
	        	bmr = null;
	        	if(ic != null){
		        	ic = null;	

After 2000+ runs it starts failing, here's the stack trace:

javax.naming.NamingException: Cannot lookup
'/BankManagerFacadeBeanRemote'. [Root exception is
java.rmi.RemoteException: Cannot connect to server
'ejbd://localhost:4201"; nested exception is: Cannot connect to server:
'ejbd://localhost:4201'.  Exception: : Address
already in use: connect]
	at org.apache.openejb.client.JNDIContext.lookup(
	at javax.naming.InitialContext.lookup(Unknown Source)
	at BankClientScalabilityTest$
	at BankClientScalabilityTest$
	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
	at Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$ Source)
	at Source)
Caused by: java.rmi.RemoteException: Cannot connect to server
'ejbd://localhost:4201"; nested exception is: Cannot connect to server:
'ejbd://localhost:4201'.  Exception: : Address
already in use: connect

I'm not planning on using remote EJB clients like this in production,
but it troubles me that it doesn't work and causes my performance and
scalability tests to fail.

I'm testing with Java 1.6 on Windows XP SP2, geronimo-jetty6-javaee5-2.1-bin.

Does anyone have an idea what the problem is? Many thanks for your help.


View raw message