1 Reply Latest reply on Mar 11, 2007 10:40 PM by Stuart Robertson

    Got

    Liming Zhang Newbie

      Hi, all.
      I am using JBoss 4.0.5 GA with profile EJB3.0, JBoss Seam 1.2 Patch1.
      When I deploy my ejb jar file and start up JBoss, I cannot call session beans from JSF pages. I got error message:

      javax.faces.el.EvaluationException: /test.jspx @16,80 action="#test.test}": Target Unreachable, identifier 'test' resolved to null


      Here is my web.xml:
      <?xml version="1.0" ?>
      <web-app 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"
       version="2.4">
      
       <!-- Ajax4jsf (must come first!) -->
      
       <filter>
       <display-name>Ajax4jsf Filter</display-name>
       <filter-name>ajax4jsf</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>ajax4jsf</filter-name>
       <url-pattern>*.seam</url-pattern>
       </filter-mapping>
      
       <context-param>
       <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
       <param-value>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</param-value>
       </context-param>
      
       <!-- Seam -->
      
       <listener>
       <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
       </listener>
      
       <filter>
       <filter-name>Seam Filter</filter-name>
       <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>Seam Filter</filter-name>
       <url-pattern>/*</url-pattern>
       </filter-mapping>
      
       <servlet>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <servlet-class>org.jboss.seam.servlet.ResourceServlet</servlet-class>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <url-pattern>/seam/resource/*</url-pattern>
       </servlet-mapping>
      
       <!-- MyFaces -->
      
       <listener>
       <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
       </listener>
      
       <!-- Facelets development mode (disable in production) -->
      
       <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <!-- JSF -->
      
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>client</param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.jspx</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>
      
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.seam</url-pattern>
       </servlet-mapping>
      
       <security-constraint>
       <display-name>Restrict raw XHTML Documents</display-name>
       <web-resource-collection>
       <web-resource-name>XHTML</web-resource-name>
       <url-pattern>*.xhtml</url-pattern>
       </web-resource-collection>
       <auth-constraint>
       <role-name>NONE</role-name>
       </auth-constraint>
       </security-constraint>
      
      </web-app>


      Here is my components.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      
      <components xmlns="http://jboss.com/products/seam/components"
      
       xmlns:core="http://jboss.com/products/seam/core"
       xmlns:drools="http://jboss.com/products/seam/drools"
       xmlns:security="http://jboss.com/products/seam/security"
      
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      
       xsi:schemaLocation=
      
       "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd
       http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-1.1.xsd
       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-1.1.xsd
      
       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd">
      
      
      
       <core:init debug="true" jndi-pattern="license/#{ejbName}/local"/>
      
       <core:manager concurrent-request-timeout="500"
      
       conversation-timeout="120000"
      
       conversation-id-parameter="cid"
      
       conversation-is-long-running-parameter="clr"/>
      
       <core:managed-persistence-context name="entityManager"
       auto-create="true"
       persistence-unit-jndi-name="java:/licenseEntityManagerFactory"/>
      
      
       <core:ejb installed="false"/>
      
       <!--drools:rule-base name="securityRules">
       <drools:rule-files>
       <value>/security.drl</value>
       </drools:rule-files>
       </drools:rule-base-->
      
       <security:identity authenticate-method="#{authenticator.authenticate}"
       remember-me="true"/>
      
       <event type="org.jboss.seam.notLoggedIn">
       <action expression="#{redirect.captureCurrentView}"/>
       </event>
       <event type="org.jboss.seam.postAuthenticate">
       <action expression="#{redirect.returnToCapturedView}"/>
       </event>
      
       <!-- For use with jBPM pageflow or process management -->
       <!--
       <core:jbpm>
       <core:process-definitions></core:process-definitions>
       <core:pageflow-definitions></core:pageflow-definitions>
      
       </core:jbpm>
       -->
      
      </components>


      Here is my faces-config.xml
      <?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>
      
       <application>
      
       <message-bundle>messages</message-bundle>
       <!-- Disabled when using Ajax4JSF -->
       <!--
       <view-handler>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</view-handler>
       -->
       </application>
      
       <!-- Seam transaction management -->
       <lifecycle>
       <phase-listener>org.jboss.seam.jsf.TransactionalSeamPhaseListener</phase-listener>
       </lifecycle>
      
       <!-- No Seam transaction management -->
       <!--
       <lifecycle>
       <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
       </lifecycle>
       -->
      
      </faces-config>


      Here is my session ejb:
      import javax.ejb.Local;

      @Local
      public interface ITest {
       public void destroy();
       public void test();
       }


      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Scope;
      
      import org.jboss.seam.annotations.Destroy;
      
      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("test")
      public class Test implements ITest
      {
       public void test(){
       System.out.println("Hi, Session Bean..................");
      
       }
      
      
      
       @Destroy @Remove
       public void destroy(){
      
       }
      
      }


      Finally, here is my page:
      <?xml version="1.0" encoding="GBK"?>
      <html xmlns:jsp="http://java.sun.com/JSP/Page"
       xmlns:c="http://java.sun.com/jsp/jstl/core"
       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"
       template="template.xhtml">
       <head>
       <title>Test</title>
       </head>
       <body>
       <f:view>
       <h:form>
       <h:commandButton type="submit" value="Register" action="#{test.test}"/>
       </h:form>
       </f:view>
      
      
       </body>
      </html>


      I really infrustrated by this problem. I have been working on this problem for days. Help me please........

      Thank you all in advance.

        • 1. Re: Got
          Stuart Robertson Novice

          Since you're at hello world stage, the simplest thing to do is just to have seam-gen create a project for you and start with that. If it works (in my experience that works out of the box) you can just compare that with what you're working with.

          Your page seems a little odd. You seem to be using facelets but you include JSP and JSTL namespaces. And while you reference a template your page doesn't declare a body with <ui:define name="body">.

          Looking at a seam-gen produced project will almost certainly help you get on track.