1 Reply Latest reply on Mar 18, 2010 8:46 AM by pavan kumar

    Regarding Seam Error

    pavan kumar Newbie
      At first Clicking on Register new user,After that Go to Administration tab on that Click on settings, then that time the following error shows,

      Exception during request processing:
      Caused by javax.servlet.ServletException with message: "#{addRegister.addRegister}: javax.ejb.EJBTransactionRolledbackException: node to traverse cannot be null!"

      javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
      org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      java.lang.Thread.run(Unknown Source)




      The Code is as follows,


      AddRegister.java

      package org.jboss.seam.example.projectmanager1;

      import javax.ejb.Local;

      @Local
      public interface AddRegister {
          public void addRegister();
          public void invalid();
          public String getVerify();
          public void setVerify(String verify);
          public boolean isRegistered();
               public void destroy();

      }


      AddRegisterAction.java
         package org.jboss.seam.example.projectmanager1;

      import static org.jboss.seam.ScopeType.EVENT;

      import java.util.List;

      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;

      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.faces.FacesMessages;

      @Stateful
      @Scope(EVENT)
      @Name("addRegister")
      public class AddRegisterAction implements AddRegister {
         @In
      private AddUser add;
         @PersistenceContext
      EntityManager em;
         @In
      private FacesMessages facesMessages;
         private String verify;
         private boolean registered;
         public void addRegister()
      {
        if(add.getPassword().equals(verify))
        {
         List existing=em.createQuery("selecu u.name,u.email from AddUser u where u.name=#{add.name} or u.email=#{add.email}").getResultList();
         if(existing.size()==0)
         {
          em.persist(add);
             facesMessages.add("Successfully registered as #{add.name}");
          registered=true;
         }
         else
         {
          facesMessages.addToControl("name", "Name #{add.name}/Email #{add.email} already exists");
         }
        }
        else
             {
                facesMessages.addToControl("verify", "Re-enter your password");
                verify=null;
             }
      }

            public String getVerify() {
           return verify;
      }
      public void setVerify(String verify) {
         this.verify = verify;
          }

         public void invalid() {
         facesMessages.add("Please try again");
          }

         public boolean isRegistered() {
           return registered;
      }

         @Remove
      public void destroy() {
             }



      }

      AddUser.java

      package org.jboss.seam.example.projectmanager1;

      import java.io.Serializable;

      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.Id;
      import javax.persistence.Table;

      import org.hibernate.validator.Length;
      import org.hibernate.validator.NotNull;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.Scope;

      import static org.jboss.seam.ScopeType.SESSION;

      @Entity
      @Name("add")
      @Scope(SESSION)
      @Table(name="Adduser")

      public class AddUser implements Serializable{
               private String name;
        private String password;
        private String email;
        private String hourlyrate;
        private String role;
                    @Id
              @Length(min=4,max=10)
        public String getName() {
         return name;
        }

        public void setName(String name) {
         this.name = name;
        }
        @NotNull
        @Length(min=5,max=8)
        public String getPassword() {
         return password;
        }

        public void setPassword(String password) {
         password = password;
        }
        @NotNull
        public String getEmail() {
         return email;
        }

        public void setEmail(String email) {
         this.email = email;
        }
        @NotNull
        public String getHourlyrate() {
         return hourlyrate;
        }
          public void setHourlyrate(String hourlyrate) {
         this.hourlyrate = hourlyrate;
        }
        @NotNull
        public String getRole() {
         return role;
        }

        public void setRole(String role) {
         this.role = role;
        }
                   }

      adduserform.xhtml


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:ui="http://java.sun.com/jsf/facelets"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:f="http://java.sun.com/jsf/core"
            xmlns:s="http://jboss.com/products/seam/taglib"
            xmlns:a="http://richfaces.org/a4j">

      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <link href="stylesheet/bcolor.css" type="text/css" rel="stylesheet"/>
         <title>Project Management</title>
      </head>

      <body class="bccolor">
            <h:form >
          <ui:include src="projecthome.xhtml" />
               <h:messages globalOnly="true" styleClass="message"/>
          <s:validateAll>
            <f:facet name="aroundInvalidField">
                  <s:span styleClass="errors"/>
                </f:facet>
                <f:facet name="afterInvalidField">
                  <s:span>&#160;<s:message/></s:span>
                </f:facet>
           <table class="centeralign" border="1px">
            <tr>
             <td style="COLOR: #c0c0c0; FONT-SIZE: large;"> UserName</td>
             <td>
              <s:decorate><h:inputText id="name" value="#{add.name}" required="true"/></s:decorate>
             </td>
            </tr>
            <tr>
             <td style="COLOR: #c0c0c0; FONT-SIZE: large;">E-mail</td>
             <td>
              <s:decorate><h:inputText id="email" value="#{add.email}" required="true"/></s:decorate>
             </td>
            </tr>
                   <tr>
            <td style="COLOR: #c0c0c0; FONT-SIZE: large;">Password</td>
            <td>
             <s:decorate><h:inputSecret id="password" value="#{add.password}" required="true"/></s:decorate>
            </td>
            </tr>
            <tr>
            <td style="COLOR: #c0c0c0; FONT-SIZE: large;">Re-Password</td>
            <td>
             <s:decorate><h:inputSecret id="verify" value="#{addRegister.verify}" required="true"/></s:decorate>
            </td>
            </tr>
                          <tr>
             <td style="COLOR: #c0c0c0; FONT-SIZE: large;">Hourly rate</td>
             <td>
              <s:decorate><h:inputText id="hourlyrate" value="#{add.hourlyrate}" required="true"/></s:decorate>
             </td>
            </tr>
            <tr>
             <td style="COLOR: #c0c0c0; FONT-SIZE: large;">Role</td>
             <td>
              <h:selectOneRadio value="#{add.role}" id="role">
               <f:selectItem itemLabel="client" itemValue="1"/>
               <f:selectItem itemLabel="user" itemValue="2"/>
               <f:selectItem itemLabel="Admin" itemValue="3"/>
              </h:selectOneRadio>
                      </td>
             </tr>
                  </table>
           <div class="buttonBox ">
            <h:commandButton id="addRegister" value="Add" action="#{addRegister.addRegister}"/>
            &#160;
            <s:button id="cancel" value="Close" view="/loginpage.xhtml"/>
                 </div>
                     </s:validateAll>
                              </h:form>
            </body>

      </html>