Search code examples
jakarta-eewildflyejb-3.1wildfly-9

Stateless remote bean injected via @Resource only providing single instance


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?


Solution

  • 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 :)