It is not so much a question, more of a note. With Glassfish4, in a JEE7 application I tried to use the flow scope using programmatic flow definition (java class annotated with @Produces @FlowDefinition).
I navigated to the start page of the flow with a h:commandButton (just as it is done in the JEE7 tutorial example https://svn.java.net/svn/javaeetutorial~svn/trunk/examples/web/jsf/checkout-module. When I pressed the button it stayed on the same page, where the button was, instead of going to the flow's start page.
After many hours of suffering, I realized that the problem is in the beans.xml, in my beans.xml I had this:
bean-discovery-mode="annotated"
which is the recommended setting according to the documentation (http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/beans_1_1.xsd). When I changed this to
bean-discovery-mode="all"
it started to work.
Somehow CDI does not recognize the flow definition as an annotated class. I tried to make it a @Named class, or a @ApplicationScoped class, but non of these helped. I don't know if it is the intended behavior, or a bug.
Hope it saves a few ours to someone.
This is related to how CDI detects bean archives. When
bean-discovery-mode="annotated"
, only classes annotated with bean defining annotations are picked up by CDI; note that@Named
and@FlowScoped
aren't on that list.Because of this, as you've documented here, using Flow annotations requires
bean-discovery-mode="all"
to be set.There's a spec issue open to discuss if this is a desired behavior.
Thank you!
Of course you can always fallback to using an XML declaration for your view. Such as creating a file
example/example-flow.xml
with contents such as