1 Reply Latest reply on Oct 30, 2007 5:47 AM by mars1412

    newbie: stateless component

    mars1412 Apprentice

      hi,

      for test reasons, I have created a very simple class, that only returns some simple values (see below for details). However, since the class does not need to keep any state, I think I should add the @Stateless annotation. But this does not work - without the @Stateless annotation it works fine, and I can access all the methods/data as expected, but when I add the @Stateless annotation, the JBoss server will mutter:

      javax.el.ELException: /public.xhtml: Could not instantiate Seam component: localeTest
      ...
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: localeTest
      ...
      Caused by: javax.naming.NameNotFoundException: LocaleTest not bound at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      


      any ideas?

      package com.twentyfouract.test000.session;
      
      import java.io.Serializable;
      import java.util.Date;
      
      import javax.ejb.Stateless;
      
      import org.jboss.seam.annotations.Name;
      
      // does not work with this stateless annotation
       @Stateless
      @Name("localeTest")
      public class LocaleTest implements Serializable {
      
       long lValue = 3;
      
       double dValue = 3124.1415926;
      
       /**
       * UID for serialization
       */
       private static final long serialVersionUID = -1157053379099060115L;
      
       public long getlValue() {
       return lValue;
       }
      
       public void setlValue(long value) {
       lValue = value;
       }
      
       public Date getCurrentDate() {
       return new java.util.Date();
       }
      
       public double getdValue() {
       return dValue;
       }
      
       public void setdValue(double value) {
       dValue = value;
       }
      }
      


        • 1. Re: newbie: stateless component
          mars1412 Apprentice

          ok - I just found out why this does not work
          when you use the @Stateless or @Stateful annotation:

          * the class must implement a method with the @Remove annotation.
          from the seam reference manual:

          In addition, stateful session bean components must define a method with no parameters annotated @Remove.
          This method is called by Seam when the context ends

          * the class must implement an interface with all its public methods

          However, I do not really understand what the difference is:
          When I omit the @Stateless annotation I can access all fields and everything works just fine, so why should I bother adding the @Stateless annotaion, an empty (!) @Remove function and an interface?
          It's just way more work for me, without benefit (?).