Bonjour;
je souhaite tester les JSF Flow.
Pour cela, j'ai déclaré une classe pour définir mon Flow (FlowA.java), le bean associé FlowABean.java et les pages.
Lors du lancement du tomcat, la méthode flowADefinitionde la classe FlowA (@FlowDefinition) elle est appelé deux fois, et du coup j'ai l’exception que je copie/colle plus bas.
Dans un premier temps le definingDocumentId je le laissé vide, mais c'est pareil.
Une idée d'ou pourrais venir ce problème, je suis vraiment perdue.
Merci d'avance.
18-Jul-2018 15:55:34.715 GRAVE [main] org.apache.catalina.core.StandardContext.listenerStart Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) [com.sun.faces.config.ConfigureListener]
java.lang.RuntimeException: java.lang.IllegalStateException: Flow with id "flow-a" and definingDocumentId "idflow-a" already exists.
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:280)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4641)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5109)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:742)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:718)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:703)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:986)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1858)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:772)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:426)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1585)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:308)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:966)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Caused by: java.lang.IllegalStateException: Flow with id "flow-a" and definingDocumentId "idflow-a" already exists.
at com.sun.faces.flow.FlowHandlerImpl.addFlow(FlowHandlerImpl.java:126)
at com.sun.faces.application.JavaFlowLoaderHelper.loadFlows(JavaFlowLoaderHelper.java:93)
at com.sun.faces.application.ApplicationAssociate$PostConstructApplicationListener.processEvent(ApplicationAssociate.java:298)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:108)
at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2190)
at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2163)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:296)
at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:739)
at com.sun.faces.config.ConfigManager.publishPostConfigEvent(ConfigManager.java:692)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:260)
... 41 more
Définition du Flow (@FlowDefinition):
Le code du Bean
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 public class FlowA implements Serializable { private final static Logger LOG = Logger.getLogger(FlowFactory.class.getSimpleName()); private static final long serialVersionUID = 1L; @Produces @FlowDefinition public Flow flowADefinition( @FlowBuilderParameter FlowBuilder flowBuilder) { String flowId = "flow-a"; // id for this flow flowBuilder.id("id"+flowId, flowId); // set flow id // add a view to the flow and mark it as start node of the flow graph flowBuilder.viewNode(flowId, "/" + flowId + "/" + flowId + ".xhtml").markAsStartNode(); // add a return node. The flow is exited with the outcome "home" once this node is reached. flowBuilder.returnNode("return-node").fromOutcome("home"); // call this when the flow is entered flowBuilder.initializer("#{flowABean.initialize()}"); // call this when the flow is exited flowBuilder.finalizer("#{flowABean.finalize()}"); return flowBuilder.getFlow(); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 @Named @FlowScoped("flow-a") public class FlowABean implements Serializable{ private static final Logger LOG = Logger.getLogger(FlowABean.class.getName()); private String welcomeMessage = "Welcome to Flow A!"; private int selectedPage = 3; private String someMessage; public String getWelcomeMessage() { return welcomeMessage; } public void setWelcomeMessage(String welcomeMessage) { this.welcomeMessage = welcomeMessage; } public void initialize() { Flow flow = FacesContext.getCurrentInstance().getApplication().getFlowHandler().getCurrentFlow(); Map<Object, Object> flowScope = FacesContext.getCurrentInstance().getApplication().getFlowHandler().getCurrentFlowScope(); LOG.info("Flow A initialized"); } public String doNothing() { methodFlowNode("called from within another method"); return "method-node"; } public void methodFlowNode(String param) { LOG.info("Flow A method node reached with param: " + param); } public String exitMethodFlowNode() { LOG.info("Exiting flow A through method node"); return "return-node"; } public void finalize() { LOG.info("Flow A finalized"); } @PostConstruct public void onCreation() { LOG.info("Flow A created"); } @PreDestroy public void onDestruction() { LOG.info("Flow A destroyed"); } public int getSelectedPage() { return selectedPage; } public void setSelectedPage(int selectedPage) { this.selectedPage = selectedPage; } public String getSomeMessage() { return someMessage; } public void setSomeMessage(String someMessage) { this.someMessage = someMessage; } }
Partager