14 Replies Latest reply on Jun 19, 2008 11:42 AM by Alex Kavo

    Simple HelloWorld not running

    Alex Kavo Novice


      I'm trying to start working with SEAM.
      I wrote this simple person class

      package com.test;
      import java.io.Serializable;
      import javax.persistence.GeneratedValue;
      import javax.persistence.Id;
      import org.hibernate.annotations.Entity;
      import org.jboss.seam.annotations.Name;
      public class Person implements Serializable {
              private static final long serialVersionUID = 1L;
              private long id;
              private String name;
              public long getId() {
                      return id;
              public void setId(long id) {
                      this.id = id;
              public String getName() {
                      return name;
              public void setName(String name) {
                      this.name = name;

      This java file I simply created in the src/model directory.

      Then I created this file (ManagerAction.java):

      package com.test;
      import java.util.List;
      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import com.test.Person;
      public class ManagerAction implements Manager {
              private Person person;
              private List<Person> fans;
              private EntityManager em;
              public String sayHello() {
                      person = new Person();
                      fans = em.createQuery("select p from Person p").getResultList();
                      return null;

      And this Interface (Manager.java):

      package com.test;
      import javax.ejb.Local;
      public interface Manager {
              public String sayHello ();

      At least I created this 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"
                <link href="stylesheet/theme.css" rel="stylesheet" type="text/css" />
            <title>Register New User</title>
              Please enter your name:<br/>
              <h:inputText value="#{person.name}" size="15"/><br/>
              <h:commandButton type="submit" value="Say Hello"
      <h:dataTable value="#{fans}" var="fan">
                      <h:outputText value="#{fan.name}"/>

      Ok, I deployed it and can enter the screen and see the form but after submitting I get the debug page with this error:

      Caused by javax.servlet.ServletException with message: "/helloworld.xhtml @12,49 value="#{person.name}": Target Unreachable, identifier 'person' resolved to null"

      Why it cannot resolve person? It is there!
      Hope you can help me.