2 Replies Latest reply on Feb 19, 2010 9:08 PM by Jari Lammassaari

    I got the following error while deploying the seam application

    pavan kumar Newbie
      7:02,971 ERROR [application] JSF1010: Illegal view ID #. The ID must begin with '/'
      17:17:02,986 ERROR [STDERR] Feb 18, 2010 5:17:02 PM com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/register.xhtml]
      java.lang.IllegalArgumentException: Illegal view ID #. The ID must begin with /
      at com.sun.faces.application.ViewHandlerImpl.getActionURL(ViewHandlerImpl.java:660)
      at org.jboss.seam.jsf.SeamViewHandler.getActionURL(SeamViewHandler.java:74)
      at org.ajax4jsf.application.ViewHandlerWrapper.getActionURL(ViewHandlerWrapper.java:92)
      at com.sun.facelets.FaceletViewHandler.getActionURL(FaceletViewHandler.java:803)
      at org.ajax4jsf.application.ViewHandlerWrapper.getActionURL(ViewHandlerWrapper.java:92)
      at org.jboss.seam.ui.util.ViewUrlBuilder.<init>(ViewUrlBuilder.java:25)
      at org.jboss.seam.ui.component.UISeamCommandBase.getUrl(UISeamCommandBase.java:37)
      at org.jboss.seam.ui.renderkit.ButtonRendererBase.getOnClick(ButtonRendererBase.java:37)
      at org.jboss.seam.ui.renderkit.ButtonRendererBase.doEncodeBegin(ButtonRendererBase.java:71)
      at org.jboss.seam.ui.util.cdk.RendererBase.encodeBegin(RendererBase.java:79)
      at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:934)
      at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
      at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
      at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
      at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
      at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      at java.lang.Thread.run(Unknown Source)




      My Logic is as follows:

      Authenticator.java

      package org.jboss.seam.example.creationofxhtml;

      import javax.ejb.Local;

      @Local
      public interface Authenticator
      {
         boolean authenticate();
      }




      AuthenticatorAction.java

      package org.jboss.seam.example.creationofxhtml;

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

      import java.util.List;

      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;

      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;

      @Stateless
      @Name("authenticator")
      public class AuthenticatorAction implements Authenticator
      {
         @PersistenceContext
         private EntityManager em;
             @Out(required=false, scope = SESSION)
         private User user;
             public boolean authenticate()
         {
            List results = em.createQuery("select u from User u where u.username=#{identity.username} and u.password=#{identity.password}")
                  .getResultList();
                   if ( results.size()==0 )
            {
               return false;
            }
            else
            {
               user = (User) results.get(0);
               return true;
            }
         }

      }


      User.java

      package org.jboss.seam.example.creationofxhtml;

      import java.io.Serializable;

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

      import org.hibernate.validator.Length;
      import org.hibernate.validator.NotNull;
      import org.hibernate.validator.Pattern;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import static org.jboss.seam.ScopeType.SESSION;
      @Entity
      @Name("user")
      @Scope(SESSION)
      @Table(name="Members")

      public class User implements Serializable {
         private String username;
      private String password;
      private String name;
          public User(String name, String password, String username)
          {
             this.name = name;
             this.password = password;
             this.username = username;
          }
               public User() {}

          @NotNull
          @Length(max=100)
          public String getName()
          {
             return name;
          }
          public void setName(String name)
          {
             this.name = name;
          }
               @NotNull
          @Length(min=5, max=15)
          public String getPassword()
          {
             return password;
          }
          public void setPassword(String password)
          {
             this.password = password;
          }
               @Id
          @Length(min=4, max=15)
          @Pattern(regex="^\\w*$", message="not a valid username")
          public String getUsername()
          {
             return username;
          }
          public void setUsername(String username)
          {
             this.username = username;
          }
               @Override
          public String toString()
          {
             return "User(" + username + ")";
          }
      }



      Register.java

      package org.jboss.seam.example.creationofxhtml;

      import javax.ejb.Local;

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

      }
      RegisterAction.java

      package org.jboss.seam.example.creationofxhtml;

      import java.util.List;

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

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

      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("register")
      public class RegisterAction implements Register {
      @In
      private User user;
      @PersistenceContext
      EntityManager em;
      @In
      private FacesMessages facesMessages;
      private String verify;
      private boolean registered;
      public void register()
          {
             if ( user.getPassword().equals(verify) )
             {
                List existing = em.createQuery("select u.username from User u where u.username=#{user.username}")
                   .getResultList();
                if (existing.size()==0)
                {
                   em.persist(user);
                   facesMessages.add("Successfully registered as #{user.username}");
                   registered = true;
                }
                else
                {
                   facesMessages.addToControl("username", "Username #{user.username} already exists");
                }
             }
             else
             {
                facesMessages.addToControl("verify", "Re-enter your password");
                verify=null;
             }
          }
               public void invalid()
          {
             facesMessages.add("Please try again");
          }
               public boolean isRegistered()
          {
             return registered;
          }
          public String getVerify()
          {
             return verify;
          }
          public void setVerify(String verify)
          {
             this.verify = verify;
          }
               @Remove
          public void destroy() {}
             }

      register.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="css/bcolor.css" type="text/css" rel="stylesheet"/>
      <title>Project Management</title>
      </head>

      <body class="bccolor">
        <table class="bccolor2" width="100%">
         <tr align="right">
             <td align="center"><img src="images/logo-b.png" align="center" />Project Management</td>
            <table align="right">
             <tr >
                      <td ><img src="images/desktop1.bmp" hspace="4px" /></td>
              <td ><img src="images/user.jpg" hspace="4px" align="right"/></td>
              <td ><img src="images/settings.jpg" hspace="4px"/></td>
              <td ><img src="images/logout.jpg" hspace="4px"/></td>
             </tr>
            </table>
          </tr>
         </table>
        <div class="centeralign">
         <h:form id="registration">
          <s:validateAll>
           <h:panelGrid columns="2">
            <h:outputText value="User Name" style="COLOR: #c0c0c0; FONT-SIZE: large;"></h:outputText>
            <h:inputText id="username" value="#{user.username}" required="true"/>
                   <h:outputText value="Real Name" style="COLOR: #c0c0c0; FONT-SIZE: large;"></h:outputText>
            <h:inputText id="name" value="#{user.name}" required="true" />
                   <h:outputText value="Password" style="COLOR: #c0c0c0; FONT-SIZE: large;"></h:outputText>
            <h:inputSecret id="password" value="#{user.password}" required="true"/>
                   <h:outputText value="Verify Password" style="COLOR: #c0c0c0; FONT-SIZE: large;"></h:outputText>
            <h:inputSecret id="verify" value="#{register.verify}" required="true" />
                  </h:panelGrid>
                   </s:validateAll>
          <div class="buttonBox">
           <h:commandButton action="#{register.register}" value="Register" id="register" style="COLOR: #800000;"/>
           <s:button id="cancel" value="Cancel" view="#" style="COLOR: #800000;"></s:button>
          </div>
         </h:form>
                 </div>
          </body>

      </html>


      home.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="css/bcolor.css" type="text/css" rel="stylesheet"/>
      <title>Project Management</title>
      </head>

      <body class="bccolor">
        <table class="bccolor2" width="100%">
         <tr align="right">
             <td align="center"><img src="images/logo-b.png" align="center" />Project Management</td>
            <table align="right">
             <tr >
                      <td ><img src="images/desktop1.bmp" hspace="4px" /></td>
              <td ><img src="images/user.jpg" hspace="4px" align="right"/></td>
              <td ><img src="images/settings.jpg" hspace="4px"/></td>
              <td ><img src="images/logout.jpg" hspace="4px"/></td>
             </tr>
            </table>
          </tr>
         </table>
      <h:form id="login">
        <div>
         <h:panelGrid columns="2">
          <h:outputLabel for="username" style="COLOR: #c0c0c0; FONT-SIZE: large;">LoginName</h:outputLabel>
          <h:inputText value="#{identity.username}" id="username" style="width: 175px;"/>
               <h:outputLabel for="password" style="COLOR: #c0c0c0; FONT-SIZE: large;">Password</h:outputLabel>
          <h:inputSecret value="#{identity.password}" id="password" style="width: 175px;"/>
         </h:panelGrid>
            <div class="buttonBox"><h:commandButton id="login" action="#{identity.login}" value="Account Login" style="COLOR: #804000;"/></div>
            <div class="notes"><s:link id="register" view="/register.xhtml" value="Register New User"/></div>
           </div>
      </h:form>
      </body>

      </html>


      pages.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <pages xmlns="http://jboss.com/products/seam/pages"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd"

             no-conversation-view-id="/home.xhtml"
             login-view-id="/login.xhtml">

          <page view-id="/register.xhtml">

                                      <navigation>
                              <rule if="#{register.registered}">
                                      <redirect view-id="/home.xhtml" />
                              </rule>
                      </navigation>

              </page>

              <page view-id="/home.xhtml">

                      <navigation>
                              <rule if="#{identity.loggedIn}">
                                      <redirect view-id="/register.xhtml" />
                              </rule>
                      </navigation>

              </page>

         
         
      </pages>