4 Replies Latest reply on Jan 2, 2007 5:43 PM by J.R. Ector

    Seam cannot find component

    Arnie Morein Novice

      I have a seam component (it is not an Entity since there is no table related to it in this application) that at run time cannot be located for some reason. I've included the errors from the log below. The User class is used in the UserLogin/UserLoginAction class, populated via the userLogin.xhtml file. I just don't see what's wrong here.

      package us.tx.state.oag.DPSLicenseInquiry.business;
      
      import org.hibernate.validator.Length;
      import org.hibernate.validator.NotNull;
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      
      import us.tx.state.oag.OagIdVault.OagIdVaultAccount;
      import us.tx.state.oag.DPSLicenseInquiry.business.User;
      
      @Name("user")
      @Scope(ScopeType.SESSION)
      public class User {
       private String cs_user_login = null;
       private String cs_user_password = null;
       private OagIdVaultAccount oagIdVaultAccount = null;
       public User () {}
      
       @NotNull @Length(min=2)
       public void setUserLogin(String ps_value) {
       cs_user_login = ps_value;
       }
       @NotNull
       public String getUserLogin() {
       return cs_user_login;
       }
       @NotNull @Length(min=5)
       public void setUserPassword(String ps_value) {
       cs_user_password = ps_value;
       }
       public String getUserPassword() {
       return cs_user_password;
       }
      
       public void setOagIdVaultAccount(OagIdVaultAccount po_account) {
       oagIdVaultAccount = new OagIdVaultAccount(po_account);
       }
      }
      


      The error is:

      2006-11-14 15:49:13,250 DEBUG [org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener] beginning transaction prior to phase: RESTORE_VIEW(1)
      2006-11-14 15:49:13,250 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2006-11-14 15:49:13,250 DEBUG [org.jboss.seam.contexts.Lifecycle] >>> Begin web request
      2006-11-14 15:49:13,281 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.manager
      2006-11-14 15:49:13,281 DEBUG [org.jboss.seam.core.Manager] No stored conversation
      2006-11-14 15:49:13,281 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.init
      2006-11-14 15:49:13,281 DEBUG [org.jboss.seam.jsf.AbstractSeamPhaseListener] After restoring conversation context: ConversationContext(2)
      2006-11-14 15:49:13,296 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: user
       2006-11-14 15:49:13,296 DEBUG [org.jboss.seam.Component] seam component not found: user
       2006-11-14 15:49:13,296 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] could not resolve name
       2006-11-14 15:49:13,343 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: user
       2006-11-14 15:49:13,343 DEBUG [org.jboss.seam.Component] seam component not found: user
       2006-11-14 15:49:13,343 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] could not resolve name
      2006-11-14 15:49:13,343 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2006-11-14 15:49:13,343 DEBUG [org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener] committing transaction after phase: PROCESS_VALIDATIONS(3)
      2006-11-14 15:49:13,343 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2006-11-14 15:49:13,343 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2006-11-14 15:49:13,343 DEBUG [org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener] beginning transaction prior to phase: RENDER_RESPONSE(6)
      2006-11-14 15:49:13,343 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2006-11-14 15:49:13,343 DEBUG [org.jboss.seam.Component] instantiating Seam component: facesMessages
      2006-11-14 15:49:13,359 DEBUG [org.jboss.seam.core.Manager] Discarding conversation state: 2
      2006-11-14 15:49:13,359 DEBUG [org.jboss.seam.contexts.Lifecycle] flushing page context
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener] committing transaction after phase: RENDER_RESPONSE(6)
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.contexts.Lifecycle] After render response, destroying contexts
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.contexts.Lifecycle] destroying event context
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.contexts.Contexts] destroying: org.jboss.seam.core.manager
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.contexts.Contexts] destroying: org.apache.myfaces.application.jsp.JspStateManagerImpl.SERIALIZED_VIEW
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.contexts.Contexts] destroying: com.sun.facelets.legacy.ELCONTEXT
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.contexts.Lifecycle] destroying conversation context
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.contexts.Contexts] destroying: facesMessages
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.contexts.Lifecycle] flushing server-side conversation context
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.contexts.Lifecycle] <<< End web request
      2006-11-14 15:49:13,375 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      


      package us.tx.state.oag.DPSLicenseInquiry.business;
      
      import java.io.Serializable;
      
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.faces.application.Application;
      import javax.faces.component.UIMessage;
      import javax.faces.context.FacesContext;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      
      import org.jboss.seam.annotations.Create;
      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 org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.ScopeType;
      
      import us.tx.state.oag.DPSLicenseInquiry.business.User;
      import us.tx.state.oag.DPSLicenseInquiry.business.DpsLicenseInquiryConstants;
      
      import us.tx.state.oag.OagIdVault.OagIdVault;
      import us.tx.state.oag.OagIdVault.OagIdVaultAccount;
      
      @Stateful
      @Name("UserLogin")
      @Scope(ScopeType.CONVERSATION)
      public class UserLoginAction implements UserLogin {
       @In(create=true, required=true)
       @Out
       private User user;
      
       //seam-gen method
       public String doAction() {
       FacesContext facesContext = FacesContext.getCurrentInstance();
       Application application = facesContext.getApplication();
       String ls_result = null;
      
       // check to see that the user object above has been created and passed in
       if ( user == null ) {
       System.out.println("No user object passed in!");
       return ls_result;
       } else {
       System.out.println("User object to find: " + user.getUserLogin());
       }
      
      
       OagIdVault userVault = new OagIdVault();
       if ( userVault.connectDefaults() == false ) {
       System.out.println("Unable to connect to LDAP server.");
       return ls_result;
       }
       OagIdVaultAccount lo_user = null;
       lo_user = userVault.authenticateUser(user.getUserLogin(), user.getUserPassword());
       if ( lo_user != null ) {
       // fake out security
       //lo_user.addToGroup(DpsLicenseInquiryConstants.CS_DPS_LI_Security_Group);
      
       // determine if the user is a member of the group
       if ( lo_user.findGroupName(DpsLicenseInquiryConstants.CS_DPS_LI_Security_Group) ) {
       ls_result = "success";
       } else {
       /*
       UIMessage msg = (UIMessage)application.createComponent("javax.faces.HtmlMessage");
       msg.getAttributes().put("for", "username");
       msg.set*/
       ls_result = "failure";
       }
       }
       userVault.disconnect();
      
       return ls_result;
       }
      
       @Remove @Destroy
       public void destroy() {}
      }
      


      XHTML FILE
      <!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:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf"
       xmlns:h="http://java.sun.com/jsf/html">
      <head>
       <f:loadBundle basename="messages" var="msgs" />
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
       <title>OAG / DPS License Inquiry</title>
       <link href="stylesheet/theme.css" rel="stylesheet" type="text/css" />
      </head>
      <body>
      <div id="pgHeader">
       <img src="images/banner.jpg" alt="OAG Banner" width="800px"/>
      </div>
      <div id="pgHeaderText">Office of the Attorney General</div>
      
      <div class="pgHorizSpace" style="color: white;">DPS License Search</div>
      
      <div class="pgAttention">
       <p class="error"><b>*** WARNING ***</b></p>
       <p class="warning">The information queried by this system has been provided by the DPS<br></br>
       with the understanding that it will not be abused or released.<br></br>
       Your access is conditional on the information contained herein remaining <b>Private</b>
       and <b>Privileged</b>.<br></br><br></br>
       Every query is logged by User Id. Printing of this data is <b>Strongly Discouraged</b>.<br></br>
       <br></br>
       </p>
      </div>
      
      <div class="pgHorizSpace"> </div>
      
      <div id="pgMessages">
       <h:messages globalOnly="true"/>
      </div>
      
      <div id="pgContent">
      <h:form>
       <fieldset>
       <legend>Enter your User Credentials</legend>
       <table class="formInput">
       <tr><td> </td></tr>
       <tr><td class="formLabelColumn">User Login:</td>
       <td class="formSpacerColumn"> </td>
       <td class="formFieldColumn"><h:inputText id="username" value="#{user.userLogin}"/></td>
       </tr>
       <tr><td class="formLabelColumn"> </td>
       <td class="formSpacerColumn"> </td>
       <td class="formFieldColumn"><h:message for="username"/></td></tr>
      
       <tr><td class="formLabelColumn">Password:</td>
       <td class="formSpacerColumn"> </td>
       <td class="formFieldColumn"><h:inputSecret id="password" value="#{user.userPassword}"/></td>
       </tr>
      
       <tr><td> </td></tr>
       <tr><td class="formLabelColumn"> </td>
       <td class="formSpacerColumn"> </td>
       <td class="formFieldColumn"><h:commandButton action="#{UserLogin.doAction}" value="Login" class="button" /></td>
       </tr>
       <tr><td> </td></tr>
       </table>
       </fieldset>
      </h:form>
      </div>
      <div class="pgHorizSpace"> </div>
      <div id="pgFooter">
       <p>This is some footer text</p>
       <p class="copyright">© 2006 Office of the Attorney General</p>
      </div>
      </body>
      </html>
      


        • 1. Re: Seam cannot find component
          Arnie Morein Novice

          I keep seeing messages that the seam.properties file has to be in various places for seam to pick up the class files. Well, in my projectEJB.jar, its in there, in the /meta-inf/ path. If it needs to be else where, just how/where using Eclipse do I get it in the resultant jar file?

          • 2. Re: Seam cannot find component
            Norman Richards Master

            seam.properties does need to be at the root of the JAR file. I'm not an eclipse user, so I'm not really sure. I believe Seam 1.1 will allow you to not use seam.properties if you have a META-INF/components.xml, but for now you'll need your seam.properties in the right place.

            To verify that Seam is finding your classes, you'll need to look at your server log when you deploy the application. You should see a message like this one that indicates seam is canning your JAR for components.

            14:05:01,891 INFO [Scanner] scanning: /Users/orb/proj/jboss/jboss-4.0/build/output/jboss-4.0.5.GA-ejb3/server/default/tmp/deploy/tmp41693jboss-seam-pay.ear-contents/jboss-seam-pay.jar



            You should also see component registration messages for your components. They will look like this:

            14:05:02,503 INFO [Component] Component: paymentHome, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.example.seampay.PaymentController


            If you aren't seeing those, you have packaging problem.


            • 3. Re: Seam cannot find component
              Gavin King Master

               

              I believe Seam 1.1 will allow you to not use seam.properties if you have a META-INF/components.xml, but for now you'll need your seam.properties in the right place.


              Right. But most people won't have a META-INF/components.xml.

              Also note that this is not in BETA2.

              • 4. Re: Seam cannot find component
                J.R. Ector Newbie

                Hi,

                I was wondering if you solved your problem?
                Also, I'm curious to know how you integrated ldap?

                thanks,

                JR