Hello, I have an issue that I can't seem to put a finger on. I am relatively new to Spring and am not using much more than the standard bean definitions for DI into my beans. During testing I ran into a concurrency issue with my applicaiton (a simple web application) running in Tomcat 6.0.10.
The servlet for the web app fetches the bean (MyWebBean) from WebApplicationContext loaded like this:
(in init() method)
Then the service is simply used from the servlet like this:Code:WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext( config.getServletContext()); if (ctx == null) { throw new RuntimeException("spring.config.broke"); } this.myService = (MyService) ctx.getBean("MyService");
The first thing myService.getFoo() does is print out to the screen as well:Code:protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ... System.out.println("I'm about to call getFoo() at: " + new Date(System.currentTimeInMillis())); myReturnValue = myService.getFoo(inputParameter); }
If I run this web app from 6 separate web browser windows concurrently, 5 of the 6 work just fine...the 6th will wait until one of the other 5 is complete before sending the request to myService.getFoo() (ie. it prints 'I'm about to call getFoo()" but doesn't print "Start getFoo()" until one of the previous 5 is complete).Code:public Object getFoo(InputParameter param) { System.out.println("Start getFoo() at: " + new Date(System.currentTimeInMillis())); ... }
maxThreads in Tomcat is set to 150 and when I stop using Spring to configure MyService and force it to be a singleton on my own the issue goes away.
application context for MyService looks like this:
I believe I'm missing something in Spring config...or perhaps something fundamental about Spring. Does anyone have any insight as to what may be causing this? Is there any sort of default throttling being done in Spring? I've seen reference to ConcurrencyThrottleSupport but I am not using that explicitly.Code:<bean id="MyService" class="com.foo.bar.MyServiceImpl"> <property name="loggingService" ref="LoggingService"/> <property name="configBean" ref="ConfigurationBean"/> </bean> <bean id="LoggingService" class="com.foo.bar.logging.LoggingServiceImpl"/> <bean id="ConfigurationBean" class="com.foo.bar.ConfigurationBeanImpl" init-method="initialize" destroy-method="destroyConfig"> <property name="loggingService" ref="LoggingService"/> </bean>
Thanks for any insight.


Reply With Quote
