Uploaded image for project: 'Application Server 7'
  1. Application Server 7
  2. AS7-3884

Load testing application with Jmeter & jboss remoting throws exception saying "Too many channels open"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.1.1.Final
    • 7.1.0.Final
    • EJB, Naming
    • None

      I've created a sampler for JMeter for load testing application. When I ran that with say around 30 threads with rampup time 80 seconds, after a while I kept getting exception specified in https://community.jboss.org/thread/195709?tstart=0. I later tried to close InitialContext in teardown methods, but wasn't really helpful. I looked at no. of InitialContext intances present in the VM using visualvm heapdump & found that just before throwing exception, it was 24 & after throwing exception for all threads, it did reach to 30, but it wasn't useful..

      Please note that, I'm creating InitialContext with passing following parameters to it:
      java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
      java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
      java.naming.provider.url=remote://localhost:4447
      jboss.naming.client.ejb.context=true

      Here is the code for Java Sampler

      package com;
      
      import org.apache.jmeter.config.Arguments;
      import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
      import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
      import org.apache.jmeter.samplers.SampleResult;
      
      import com.banctec.caseware.client.api.API;
      import com.banctec.caseware.client.api.RemoteClientAPI;
      import com.banctec.caseware.resources.CaseResource;
      import com.banctec.caseware.resources.LoginResource;
      import com.banctec.caseware.resources.Resource;
      
      public class EJBTest extends AbstractJavaSamplerClient {
      
      	private API api = null;
      	private Long typeId;
      	private int setupTestCalled = 0;
      	private int teardownTestCalled = 0;
      	private int runTestCalled = 0;
      	
      	public Arguments getDefaultParameters() {
      	    Arguments defaultParameters = new Arguments();
      	    defaultParameters.addArgument("typeId", "1");
      	    defaultParameters.addArgument("RunLoop", "200");
      	    defaultParameters.addArgument("username", "abc");
      	    defaultParameters.addArgument("password", "abc");
      	    return defaultParameters;
      	}
      	
      	public void setupTest(JavaSamplerContext context) {
      		try {
      			typeId = context.getLongParameter("typeId");
      			api = new RemoteClientAPI();//this is where InitialContext gets created
      			LoginResource loginResource = new LoginResource(context.getParameter("username"), context.getParameter("password"));
      			loginResource.setUseDefaultRole(Boolean.valueOf(true));
      			api.login(new Resource[] { loginResource });
      		}catch (Exception e) {
      			e.printStackTrace();
      		}
      		System.out.println(" Number of times setupTest called "+(++setupTestCalled));
      	}
      	
      	public void teardownTest(JavaSamplerContext context) {
      		try{
      			if (api != null) {
      				api.logout();//In this method InitialContext.close() get's called
      			}
      		}catch (Exception e) {
      			e.printStackTrace();
      		}
      		System.out.println(" Number of times teardownTest called "+(++teardownTestCalled));
      	}
      	
      	public SampleResult runTest(JavaSamplerContext context) {
      	    SampleResult result = new SampleResult();
      	    boolean success = true;
      	    int loopCount = context.getIntParameter("RunLoop");
      	    result.sampleStart();
                  //Here goes the code that will call few business methods on remote EJB's in application
                  // I've purposely removed this bit here..
      	    System.out.println(" Number of times runTest called "+(++runTestCalled));
      	    result.sampleEnd();
      	    result.setSuccessful(success);
      	    return result;
      	}
      }
      

            jaikiran Jaikiran Pai (Inactive)
            prasad.deshpande Prasad Deshpande (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: