1 Reply Latest reply on Jul 10, 2009 5:24 PM by Arbi Sookazian

    Bean could not be created on the Seam Project

    E Ric Newbie

      Hello all,

      i am a newbi in Seam-programming.
      I already could make a Hello Seam on JBoss. But it's only the first step. I still have to learn many things.

      Now i am trying to make an input Text where user can type a name and then beside this Input Text, the name they typed, will be shown.

      So first,of course i make a java project named Bean.
      My Bean.java is

      package model; 
      public class Bean {
           public String text;
           public Bean() {
           public String getText() {
                return text;
           public void setText(String text) {
                this.text = text;

      And i make a new .xhtml file named hello.xhtml. It looks like this

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          <ui:define name="body">
              <h1>Welcome to Seam!</h1>
                  <h:panelGrid columns="2">
                      <h:graphicImage value="/img/seamlogo.png" alt="Seam logo"/>
                      <s:div styleClass="info">
                         <h:commandButton value="Hello" size="50" style=" width : 129px; height : 60px;"/>
                         <h:inputText value="#{bean.text}"/>
                         <a4j:support event="onkeyup" reRender="rep"/>
                                 <h:outputText value="#{bean.text}" id="rep"/>               

      And into my face-config.xml i add this code


      And i didn't add anything onto web.xml.

      I deployed it...
      But in the webbroser i got this :

      An Error Occurred:
      javax.faces.FacesException: Cant instantiate class: model.Bean.. model.Bean

      Stack Trace

      Component Tree

      Scoped Variables

      And in the console there was an error:
      Managedbean bean could not be created.

      Could anyone please help me?
      I am really new here ..

      It would be my pleasure to get any feedback from you.

      Thank you

        • 1. Re: Bean could not be created on the Seam Project
          Arbi Sookazian Master

          change this:

          <h:commandButton value="Hello" size="50" style=" width : 129px; height : 60px;"/>


          <h:commandButton value="Hello" action="#{foo.bar}" size="50" style=" width : 129px; height : 60px;"/>

          In the Unified EL (expression language) above, 'foo' is the name of your Seam component and 'bar' is a business method (public) in your JavaBean or SFSB (if using SFSB, the method must be defined in your local interface).

          so your backing bean would look something like this for a JavaBean:

          public class Foo {
             public void bar() {
                //do stuff

          or this for a SFSB:

          public class Foo implements FooLocal {
             public void bar() {
                //do stuff
             public void destroy(){}

          With JBoss EL, you can pass a param to the action method as well:


          One of the purposes of Seam was to eliminate the XML in faces-config.xml you wrote.  You don't need to do that anymore when you use JSF/Seam/EJB3/JavaBean.

          Look at the code for the hotel booking example very closely.  Conversation management/modeling and bijection are two of the most difficult aspects of Seam to learn...

          Read one of the Seam books in their entirety (it's in your best interest :).