How to set an EJB's Instance Pool class via annotation and xml in JBoss EAP 7 / 6
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.x
- 6.x
Issue
- I'm migrating an ejb from JBoss EAP 5 to JBoss EAP 6 using PoolDefaults to JBoss EAP 6 and I'm getting this failure when deploying to JBoss EAP 6:
JBAS014775: New missing/unsatisfied dependencies:
service jboss.ejb.pool-config.StrictMaxPool (missing) dependents:
My EJB has the following annotations:
import org.jboss.ejb3.annotation.Pool;
import org.jboss.ejb3.annotation.defaults.PoolDefaults;
@Pool(value = PoolDefaults.POOL_IMPLEMENTATION_STRICTMAX, maxSize = 1, timeout = 10000)
-
We have some SLSB used more often than others, How do we set the ejb pool size?
-
JBoss 6.x Migration: Stateless Session Bean pool configuration in jboss-ejb3.xml ?
-
We are seeing this ERROR & WARNING when our EJB client tries to call an EJB:
12:58:58,633 ERROR [org.jboss.as.ejb3.invocation] (http-/127.0.0.1:8080-2) JBAS014134: EJB Invocation failed on component HelloBean for method public abstract java.lang.String com.jboss.examples.ejb3.Hello.hello(java.lang.Long): javax.ejb.EJBException: JBAS014516: Failed to acquire a permit within 1 MINUTES
at org.jboss.as.ejb3.pool.strictmax.StrictMaxPool.get(StrictMaxPool.java:109) [jboss-as-ejb3-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:47) [jboss-as-ejb3-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
...
12:58:58,659 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http-/127.0.0.1:8080-2) #{bean.helloSleep}: javax.ejb.EJBException: JBAS014516: Failed to acquire a permit within 1 MINUTES: javax.faces.FacesException: #{bean.helloSleep}: javax.ejb.EJBException: JBAS014516: Failed to acquire a permit within 1 MINUTES
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:117) [jsf-impl-2.1.19-redhat-1.jar:2.1.19-redhat-1]
at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]
...
Caused by: javax.ejb.EJBException: JBAS014516: Failed to acquire a permit within 1 MINUTES
at org.jboss.as.ejb3.pool.strictmax.StrictMaxPool.get(StrictMaxPool.java:109) [jboss-as-ejb3-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:47) [jboss-as-ejb3-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
...
- Is there any limit in creating the message driven beans and corresponding queues? If so what is the max we can have?
Resolution
Recompile your application against the JBoss EAP 6 jars, the class: org.jboss.ejb3.annotation.defaults.PoolDefaults is not in JBoss EAP 6.
Change the Pool anntation from
@Pool(value = PoolDefaults.POOL_IMPLEMENTATION_STRICTMAX, maxSize = 1, timeout = 10000)
to
@org.jboss.ejb3.annotation.Pool(value="mdb-strict-max-pool")
If you don't want to use annotations, you can define the pool via the jboss-ejb3.xml this way:
<jboss xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:p="urn:ejb-pool:1.0">
....
<assembly-descriptor>
<p:pool>
<ejb-name>MyBean</ejb-name>
<p:bean-instance-pool-ref>mdb-strict-max-pool</p:bean-instance-pool-ref>
</p:pool>
</assembly-descriptor>
</jboss>
Note: The jboss-ejb3 schema extends the ejb-jar schema, so the namespaces can be referenced as this also:
<?xml version="1.0" encoding="UTF-8"?>
<jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="urn:ejb-pool:1.0"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd
http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd
http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
version="3.1"
impl-version="2.0">
<assembly-descriptor>
<p:pool>
<ejb-name>MyBean</ejb-name>
<p:bean-instance-pool-ref>mdb-strict-max-pool</p:bean-instance-pool-ref>
</p:pool>
</assembly-descriptor>
</jboss:ejb-jar>
If you want to apply it to all EJBs in that deployment (notice the
<jboss xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:p="urn:ejb-pool:1.0">
....
<assembly-descriptor>
<p:pool>
<ejb-name>*</ejb-name>
<p:bean-instance-pool-ref>mdb-strict-max-pool</p:bean-instance-pool-ref>
</p:pool>
</assembly-descriptor>
</jboss>
Instance on demand
If the bean-instance-pool-ref is removed from the stateless or mdb sections, then they will default to instance on demand. For stateless that means if a web thread, remoting thread, etc requests a stateless EJB, then an instance will be created on demand and it will go away once the thread's request has been processed. For mdb this means that the maxSession activation property on the Message Driven Bean will be the maximum number of instances, as maxSession is the maximum number of threads for the specific MDB and when the thread needs an MDB instance it will create it on demand.
Note: if the Stateless / MDB instance uses a lot of memory, then you would want to use the bean-instance-pools to restrict the maximum number of concurrent instances to avoid running out of memory.
<session-bean>
<stateless>
<bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
</stateless>
...
</session-bean>
<mdb>
<resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:hornetq-ra}"/>
<bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
</mdb>
Related Solutions:
[@Pool vs maxSession for MDB in JBoss EAP 6](https://access.redhat.com/solutions/1223803)
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.