2 Replies Latest reply on Jun 21, 2006 9:08 PM by Susumu Majima

    Beginner Question Why seam doesn't resolve name

    Susumu Majima Newbie

      I wrote small program. Its useage is setting value1 & value2 after that push Multi button to multiple them.

      JSP code is

      <%@ page contentType="text/html;charset=WINDOWS-31J" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      
      <html>
      <head>
      <title>Security Check</title>
      </head>
      <body>
      <f:view>
       Welcome
       <br>
       <h:form>
       <table>
       <tr><td>Value1</td><td><h:inputText value="#{calculator.value1}"/></td></tr>
       <tr><td>Value2</td><td><h:inputText value="#{calculator.value2}"/></td></tr>
       </table>
       <h:commandButton type="submit" value="Multiple" action="#{calculator.multi}"></h:commandButton>
       </h:form>
       <br><br>
      
       Answer:<h:outputText value="#{calculator.answer}"/>
      </f:view>
      
      </body>
      </html>
      


      Seam code is
      package seam.sample;
      
      import java.io.Serializable;
      
      import javax.annotation.security.PermitAll;
      import javax.annotation.security.RolesAllowed;
      import javax.ejb.Stateful;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      
      
      @Stateful
      @Name("calculator")
      @Scope(ScopeType.SESSION)
      public class CalculatorAction implements Calculator,Serializable {
      
       int value1 = 0;
       int value2 = 0;
       int answer = 0;
      
       public int getAnswer() {
       return answer;
       }
       public void setAnswer(int answer) {
       this.answer = answer;
       }
       public int getValue1() {
       return value1;
       }
       public void setValue1(int value1) {
       this.value1 = value1;
       }
       public int getValue2() {
       return value2;
       }
       public void setValue2(int value2) {
       this.value2 = value2;
       }
      
       public CalculatorAction() {
      
       }
      
      
       //@RolesAllowed("admin")
       public void multi() {
       System.out.println("**** multi ****");
       answer = value1 * value2;
       }
      
       //@RolesAllowed("user")
       public void plus() {
       System.out.println("**** plus ****");
       answer = value1 + value2;
       }
      
       //@PermitAll
       public void minus() {
       System.out.println("**** minus ****");
       answer = value1 - value2;
       }
      
      }
      


      I checked the log. there's DEBUG infomation below
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: calculator
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.Component] seam component not found: calculator
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: calculator
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.Component] seam component not found: calculator
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] could not resolve name
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] could not resolve name
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: calcucator
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.Component] seam component not found: calcucator
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: calcucator
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.Component] seam component not found: calcucator
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] could not resolve name
      2006-06-22 09:27:58,119 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] could not resolve name
      


      I don't understand why seam can't find calculator.
      Deos anyone explain about this?

      Any kind of suggestion will help me.

      Susumu


        • 1. Re: Beginner Question Why seam doesn't resolve name
          Gavin King Master

          Look in your Seam startup log to see if your component is found and installed by Seam.

          Do you have seam.properties in the archive with your bean?

          • 2. Re: Beginner Question Why seam doesn't resolve name
            Susumu Majima Newbie

            I forget to say an importtant thing. I use seam1.0.0CR3 and JBOSS4.0.4GA.

            I set up seam setting in faces-config.xml, web.xml and ejb-jar.xml.
            faces-cconfig.xml is

            <?xml version="1.0" encoding="UTF-8"?>
            
            <!DOCTYPE faces-config
             PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
             "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
            
            <faces-config>
            
            
            
             <!-- Same for all Seam applications -->
            
             <application>
             <variable-resolver>org.jboss.seam.jsf.SeamVariableResolver</variable-resolver>
             </application>
            
             <!-- Select one of the three standard persistence lifecycle models for the Seam application -->
            
             <lifecycle>
             <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
             </lifecycle>
            
            
            </faces-config>
            


            web.xml is
            <?xml version="1.0" encoding="UTF-8"?>
            <web-app version="2.4"
             xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
            
            
             <!-- Seam -->
            
             <listener>
             <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
             </listener>
            
             <!-- Global JNDI name pattern for JBoss EJB3 (change for other servers) -->
            
             <context-param>
             <param-name>org.jboss.seam.core.init.jndiPattern</param-name>
             <param-value>SeamTest01/#{ejbName}/local</param-value>
             </context-param>
            
            
            
             <!-- MyFaces -->
            
             <listener>
             <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
             </listener>
            
             <context-param>
             <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
             <param-value>client</param-value>
             </context-param>
            
             <servlet>
             <servlet-name>Faces Servlet</servlet-name>
             <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
             <load-on-startup>1</load-on-startup>
             </servlet>
            
             <!-- Faces Servlet Mapping -->
             <servlet-mapping>
             <servlet-name>Faces Servlet</servlet-name>
             <url-pattern>*.seam</url-pattern>
             </servlet-mapping>
            
            
            </web-app>
            


            ejb-jar.xml is
            <ejb-jar>
             <assembly-descriptor>
             <interceptor-binding>
             <ejb-name>*</ejb-name>
             <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
             </interceptor-binding>
             </assembly-descriptor>
            </ejb-jar>