javax.ejb.NoSuchEJBException: WFLYEJB0168 is thrown by migrating an application from JBoss EAP 5 to EAP 6+
Issue
If one migrates an application to JBoss EAP 7 that uses Stateful Session Bean, which was working fine in JBoss EAP 5, the following exception will be thrown:
2024-09-04 16:59:02,348 ERROR [org.jboss.as.ejb3.invocation] (default task-1) WFLYEJB0034: Jakarta Enterprise Beans Invocation failed on component CounterBean for method public abstract int com.redhat.cee.example.ejb.Counter.now(): javax.ejb.NoSuchEJBException: WFLYEJB0168: Could not find Jakarta Enterprise Beans with id UUIDSessionID [8576d7b1-7895-4d00-a207-14f06f8e4203]
Our application has code to re-access the SFSB client proxy instance which throws system exception. It works on JBoss EAP 5.x, but it fails on JBoss EAP 6.0+, also JBoss EAP 7.4.z as the latest version.
@Local
public interface Counter {
public int incrementAndGet() throws Exception;
public int now();
}
@Stateful
public class CounterBean implements Counter, Serializable {
private static final long serialVersionUID = 1L;
private int cnt;
@Override
public int incrementAndGet() throws Exception {
cnt++;
if (cnt == 5) {
throw new RuntimeException("TEST");
}
return cnt;
}
@Override
public int now() {
return cnt;
}
}
@Stateful
public class FacadeBean implements Facade {
private Counter counterBean;
@Override
public int execute() {
if (counterBean == null) {
try {
this.counterBean = InitialContext.doLookup("java:global/.../CounterBean");
} catch (NamingException e) {
throw new RuntimeException(e);
}
}
try {
result = counterBean.incrementAndGet();
} catch (Exception e) {
result = counterBean.now(); // re-call business method for the SFSB proxy instance which is already throwing an RuntimeException causes WFLYEJB0034. It works on EAP 5.x.
return result;
}
return result;
}
}
Environment
- Red Hat JBoss Application Platform (EAP)
- 5
- 6
- 7
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.