12 Replies Latest reply on May 24, 2007 3:57 PM by ryanskeller

    PropertyNotFoundException - Target Unreachable

    strickla

      Hello all,

      New to JSF and Seam here so I'm trying to work out a few kinks. I have created a simple JSF/Facelets application that "just worked" when deploying to JBoss AS 4.2.0 GA.

      Converting that same application to take advantage of Seam has been a headache and a half. Currently everything seems to be good except that when my form on my Login.xhtml page attempts to submit I get the following error:

      First, my environment: JBoss AS 4.2 GA, jboss-seam-CVS.20070521, java 1.5.0_06, MyEclipse 5.5 GA, Facelets 1.1.11.

      javax.servlet.ServletException: /Login.xhtml @41,51 value="#{user.userName}": Target Unreachable, identifier 'user' resolved to null
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      
      root cause
      
      javax.el.PropertyNotFoundException: /Login.xhtml @41,51 value="#{user.userName}": Target Unreachable, identifier 'user' resolved to null
       com.sun.facelets.el.TagValueExpression.getType(TagValueExpression.java:62)
       com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:81)
       javax.faces.component.UIInput.getConvertedValue(UIInput.java:934)
       javax.faces.component.UIInput.validate(UIInput.java:860)
       javax.faces.component.UIInput.executeValidate(UIInput.java:1065)
       javax.faces.component.UIInput.processValidators(UIInput.java:666)
       javax.faces.component.UIForm.processValidators(UIForm.java:229)
       javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)
       javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:662)
       com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
       com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      


      I have since modeled my application as closely as possible to the "registration" example that comes with the Seam CVS nightly build. The main differences being that I am deploying it as a WAR since I created the project w/out using the seam-gen utility. All libraries (jboss-seam.jar, jboss-seam-ui.jar, jsf-facelets.jar, jboss-el.jar) are in the WEB-INF/lib directory of the war.

      Here is my backing bean code:

      /**
       *
       */
      package ***.***.netprov.bean;
      
      import static org.jboss.seam.ScopeType.SESSION;
      
      import java.io.Serializable;
      
      import javax.faces.application.FacesMessage;
      import javax.faces.context.FacesContext;
      
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      
      /**
       * @author strickla
       */
      @Name("user")
      @Scope(SESSION)
      public class User implements Serializable {
      
       /**
       * The name of the user
       */
       private String userName;
      
       /**
       * The password of the user
       */
       private String userPassword;
      
       public User() {
      
       }
      
       public User(String userName, String userPassword) {
       this.userName = userName;
       this.userPassword = userPassword;
       }
      
       /**
       * @return the userName
       */
       public String getUserName() {
       return userName;
       }
      
       /**
       * @param userName
       * the userName to set
       */
       public void setUserName(String userName) {
       this.userName = userName;
       }
      
       /**
       * @return the userPassword
       */
       public String getUserPassword() {
       return userPassword;
       }
      
       /**
       * @param userPassword
       * the userPassword to set
       */
       public void setUserPassword(String userPassword) {
       this.userPassword = userPassword;
       }
      
       public String loginUser() {
       if ("myeclipse".equals(getUserName())
       && "myeclipse".equals(getUserPassword())) {
       return "success";
       } else {
       FacesContext fCtx = FacesContext.getCurrentInstance();
       FacesMessage fMsg = new FacesMessage(
       "You have entered an invalid username and/or password.");
       fCtx.addMessage("loginForm", fMsg);
       return "failure";
       }
       }
      
      }
      


      and my stateless session bean:

      package ***.***.netprov.bean;
      
      import java.util.Date;
      
      import javax.ejb.Stateless;
      
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.log.Log;
      
      @Stateless
      @Name("login")
      public class LoginAction implements Login {
      
       @In(create=true)
       private User user;
      
       @Logger
       private static Log log;
      
       public String login() {
       log.info("User " + user.getUserName() + " attempted to log in @ "
       + new Date());
       return user.loginUser();
       }
      }
      


      and finally, the Login.xhtml page:

      <!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">
       <head>
       <title>JSF Facelets 'Login' Page</title>
       <meta http-equiv="Content-Type"
       content="text/html; charset=iso-8859-1" />
       <meta http-equiv="pragma" content="no-cache" />
       <meta http-equiv="cache-control" content="no-cache" />
       <meta http-equiv="expires" content="0" />
       <meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
       <meta http-equiv="description" content="This is my page" />
       <!--
       <link rel="stylesheet" type="text/css" href="styles.css">
       -->
      
       </head>
      
       <body>
       <ui:composition template="./template.xhtml">
      
       <ui:define name="title">
       JSF Facelets Login Tutorial
       </ui:define>
      
       <ui:define name="body">
       <f:loadBundle basename="mil.disa.netprov.MessageBundle" var="bundle"></f:loadBundle>
       <form jsfc="h:form" id="loginForm">
       <table>
       <tr>
       <td>
       <label jsfc="h:outputLabel" value="#{bundle.userNameLabel}"
       for="userNameTxt" rendered="true">
       <span jsfc="ui:remove">Username:</span>
       </label>
       </td>
       <td>
       <input jsfc="h:inputText" id="userNameTxt" required="true"
       rendered="true" value="#{user.userName}"></input>
       </td>
       </tr>
       <tr>
       <td>
       <label jsfc="h:outputLabel" value="#{bundle.userPasswordLabel}"
       for="userPasswordTxt" rendered="true">
       <span jsfc="ui:remove">Password:</span>
       </label>
       </td>
       <td>
      
       <input jsfc="h:inputSecret" id="userPasswordTxt"
       redisplay="false" required="true" rendered="true"
       value="#{user.userPassword}"></input>
       </td>
       </tr>
       <tr>
       <td>
       <button jsfc="h:commandButton" id="submitButton"
       action="#{login.login}" rendered="true"
       value="#{bundle.loginButtonLabel}" />
       </td>
       </tr>
       </table>
       </form>
       </ui:define>
       </ui:composition>
       </body>
      </html>
      


      Can anyone tell me what I'm doing wrong? My gut instincts at this point are telling me that I should have started with seam-gen script, and that I must set up some sort of database that I then use to bind my backing bean to with the Seam/EJB integration.

      Do I *HAVE* to use the @Entity annotation in my backing bean and use the Seam/EJB integration if I'm going to use Seam to manage my beans or do I have to stick with declaring them in my faces-config.xml file and let JSF manage them?

      Any help is appreciated!

        • 1. Re: PropertyNotFoundException - Target Unreachable
          gavin.king

          It is much, much better to start with a Seam example, or seam-gen, than try to convert a generic JSF project across. A Seam app has waaay more moving parts (EJB, JTA, JPA, Seam itself, etc) that all need to coexist.

          • 2. Re: PropertyNotFoundException - Target Unreachable
            strickla

            Thats all well and good, but what if I don't care about persistence at this time? I thought you didn't need to use EJB, that you could just use POJO's. Is that not true with Seam?

            • 3. Re: PropertyNotFoundException - Target Unreachable
              gavin.king

              That's true, but its easier to remove things you aren't using than to create the whole config from scratch.

              I mean, its not that hard, pretty straightforward if you just follow the docs. But generally I've found that people have a very hard time copy/pasting from documentation and into configuration files.

              • 4. Re: PropertyNotFoundException - Target Unreachable
                strickla

                the problem with the documentation, at least that I've seen so far (which is quite a lot), is that it's obviously all written to the Seam GA releases and not the nightly builds. This makes sense of course, but it makes following the docs and knowning which parts still apply and which don't a bit trickier.

                Btw, I'm using the nightly build of Seam for JSF 1.2 support...if you think it would be easier for me to do this with JSF 1.1 and use the JBoss 4.0.5 GA then perhaps I should try that?

                • 5. Re: PropertyNotFoundException - Target Unreachable
                  lightguard

                  We're having the same problem here. We haven't been able to figure it out either. If we do, we'll post our answer. Gavin maybe right (it being easier to go from an example or seam-gen first then tweak) about how to to start.

                  • 6. Re: PropertyNotFoundException - Target Unreachable
                    strickla

                    And I'll do the same for you if I find a solution. I created the hellowworld project from scratch using seam-gen and the number of configuration files that get generated is a little staggering...it deploys and works fine but telling which parts of that "from scratch" project are necessary is not clear.

                    Oh, it also uses a Seam class called Identity for it's user authentication which in turn uses the @Startup annotation. The @Startup annoation claims that for an application or session scoped bean it will create the bean when the application or session are created. I tried using the @Startup annoation on my User object from the project in my first post but it did *not* fix the problem.

                    • 7. Re: PropertyNotFoundException - Target Unreachable
                      strickla

                      Ok so I took the helloworld example from chapter 2 of the Seam reference guide and added a User.java class with a @Name of "user" and an @Scope of SESSION. The User bean has one field named "name".

                      I created a <h:inputText id="name" value="#{user.name}"/> in the login.xhtml file and when I hit the "Login" button it fails with the exact same error that I got with my initial project in the first post. So with the same error in two projects now...one that I started from scratch and one that was generated by seam-gen I'm really starting to wonder what I could possibly be missing here...because whatever it is it ISN'T obvious.

                      What kind of extra configuration needs to go on for me to reference a bean that is annotated with @Name and @Scope for me to be able to reference it from an .xhtml file?

                      • 8. Re: PropertyNotFoundException - Target Unreachable
                        gavin.king

                        There must be a seam.properties file in the root of the archive that you deploy it in.

                        • 9. Re: PropertyNotFoundException - Target Unreachable
                          strickla

                          I have a seam.properties file in the deploy/netprov.war/META-INF directory of my converted JSF/Facelets project.

                          The helloworld project has a seam.properties in the deploy/helloworld.ear/helloworld.jar directory.

                          From what I can tell the console output of JBoss AS is saying that Seam is being initialized correctly.

                          • 10. Re: PropertyNotFoundException - Target Unreachable
                            strickla

                            After reading the Seam reference documentation a little more closely I found that if you are deploying a WAR (like I am) that the seam.properties file must be in the WEB-INF/classes directory of the WAR.

                            Placing the seam.properties file there appears to allow Seam to find and instantiate my beans. Now however I get the following exception

                            javax.servlet.ServletException: Could not instantiate Seam component: login
                             javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             org.jboss.seam.web.HttpAuthFilter.processBasicAuth(HttpAuthFilter.java:121)
                             org.jboss.seam.web.HttpAuthFilter.doFilter(HttpAuthFilter.java:79)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:59)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:81)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:47)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:126)
                             org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                            
                            root cause
                            
                            org.jboss.seam.InstantiationException: Could not instantiate Seam component: login
                             org.jboss.seam.Component.newInstance(Component.java:1744)
                             org.jboss.seam.Component.getInstance(Component.java:1647)
                             org.jboss.seam.Component.getInstance(Component.java:1614)
                             org.jboss.seam.Component.getInstance(Component.java:1608)
                             org.jboss.seam.jsf.SeamELResolver.getValue(SeamELResolver.java:49)
                             javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
                             com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
                             org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
                             org.jboss.el.parser.AstValue.getTarget(AstValue.java:34)
                             org.jboss.el.parser.AstValue.invoke(AstValue.java:95)
                             org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                             com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                             javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
                             com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
                             javax.faces.component.UICommand.broadcast(UICommand.java:383)
                             javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
                             javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
                             com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
                             com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                             com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
                             javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             org.jboss.seam.web.HttpAuthFilter.processBasicAuth(HttpAuthFilter.java:121)
                             org.jboss.seam.web.HttpAuthFilter.doFilter(HttpAuthFilter.java:79)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:59)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:81)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:47)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:126)
                             org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                            
                            root cause
                            
                            javax.naming.NameNotFoundException: NetProv not bound
                             org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
                             org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
                             org.jnp.server.NamingServer.getObject(NamingServer.java:543)
                             org.jnp.server.NamingServer.lookup(NamingServer.java:267)
                             org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
                             org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
                             javax.naming.InitialContext.lookup(InitialContext.java:351)
                             org.jboss.seam.Component.instantiateSessionBean(Component.java:1108)
                             org.jboss.seam.Component.instantiate(Component.java:1094)
                             org.jboss.seam.Component.newInstance(Component.java:1740)
                             org.jboss.seam.Component.getInstance(Component.java:1647)
                             org.jboss.seam.Component.getInstance(Component.java:1614)
                             org.jboss.seam.Component.getInstance(Component.java:1608)
                             org.jboss.seam.jsf.SeamELResolver.getValue(SeamELResolver.java:49)
                             javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
                             com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
                             org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
                             org.jboss.el.parser.AstValue.getTarget(AstValue.java:34)
                             org.jboss.el.parser.AstValue.invoke(AstValue.java:95)
                             org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                             com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                             javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
                             com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
                             javax.faces.component.UICommand.broadcast(UICommand.java:383)
                             javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
                             javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
                             com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
                             com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                             com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
                             javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             org.jboss.seam.web.HttpAuthFilter.processBasicAuth(HttpAuthFilter.java:121)
                             org.jboss.seam.web.HttpAuthFilter.doFilter(HttpAuthFilter.java:79)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:59)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:81)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:47)
                             org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:55)
                             org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:126)
                             org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                            


                            • 11. Re: PropertyNotFoundException - Target Unreachable

                              I'm experiencing the same problem described in this thread. I haven't been able to get Seam to resolve the name of my backing beans when using POJOs and the @Name annotation (I've been using the 'todo' and 'hibernate' example projects as models adding facelets and RichFaces to my configuration).

                              I've tried placing the empty 'seam.properties' file at the root of my war file. This didn't change anything for me.

                              • 12. Re: PropertyNotFoundException - Target Unreachable

                                Missed that last post from 'strickla'. I went back and added the properties file to the WEB-INF/classes directory and Seam is now resolving the bean names on my view pages. It's now correctly calling methods on some simple POJO backing beans from my view pages. - Thanks