Hi,
AFAIK this should be solved in G 2.1.1 which uses the recently
released openejb 3.0.
Regards
Manu
On Thu, Apr 17, 2008 at 12:09 AM, Trygve Hardersen <[EMAIL PROTECTED]> wrote:
> Hello
> 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
> problem:
>
> The source in
> https://svn.apache.org/repos/asf/geronimo/samples/branches/2.1/samples/bank
> 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: java.net.BindException : 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(instance.new
> BankClientTest()));
> }
> boolean allDone = false;
> while(!allDone){
> allDone = true;
> Iterator<Future<Long>> iter = results.iterator();
> while(iter.hasNext()){
> Future<Long> res = iter.next();
> if(!res.isDone()){
> allDone = false;
> break;
> }else{
> Exception ex = null;
> Long ttime = null;
> try{
> ttime = res.get();
> }catch (Exception e) {
> ex = e;
> }
> if(ex != null){
> System.err.println("Multi
> threaded BankClientTest failed");
> }else{
> System.out.println("Multi
> threaded BankClientTest finished in
> "+ttime.longValue()+" milliseconds");
> }
> iter.remove();
> res = null;
> }
> }
> try {
> Thread.sleep(50);
> } catch (InterruptedException e) {break;}
> }
> System.out.println("Finished BankClientTest in multi threaded
> mode
> (10000 runs, 1 threads) in "+(System.currentTimeMillis() - time)+"
> milliseconds");
> }
>
> private class BankClientTest implements Callable<Long>{
>
> @Override
> public Long call() throws Exception {
> long time = System.currentTimeMillis();
> InitialContext ic = null;
> BankManagerFacadeRemote bmr = null;
> try {
> Properties p = new Properties();
> p.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.RemoteInitialContextFactory");
> p.setProperty(Context.PROVIDER_URL,
> "ejbd://localhost:4201");
> ic = new InitialContext(p);
> bmr =
> (BankManagerFacadeRemote)ic.lookup("BankManagerFacadeBeanRemote");
> 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());
> System.out.println();
> }
> return new Long(System.currentTimeMillis() - time);
> } catch(Exception e) {
> e.printStackTrace();
> throw e;
> } finally{
> bmr = null;
> if(ic != null){
> ic.close();
> 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:
> java.io.IOException: Cannot connect to server:
> 'ejbd://localhost:4201'. Exception: java.net.BindException : Address
> already in use: connect]
> at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:214)
> at javax.naming.InitialContext.lookup(Unknown Source)
> at
> BankClientScalabilityTest$BankClientTest.call(BankClientScalabilityTest.java:86)
> at
> BankClientScalabilityTest$BankClientTest.call(BankClientScalabilityTest.java:1)
> at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
> at java.util.concurrent.FutureTask.run(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
> Caused by: java.rmi.RemoteException: Cannot connect to server
> 'ejbd://localhost:4201"; nested exception is:
> java.io.IOException: Cannot connect to server:
> 'ejbd://localhost:4201'. Exception: java.net.BindException : 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.
>
> Trygve
>