开发者

How to configure the maximum pool size of servlets implementing SingleThreadModel?

I'm having the problem that the maximum pool size of a SingleThreadModel servlet is on Tomcat 5.5 limited to 20 instances. I do not know where to configure it in Tomcat 5.开发者_开发技巧5.

My HTTP connector is declared as follows:

<Connector port="8090" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="100"
    enableLookups="false" redirectPort="8443" acceptCount="100"
    connectionTimeout="20000" disableUploadTimeout="true" />

Do you know where I could configure this?


This is as far as I see not configureable by XML.

It's however programmatically configureable by StandardWrapper#setMaxInstances(). You could do this in the init() method of your servlet implementing SingleThreadModel. I tested it here on Tomcat 7 and it works fine.

@Override
public void init() throws ServletException {
    try {
        Field wrappedConfig = StandardWrapperFacade.class.getDeclaredField("config");
        wrappedConfig.setAccessible(true);
        StandardWrapper standardWrapper = (StandardWrapper) wrappedConfig.get(getServletConfig());
        standardWrapper.setMaxInstances(100);
    } catch (Exception e) {
        throw new ServletException("Failed to increment max instances", e);
    }
}

This would in theory only not work on a Tomcat instance which is outside your control and might have some restrictive access policy on the particular classes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜