0

I'm running a web application that has front-end (JSF, CDI) and back-end(EJB,Hibernate) parts of application, each on separate WildFly 9.0.1.Final AS. Front-end communicates with back-end through Remote EJB Client by JNDI names.

Some front-end code:

@ViewScoped
@Named("ddc")
public class DynamicDatatableController implements Serializable {    
    @Produces
    @Resource(lookup = "ejb:bpm-back-ear/bpm-back-dynamicTable/DynamicTableBean!bc.bpm.dynamicTable.back.beans.remote.DynamicTableBeanRemote")
    private DynamicTableBeanRemote dtb;

    private Integer tableId;
    private DynamicTable table;

    @PostConstruct
    public void init{
      table = dtb.getTable(tableId);
    }
}

And some back-end interface code:

@Remote
public interface DynamicTableBeanRemote {
    List<DynamicTable> getTable(Integer tableId);
}

And some back-end bean code:

@Stateless
@LocalBean
public class DynamicTableBean implements DynamicTableBeanRemote {
    final static Logger LOGGER = LoggerFactory.getLogger(DynamicTableBean.class);
    @PersistenceContext(unitName = "bpmBeans")
    private EntityManager em;

    @Override
    public List<DynamicTable> getTableList(Integer tableId) {
        return em.find(DynamicTable.class, tableId);
    }
}

Problem is, that no matter how many requests I do, with JMeter or by refreshing a couple of browser tabs, only one instance of DynamicTableBean is alive at any given time. Every request gets executed by that one bean instance in queue. As you understand, the application is absolutely unusable, because it's absolutely single-threaded EJB wise. What could be the problem?

Sevan
  • 669
  • 1
  • 5
  • 18
ptrdom
  • 100
  • 9

3 Answers3

0

Check your jboss ejb pool configuration. In jboss (this works on eap 6.4.2 and assume same would on wildfly) you can configure the ejb pool size in domain.xml

<subsystem xmlns="urn:jboss:domain:ejb3:1.5">
    <session-bean>
        <stateless>
            <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
        </stateless>
    </session-bean>...
    <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"/>
        </bean-instance-pools>
    </pools>

You can reference this pool in jboss-ejb3.xml as:

<?xml version="1.1" 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:c="urn:clustering:1.0" xmlns:r="urn:resource-adapter-binding"
    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"
    version="3.1" impl-version="2.0">
    <assembly-descriptor>
        <p:pool>
            <ejb-name>ejebId</ejb-name>
            <p:bean-instance-pool-ref>slsb-strict-max-pool</p:bean-instance-pool-ref>
        </p:pool>
    </assembly-descriptor>
</jboss:ejb-jar>
6ton
  • 4,174
  • 1
  • 22
  • 37
  • Tried adding jboss-ejb3.xml to ejb-jar where Stateless EJB is (src/main/resources/META-INF/jboss-ejb3.xml) and WildFly configuration, but result is that now only one instances is created, not destroyed, but reused for every request. Execution is still in queue, no multiple instances, parallel execution or something. – ptrdom Nov 19 '15 at 14:49
  • Turn jboss logging to debug/trace & check logs. You should see logs showing that pools is being used. – 6ton Nov 19 '15 at 14:55
  • Pool is used, but only 1 EJB is created, no matter how many requests you send. Checked that with CLI for this specific bean. – ptrdom Nov 19 '15 at 15:11
0

There is a possibility that the stateless session bean is able to complete the requests at the faster rate than the requests arrival rate.

In such cases you might see only one stateless session bean able catering all the requests. You may want to inject some delay in the stateless session bean and see if you are still seeing only one instance of it. You can inject delay by,

public List<DynamicTable> getTableList(Integer tableId) {
    try {Thread.sleep(3000); } catch (InterruptedException ex) {}
    return em.find(DynamicTable.class, tableId);
}

And also add some log statement in the stateless session bean default constructor to check how many instances got created.

By the way, how did you infer that there only one instance of stateless session bean being created? Through any logs or console etc.

0

Problem was with Intellij 14 and outdated version of JRebel client apparently, both running on Linux workstation. So a thing to remember here is to always keep your tools up to date :)

ptrdom
  • 100
  • 9