4 Replies Latest reply on Feb 16, 2007 3:33 AM by Gerardo Segura

    hidden exception issue?

    Gerardo Segura Newbie

      Hello, I'm having this problem with a scenario similar to seamspace registration. This exception is happening:

      java.lang.IllegalStateException: begin method invoked from a long running conversation, try using @Begin(join=true)


      it throws every time I request register.xhtml, it doesn't render since the first request to the page.

      It happens even if I just request that page directly from a fresh browser (I mean, no previous navegation in the application was performed)

      The problem disappears if I delete any reference to newMember object. To make it less confusing here is the actual code:

      The SFSB:
      @Stateful
      @Name("register")
      public class RegistroAction implements Register {
      
       @Logger Log log ;
      
       @In EntityManager entityManager ;
      
       @In(required = false)
       private User newUser ;
      
       @In
       private Identity identity;
      
       @Factory("newUser") @Begin
       public void start() {
       newUser = new User();
       }
      
       private String repassword;
      
       public String getRepassword() {
       return this.repassword;
       }
      
       public void setRepassword(String repassword) {
       this.repassword = repassword;
       }
       ...
      



      The page:

      <ui:define name="body">
       <h:messages globalOnly="true" styleClass="message" />
       <h:form>
       <s:validateAll>
       <div>Nombre: <h:inputText value="#{newUser.name}" required="true" /> </div>
       </s:validateAll>
       <div class="actionButtons">
       <h:commandButton value="Next" action="#{register.next}" />
       </div>
       </h:form>
       </ui:define>


      Note that If I just remove #{newUser.name} the page is loaded properly

      The entity bean declaration:
      @Entity
      @Table(name = "user")
      @NamedQueries( {
       @NamedQuery(name = "User.findById", query = "SELECT p FROM User p WHERE p.id = :id"),
       @NamedQuery(name = "User.findByName", query = "SELECT p FROM User p WHERE p.name = :name"),
       @NamedQuery(name = "User.findByEmail", query = "SELECT p FROM User p WHERE p.email = :email"),
       @NamedQuery(name = "User.findByLoginAndPassword", query = "SELECT p FROM User p WHERE p.login = :login and p.password = :password")
      })
      public class User implements Serializable {
      
       @Id
       @GeneratedValue(strategy = GenerationType.AUTO)
       @Column(name = "id", nullable = false)
       private Integer id;
      
       @Column(name = "name", nullable = false)
       @NotNull
       @Length(max=150)
       private String name;
      
       @Column(name = "email", nullable = false)
       @NotNull
       @Email
       @Length(max=50)
       private String email;
      
       @Column(name = "login", nullable = false)
       @NotNull
       @Length(max=50)
       private String login;
      
       @Column(name = "password", nullable = false)
       @NotNull
       @Length(min=5,max=50)
       private String password;
      
       @OneToOne(cascade = CascadeType.ALL, mappedBy = "contact")
       private Club club ;
      
       @JoinColumn(name = "clientId", referencedColumnName = "id")
       @ManyToOne
       private Client client;
      
       @Version public int version ;
      
       public User() {
       }
      
       public User(Integer id) { this.id = id; }
      
       /** id */
       public Integer getId() { return this.id; }
      
       public void setId(Integer id) { this.id = id; }
      
       /** nombre */
       public String getNombre() { return this.name; }
      
       public void setNombre(String name) { this.name = name; }
      
       /** email */
       public String getEmail() { return this.email; }
      
       public void setEmail(String email) { this.email = email; }
      
       /** login */
       public String getLogin() { return this.login; }
      
       public void setLogin(String login) { this.login = login; }
      
       /** password */
       public String getPassword() { return this.password; }
      
       public void setPassword(String password) { this.password = password; }
      
       /** client */
       public Client getClient() { return this.client; }
      
       public void setClient(Client client) { this.client = client; }
      
       /** club */
       public Club getClub() { return club ; }
      
       public void setClub(Club club) { this.club = club ; }
      
       @Override
       public int hashCode() {
       int hash = 0;
       hash += (this.id != null ? this.id.hashCode() : 0);
       return hash;
       }
      
       @Override
       public boolean equals(Object object) {
       // TODO: Warning - this method won't work in the case the id fields are not set
       if (!(object instanceof User)) {
       return false;
       }
       User other = (User)object;
       if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
       return true;
       }
      
       @Override
       public String toString() {
       return getId() + ":" + getNombre() ;
       }
      
      }



      finally an excerpt of stack trace:
      GRAVE: Error Rendering View[/register.xhtml]
      javax.ejb.EJBException: java.lang.IllegalStateException: begin method invoked from a long running conversation, try using @Begin(join=true)
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:131)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:203)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
       at $Proxy109.start(Unknown Source)
       at mx.test2.seam.Register$$FastClassByCGLIB$$4f33a91c.invoke(<generated>)
       at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:74)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)

      I can't see why the reference to #{newUser.name} is throwing this kind of exception.

      I found this post
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=87167 that seems similar but my EL expression is very simple.

      If I assign values to the newUser properties in the start method (annotated @Factory) nothing changes so makes me think is the EL expression, but again, how so?

      I deeply appreciate any help to trace where my error is.


        • 1. Re: hidden exception issue?
          Gavin King Master

          One possibility is that you are using (broken) server-side state saving in MyFaces. Try client-side state saving, which is non-broken in Myfaces..

          • 2. Re: hidden exception issue?
            Gerardo Segura Newbie

            Nop, I have client side state saving specified.

            I worked around the problem by not using the factory method and exposing newUser as a property of the bean and it worked.

            By doing so I'm not explicitly creating a conversation and I know if there is an error somewhere in the code it will bite me again, but for now I'm good.

            I just wonder which other (besides client side state saving) causes of error might I had.

            regards,

            • 3. Re: hidden exception issue?
              Carsten Hoehne Master

              you have debugged your application, i think.
              But try it again. But a log message in your factory method and see how many times it is really called.
              Please let us know the result.

              • 4. Re: hidden exception issue?
                Gerardo Segura Newbie

                baz: I did that when I first encounter the problem and found start method was called just once.

                I also asigned some values to the properties of newUser inside tehe start method, like:

                newUser.setName("testing") ;

                and that didn't throw the referred exception.

                The exception was been thrown by having a reference to the newUser object, for instance:
                <h:inputText value="#{newUser.name}" required="true" />


                I compared once and again the code with seamspace (you can see it is practicaly the same) but could find my mistake. Of course, seamspace works fine in my machine. Almost only difference is the entity User/Member class.