2

I created a small example that demonstrates the error.

A stateful bean holds a list as its state and injects a stateless bean:

@Stateful
@RequestScoped
public class StatefulBean {

    @Inject
    StatelessBean slsb;

    @Getter // public list getter
    private List<String> list = new ArrayList<>();

    public List<String> sfAdd() {
        slsb.slAdd();
        System.out.println(list);
        list.add("Z");
        return list;
    }
}

The stateless bean manipulates the state of the stateful bean by injection:

@Stateless
public class StatelessBean {

    @Inject
    StatefulBean sfsb;

    public void slAdd() {
        sfsb.getList().add("S");
    }
}

The call System.out.println(sfsb.sfAdd()); is made in a JAXRS GET method. The steps of the invocation that I expected are are:

  1. sfAdd is called
  2. slAdd is called and adds "S", return.
  3. print [S].
  4. add "Z", return.
  5. print [S, Z].

Which in general is what happens, but the ouput gives an error message also:

INFO  [stdout] (default task-2) [S]

ERROR [org.jboss.as.ejb3] (default task-2) WFLYEJB0487: Unexpected invocation state 0
INFO  [stdout] (default task-2) [S, Z]

I don't understand what is WFLYEJB0487: Unexpected invocation state 0, why it happens and what I'm supposed to do about it. The message is printed between steps 3 and 5. Google found only https://developer.jboss.org/thread/272767 but it's not helpful.

I also found out that removing @Stateful from StatefulBean causes the error to disappear. Wildfly 10.1, JavaEE 7.

Mark
  • 2,167
  • 4
  • 32
  • 64
  • Where is your `getList()` on your `StatefulBean` class? – Jorge Campos Aug 10 '17 at 00:05
  • @JorgeCampos Oh, there's Lombok's `@Getter` annotation on the list which generates a getter. I'll mention that. – Mark Aug 10 '17 at 00:16
  • Looks like a bug in Wildfly. Removing `@Stateful` clears the error message because the bug is triggered by a transactional [interceptor](http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.wildfly/wildfly-ejb3/9.0.1.Final/org/jboss/as/ejb3/component/stateful/StatefulSessionSynchronizationInterceptor.java#StatefulSessionSynchronizationInterceptor) that affects only SFSBs. Unless you're managing transactions in your use case, you shouldn't worry (or upgrade). – kolossus Aug 10 '17 at 08:13
  • Possible duplicate of [Java EE 6: How to call Stateful Session Bean from Stateless Session Bean?](https://stackoverflow.com/questions/11437206/java-ee-6-how-to-call-stateful-session-bean-from-stateless-session-bean) – Steve C Aug 10 '17 at 09:54
  • @SteveC No, see https://stackoverflow.com/questions/45249780/how-to-make-a-state-available-to-all-beans-in-a-session and the discussions in there. – Mark Aug 10 '17 at 16:10
  • Well, is it EJB 3.0, 3.1 or 3.2? You have tagged it with "ejb-3.0". – Steve C Aug 10 '17 at 23:00
  • @SteveC Java ee 7 with wildfly 10.1, so I guess ejb 3.2. – Mark Aug 11 '17 at 01:03

0 Answers0