6 Replies Latest reply on Aug 30, 2011 8:13 PM by konami.bankyaw.gmail.com

    When submitting form: Target Unreachable, identifier 'client' resolved to null

    jonfre

      I haven't been able to find a solution to this for the last two days, and the deadline is fast approaching. It's a simple page... a Add Client form. When loading it, everything is fine. (I also have a Edit Client form that uses the same JSF but different method, and it loads fine too... with all fields populated.) But when I try to submit the form, I get the Target Unreachable, identifier 'client' resolved to null error.


      Here is the action class:


      @Stateful
      @Name("manageClient")
      public class ManageClientAction implements ManageClient
      {
           @Logger
           Log log;
      
           @In(required=false)
           @Out
           private Client client;
      
           @Out
           private boolean editing;
      
           @DataModel
           List<SubClient> subClients;
      
           @DataModel
           List<User> users;
      
      
           public String create()
           {
                log.debug("create()");
      
                client = new Client();
                client.setStatus(getDefaultStatus());
      
                return "/admin/clients/edit.xhtml";
           }
      
           public String edit(Client selectedClient)
           {
                ...
           }
      
           public String view(Client selectedClient)
           {
                ...
           }
      
           public String save()
           {
                log.debug("save() invoked!");
      
                if(editing)
                {
                     ClientDB.save(client);
                }
                else
                {
                     ClientDB.add(client);
                }
      
                return "/admin/clients/view.xhtml";
           }
      
           public String delete(Client selectedClient)
           {
                ...
           }
      
           public String toggleActivation(Client selectedClient)
           {
                ...
           }
      
           public String cancel()
           {
                log.debug("cancel()");
      
                return ((client != null) && (client.getGuid() != null)) ? "/admin/clients/view.xhtml" : returnToList();
           }
      
           public String returnToList()
           {
                log.debug("returnToList()");
      
                return "/admin/clients/index.xhtml";
           }
      
           /**
            * Factory method that finds and returns a {@link List} of possible {@link Status}es to populate the "Status" select box.
            */
           @Factory("validClientStatuses")
           public List<Status> getValidStatuses()
           {
                ...
           }
      
           /**
            * Utility method that figures and returns the opposite {@link Status} of a given status.
            * @param status The {@link Status} whose opposite to find and return
            * @return The opposite status of the one specified
            */
           private Status getOppositeStatus(Status status)
           {
                ...
           }
      
           /**
            * Helper method used to get a default {@link Status} object for the add client screen.
            * @return A {@link Status} appropriate for being the default
            */
           private Status getDefaultStatus()
           {
                ...
           }
      
           @Remove
           public void remove() {}
      }




      Here is the RichFaces file:


      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           xmlns:s="http://jboss.com/products/seam/taglib"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:a4j="http://richfaces.org/a4j"
           xmlns:rich="http://richfaces.org/rich"
           template="../../layout/template.xhtml">
      
      <ui:define name="body">
      
      <rich:panel>
           <f:facet name="header">#{editing ? 'Edit' : 'Add'} Client</f:facet>
      
           <s:validateAll>
           
           <rich:messages layout="table" tooltip="true" showDetail="false" showSummary="true"/>
      
           <h:panelGrid columns="2" rowClasses="prop" columnClasses="name,value">
                <h:outputLabel for="id">Client ID</h:outputLabel>
                <h:inputText id="id" value="#{client.clientId}" required="true"/>
      
                <h:outputLabel for="name">Client Name</h:outputLabel>
                <h:inputText id="name" value="#{client.name}" required="true"/>
      
                <h:outputLabel for="status">Status</h:outputLabel>
                <h:selectOneMenu id="status" value="#{client.status}" required="true" converter="client.StatusConverter">
                     <s:selectItems var="_status" value="#{validClientStatuses}" label="#{_status.status}"/>
                </h:selectOneMenu>
           </h:panelGrid>
      
           <h:outputLabel for="readOnly">
                <h:selectBooleanCheckbox id="readOnly" value="#{client.readOnly}"/>
                Read-only access to all data
           </h:outputLabel>
      
           </s:validateAll>
      
           <div>
                <h:commandButton id="save" value="Save" action="#{manageClient.save}"/>
                <s:button id="cance" value="Cancel" view="/admin/clients/index.xhtml"/> 
           </div>
      
      </rich:panel>
      
      </ui:define>
      </ui:composition>



        • 1. Re: When submitting form: Target Unreachable, identifier 'client' resolved to null
          jonfre

          And sorry, I forgot: I'm using Seam 2.2.0.GA, deploying as an EAR onto JBoss 5.1.0.GA.


          During my days(!) of searching for a solution, I've come across several other incidents of this same error. Unfortunately, either no one ever posted a solution or pointers, or the solution and pointers turned out to be either irrelevant or simply didn't work.


          Here is a case of my exact problem, down to the code and the issue he is having:
          http://community.jboss.org/message/480784


          Unfortunately he never received any helpful responses, and he never posted his solution (if he found one).


          I'd absolutely appreciate any suggestions, tips, pointers, references, etc. that would help me out here. I'm at a deadend.

          • 2. Re: When submitting form: Target Unreachable, identifier 'client' resolved to null
            vata2999

            Hi,
            why don't u use EntityHome ? there are many examples in Seam


            Actually when u get Target unreachable it means u bind something in Ui that is not correctly define as Seam component instance as far as i know


            try this


            @Name("client")
            public class ManageClientAction extends EntityHome<Client>
            {
            
               //setter / getter for client id
            
               pesistmethod()
            }
            
            


            or use seam gen it's a breeze


            would u please  explain about create method ?




            • 3. Re: When submitting form: Target Unreachable, identifier 'client' resolved to null
              jonfre

              Hi omid, thanks for replying.


              Unfortunately, I can't use EntityHome because we cannot use Hibernate or even JPA on this project. We're stuck using JDBC. If it was up to me, we'd be using Hibernate and I wouldn't have had to create a JSF converter because I could've used the <s:convertEntity/> tag instead.


              But I digress...


              The create() method is the method that is invoked when a user clicks Create New Client. But since I originally posted this I've made quite a few changes to the class, and I got it working. But as you can see from the code below I have, among other things, changed the class's scope to SESSION. I would however like to avoid this and use CONVERSATION if possible. Any ideas?


              @Name("manageClient")
              @Scope(ScopeType.SESSION)
              public class ManageClientAction implements Serializable
              {
                   private static final long serialVersionUID = 1L;
              
                   @Logger
                   Log log;
              
                   @Out
                   private boolean editing;
              
                   @In(create=true)
                   @Out(required=false)
                   private ClientFilter clientFilter;
              
                   @DataModel(scope=ScopeType.PAGE)
                   private List<Client> clients;
              
                   @DataModelSelection("clients")
                   @In(required=false)
                   @Out(required=false)
                   private Client client;
              
                   @DataModel
                   List<SubClient> subClients;
              
                   @DataModel
                   List<User> users;
              
              
                   @Factory("clients")
                   public void findClients()
                   {
                        log.debug("findClients() invoked!");
              
                        log.debug("clientFilter.clientId = " + clientFilter.getClientId());
                        log.debug("clientFilter.name = " + clientFilter.getName());
                        log.debug("clientFilter.status = " + clientFilter.getStatus());
                        log.debug("clientFilter.readOnly = " + clientFilter.getReadOnly());
              
                        if(clientFilter == null)
                        {
                             clients = ClientDB.findAll();
                        }
                        else
                        {
                             clients = ClientDB.findByFilter(clientFilter);
                        }
                   }
              
                   @Begin
                   public String create()
                   {
                        log.debug("create()");
              
                        client = new Client();
                        client.setStatus(getDefaultStatus());
              
                        return "/admin/clients/edit.xhtml";
                   }
              
                   @Begin
                   public String edit()
                   {
                        log.debug("edit()");
              
                        log.debug("Client GUID = " + client.getGuid());
                        log.debug("Client ID = " + client.getClientId());
                        log.debug("Client name = " + client.getName());
                        log.debug("Client status = " + client.getStatus().getStatus());
                        log.debug("Client readonly = " + client.isReadOnly());
              
                        client = ClientDB.findByGuid(client.getGuid());
                        editing = true;
              
                        return "/admin/clients/edit.xhtml";
                   }
              
                   @Begin
                   public String view()
                   {
                        log.debug("view()");
              
                        client = ClientDB.findByGuid(client.getGuid());
              
                        subClients = SubClientDB.findByClientGuid(client.getGuid());
                        users = UserDB.findByClientGuid(client);
              
                        log.debug("Client GUID = " + client.getGuid());
                        log.debug("Client ID = " + client.getClientId());
                        log.debug("Client name = " + client.getName());
                        log.debug("Client status = " + client.getStatus().getStatus());
                        log.debug("Client readonly = " + client.isReadOnly());
              
                        return "/admin/clients/view.xhtml";
                   }
              
                   @End
                   public String save()
                   {
                        log.debug("save() invoked!");
              
                        if((client.getGuid() != null) && (client.getGuid().length() > 0))
                        {
                             ClientDB.save(client);
                        }
                        else
                        {
                             ClientDB.add(client);
                        }
              
                        return "/admin/clients/view.xhtml";
                   }
              
                   @End
                   public String delete()
                   {
                        log.debug("delete()");
              
                        ClientDB.delete(client);
              
                        return close();
                   }
              
                   @End
                   public String toggleActivation()
                   {
                        client = ClientDB.findByGuid(client.getGuid());
              
                        client.setStatus(getOppositeStatus(client.getStatus()));
                        ClientDB.save(client);
              
                        return close();
                   }
              
                   @End
                   public String cancel()
                   {
                        log.debug("cancel()");
              
                        editing = false;
              
                        return ((client != null) && (client.getGuid() != null)) ? "/admin/clients/view.xhtml" : close();
                   }
              
                   @End
                   public String close()
                   {
                        log.debug("close()");
              
                        return "/admin/clients/index.xhtml";
                   }
              
                   /**
                    * Factory method that finds and returns a {@link List} of possible {@link Status}ess to populate the "Status" select box.
                    */
                   @Factory("clientStatuses")
                   public List<Status> getStatuses()
                   {
                        ...
                   }
              
                   /**
                    * Factory method that finds and returns a {@link List} of possible {@link Status}es to populate the "Status" select box.
                    */
                   @Factory("validClientStatuses")
                   public List<Status> getValidStatuses()
                   {
                        ...
                   }
              
                   /**
                    * Utility method that figures and returns the opposite {@link Status} of a given status.
                    * @param status The {@link Status} whose opposite to find and return
                    * @return The opposite status of the one specified
                    */
                   private Status getOppositeStatus(Status status)
                   {
                        ...
                   }
              
                   /**
                    * Helper method used to get a default {@link Status} object for the add client screen.
                    * @return A {@link Status} appropriate for being the default
                    */
                   private Status getDefaultStatus()
                   {
                        ...
                   }
              }

               

              • 4. Re: When submitting form: Target Unreachable, identifier 'client' resolved to null
                vata2999

                I would however like to avoid this and use CONVERSATION if possible. Any ideas?

                I didn't quite catch the point, but maybe this help you


                1. do you define your client as seam component instance ? (your client entity has @Name annotation)
                if yes, you can  use this code instead of client = new Client();



                client = Component.getInstance(Client.class, true)



                • 5. Re: When submitting form: Target Unreachable, identifier 'client' resolved to null
                  deuce

                  I was getting same message when trying to run the Seam tutorial workshop project.  At some point I decided to check the .WAR deployed on JBoss and saw that none of the entity classes were there. Turned out that when the project rebuilt after generating the entiy classes, there was an error that I didn't notice 'Unable to delete folder org/domain...' which resulted in the build failing. Once I fixed that and got a good build and deployment to JBoss (I had to restart JBoss in this case) the application ran just fine.  Don't know if your problem has the same cause, but this is what I found.

                  • 6. Re: When submitting form: Target Unreachable, identifier 'client' resolved to null
                    konami.bankyaw.gmail.com

                    Hi,


                    Your xhtml page is missing h:form or a4j:form. Does your edit page have the form tag?