解决方法-JBAS014516:在5分钟内未能获得许可

Nar*_*dey 2 ejb threadpool ejb-3.1 jboss6.x

我的EJB-JBOSS配置目前面临着“ JBAS014516:未能在5分钟内获得许可”的问题。下面是我的配置-

<subsystem xmlns="urn:jboss:domain:ejb3:1.4">
        <session-bean>
            <stateless>
                <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
            </stateless>
            <stateful default-access-timeout="5000" cache-ref="simple"/>
            <singleton default-access-timeout="5000"/>
        </session-bean>
        <mdb>
            <resource-adapter-ref resource-adapter-name="hornetq-ra"/>
            <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
        </mdb>
        <pools>
            <bean-instance-pools>
                <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
                <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
            </bean-instance-pools>
        </pools>
        <caches>
            <cache name="simple" aliases="NoPassivationCache"/>
            <cache name="passivating" passivation-store-ref="file" aliases="SimpleStatefulCache"/>
            <cache name="clustered" passivation-store-ref="abc" aliases="StatefulTreeCache"/>
        </caches>

        <async thread-pool-name="default"/>
        <timer-service thread-pool-name="default">
            <data-store path="timer-service-data" relative-to="jboss.server.data.dir"/>
        </timer-service>
        <remote connector-ref="remoting-connector" thread-pool-name="default"/>
        <thread-pools>
            <thread-pool name="default">
                <max-threads count="10"/>
                <keepalive-time time="100" unit="milliseconds"/>
            </thread-pool>
        </thread-pools>
        <iiop enable-by-default="false" use-qualified-name="false"/>
        <default-security-domain value="other"/>
        <default-missing-method-permissions-deny-access value="true"/>
    </subsystem>
Run Code Online (Sandbox Code Playgroud)

为了解决这个问题,我应该将“ strict-max-pool”增加到一个更高的值或增加线程池的大小。

ynt*_*ual 5

在不了解用例的情况下,很难建议一种好的方法,但是很可能您是在EJB bean上调用一个方法,该方法执行时间太长,逐渐耗尽池中的实例,直到调用者没有剩余为止处理。随着越来越多的对此操作的请求进入,EJB容器将尝试向客户端提供池中的下一个空闲项目。通常,如果对bean实例的操作完成,则该实例将返回到池中,并可以用于下一个客户端调用。如果操作花费很长时间,则该池将耗尽,直到没有剩余可用实例来服务该客户端调用为止。根据您的配置,EJB容器有20个实例。如果没有可用的实例,它将尝试等待5分钟,以确保某些实例不会返回到池中。
那么,这导致了什么呢:首先分析花费这么长时间的EJB操作(向部署中添加一个简单的EJB拦截器非常有用,它可以跟踪EJB调用的开始和结束以及跟踪执行时间)
确定谁调用该EJB实例 -也许它正在对该bean进行过多的调用。
如果无法避免或优化长时间运行的操作,请增加池大小,以便客户端可以使用该bean的更多实例(调整max-pool-size

如果您的用例需要长时间运行的操作,而又不需要阻塞并等待其结果,请考虑与JMS队列一起进行异步处理-在队列中创建作业,然后使用MDB执行它们。您仍然可以通过DB存储和查询处理状态。