[jboss-user] [JBoss Seam] - Re: create method not found + @Factory
Basel
do-not-reply at jboss.com
Sat Jul 15 14:44:44 EDT 2006
Could someone please help me with getting a component initialized properly? I have read so many posts and tried many solutions with no avail.
Few things that I have leaned from the posts:
1. @Begin does not start a new conversation. It only promotes a short-running conversation to a long-running mode.
2. @Factory get called whenever your JSF EL code is trying to access a context variable that is null.
3. The variable that that gets initialized by the @Factory method might need to be annotated using @Out(scope=CONVERSATION)
Let me rephrase what I am currently doing. There three pages:
1. An input page called newentry.jsf that has a button which directs the user to confirmentry.jsf
2. A confirmation page called confimentry.jsf that show the date from newentry.jsf and ask the user to confirm or edit.
3. View result page called saveentry.jsf that tells the user whether the record was saved or not.
These three pages depend on a component called newEntry which happens to be an entity bean, Entry.java. This component gets created inside a stateful session bean, PostAction.java, with the help of the @Factory annotation. The session bean persists the entity bean once the user clicks the save button on the confirmentry.jsf page. Since jBPM is used to manage the page flow I had to add a method that triggers the beginning of the conversation and the name of the pageflow definition.
When I try to access newentry.jsf I get the first six lines below. Once I input some data and hit process I get two line from postAction in addition to the stacktrace:
| 21:00:47,163 INFO [PostAction] Creating a new empty entry
| 21:00:47,163 INFO [PostAction] Created a new empty entry
| 21:00:47,168 INFO [PostAction] Creating a new empty entry
| 21:00:47,169 INFO [PostAction] Created a new empty entry
| 21:00:47,173 INFO [PostAction] Creating a new empty entry
| 21:00:47,174 INFO [PostAction] Created a new empty entry
| 21:00:54,474 INFO [PostAction] Creating a new empty entry
| 21:00:54,474 INFO [PostAction] Created a new empty entry
| 21:00:54,475 ERROR [STDERR] Jul 16, 2006 9:00:54 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute
| WARNING: /newentry.xhtml @18,48 value="#{newEntry.title}": Target Unreachable, identifier 'newEntry' resolved to null
| javax.el.PropertyNotFoundException: /newentry.xhtml @18,48 value="#{newEntry.title}": Target Unreachable, identifier 'newEntry' resolved to null
| at com.sun.facelets.el.TagValueExpression.getType(TagValueExpression.java:62)
| at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:129)
| at javax.faces.component.UIInput.getConvertedValue(UIInput.java:943)
| at javax.faces.component.UIInput.validate(UIInput.java:868)
| at javax.faces.component.UIInput.executeValidate(UIInput.java:1078)
| at javax.faces.component.UIInput.processValidators(UIInput.java:670)
| at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1039)
| at javax.faces.component.UIForm.processValidators(UIForm.java:229)
| at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1039)
| at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:672)
| at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
| at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
| at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:132)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
| at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
| at java.lang.Thread.run(Thread.java:595)
| 21:00:54,477 ERROR [STDERR] Jul 16, 2006 9:00:54 PM com.sun.faces.lifecycle.LifecycleImpl phase
| WARNING: executePhase(PROCESS_VALIDATIONS 3,com.sun.faces.context.FacesContextImpl at 1a2dbfc1) threw exception
| javax.faces.FacesException: /newentry.xhtml @18,48 value="#{newEntry.title}": Target Unreachable, identifier 'newEntry' resolved to null
| at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:108)
| at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
| at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:132)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
| at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
| at java.lang.Thread.run(Thread.java:595)
| Caused by: javax.el.PropertyNotFoundException: /newentry.xhtml @18,48 value="#{newEntry.title}": Target Unreachable, identifier 'newEntry' resolved to null
| at com.sun.facelets.el.TagValueExpression.getType(TagValueExpression.java:62)
| at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:129)
| at javax.faces.component.UIInput.getConvertedValue(UIInput.java:943)
| at javax.faces.component.UIInput.validate(UIInput.java:868)
| at javax.faces.component.UIInput.executeValidate(UIInput.java:1078)
| at javax.faces.component.UIInput.processValidators(UIInput.java:670)
| at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1039)
| at javax.faces.component.UIForm.processValidators(UIForm.java:229)
| at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1039)
| at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:672)
| at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
| ... 28 more
| 21:00:54,481 ERROR [SeamExceptionFilter] uncaught exception handled by Seam
| javax.servlet.ServletException: /newentry.xhtml @18,48 value="#{newEntry.title}": Target Unreachable, identifier 'newEntry' resolved to null
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
| at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
| at java.lang.Thread.run(Thread.java:595)
| 21:00:54,494 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
| javax.el.PropertyNotFoundException: /newentry.xhtml @18,48 value="#{newEntry.title}": Target Unreachable, identifier 'newEntry' resolved to null
| at com.sun.facelets.el.TagValueExpression.getType(TagValueExpression.java:62)
| at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:129)
| at javax.faces.component.UIInput.getConvertedValue(UIInput.java:943)
| at javax.faces.component.UIInput.validate(UIInput.java:868)
| at javax.faces.component.UIInput.executeValidate(UIInput.java:1078)
| at javax.faces.component.UIInput.processValidators(UIInput.java:670)
| at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1039)
| at javax.faces.component.UIForm.processValidators(UIForm.java:229)
| at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1039)
| at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:672)
| at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
| at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
| at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:132)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
| at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
| at java.lang.Thread.run(Thread.java:595)
|
Excerpts of the source code and configuration files follows:
newentry.jsf
| <ui:define name="content">
| <div class="entry">
| <h:form>
| <s:validateAll>
| <div>
| <h:outputLabel for="title">Title: </h:outputLabel>
| </div>
| <div>
| <h:inputText id="title" value="#{newEntry.title}"
| size="70" maxlength="70" required="true"/>
| <span class="errors"><h:message for="title"/></span>
| </div>
| <div>
| <h:outputLabel for="excerpt">
| Excerpt (optional):
| </h:outputLabel>
| </div>
| <div>
| <h:inputTextarea id="excerpt"
| value="#{newEntry.excerpt}" cols="68" rows="3"/>
| <span class="errors"><h:message for="excerpt"/></span>
| </div>
| <div>
| <h:outputLabel for="body">Body text: </h:outputLabel>
| </div>
| <div>
| <h:inputTextarea id="body" value="#{newEntry.body}"
| cols="68" rows="20" required="true"/>
| <span class="errors"><h:message for="body"/></span>
| </div>
| <div>
| <h:commandButton value="Proceed" action="proceed"/>
| </div>
| </s:validateAll>
| </h:form>
| </div>
| </ui:define>
|
Entry.java and PostAction.java
| @Entity(name="gs_entry")
| public class Entry {
|
| @Id
| @GeneratedValue(strategy=AUTO)
| @Column(name="entry_id")
| private int id;
|
| @NotNull
| @Length(max=70)
| private String title;
|
| @Length(max=200)
| private String excerpt;
|
| @NotNull
| @Length(max=1400)
| private String body;
|
| @NotNull
| @Column(name="post_date")
| private Date postDate = new Date();
|
| // @Length(max = 50)
| // @JoinColumn(name="category_name", referencedColumnName="name")
| @NotNull
| @ManyToOne
| @JoinColumn(name="categoryid", referencedColumnName="category_id")
| private Category mycategory;
|
| public Entry(){}
| public Entry(Category category){
| this.mycategory = category;
| }
| }
|
| @Stateful
| @Name("postAction")
| public class PostAction implements PostActionInterface{
|
| @In(create=true)
| private Category category;
|
| @In(create=true, value="entityManager")
| private EntityManager em;
|
| //@In(required=false)
| //@Out(value="newEntry")
| //@Out(value="newEntry", scope=ScopeType.CONVERSATION)
| private Entry entry;
|
| @Factory("newEntry")
| //@Begin(pageflow="new-entry", join=true)
| public void createNewEntry(){
| log.info("Creating a new empty entry");
| entry = new Entry(category);
| if(entry == null){
| log.info("The entry IS NULL");
| }
| log.info("Created a new empty entry");
| }
|
| @Logger
| private Log log;
|
| @Begin(pageflow="new-entry", join=true)
| public void startPost(){
| log.info("Starting to create a new post");
| }
|
| @End
| public String post(){
| log.info("Saving entry #{newEntry}");
| entry.setPostDate(new Date());
| category.getEntries().add(entry);
| em.persist(entry);
| return "/saveentry.xhtml";
| }
|
| /*
| * Stateful seam components should have a destroy method to link
| * the stateful bean lifecycle to the Seam component lifecycle.
| */
| @Remove @Destroy
| public void destroy(){}
| }
|
pages.xml
| <pages>
| <!--
| <page view-id="/newentry.jsf" action="#{conversation.begin}"/>
| -->
| <page view-id="/newentry.jsf" action="#{postAction.startPost}"/>
| </pages>
|
I am so sorry if this was discussed in the past but I am desperate at the moment after spending two full days without being able to find a solution.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3958285#3958285
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3958285
More information about the jboss-user
mailing list