1 Reply Latest reply on Mar 30, 2011 3:26 PM by Leo van den berg

    Stateless bean property access

    Wilson Lima Newbie
      Hi, I have been facing a problem. In my application, there is a Stateless Bean which that runs a thread a startup time. This thread should connect to the serial port and acquire incoming data.

      `
      @Stateless
      @Name("serialThread")
      @Scope(ScopeType.APPLICATION)
      @Startup

      public class SerialComm {
      //here i read the com port.
      }
      `
      I created a int property called connected with a getter and setter so I would have an icon telling is the app could or could not establish the connection to the serial port. (I set the connected property to 0 or 1 depending on the establishment of the connection or not).

      In my menu.xhtml file I have this:

      `
      <h:graphicImage id="connect_ok_Img" value="/img/connect_ok.png" styleClass="pic" rendered="#{serialThread.connected == 1}" />
              <h:graphicImage id="connect_no_Img" value="/img/connect_no.png" styleClass="pic" rendered="#{serialThread.connected == 0}" />
      `

      But I am getting...

      FacesException: javax.el.PropertyNotFoundException: /layout/menu.xhtml @11,136 rendered="#{serialThread.connected == 1}": Property 'connected' not found on type org.javassist.tmp.java.lang.Object_$$_javassist_0

      What should I do to make this work? Couldnt I reference serialThread like I do to other typs of bean?







        • 1. Re: Stateless bean property access
          Leo van den berg Master

          Hi,


          you have a conflict in your bean definition. You tell the container that the bean is stateless (so it create and destroy when it to do so) and a ApplicationScope without an AutoCreate. First of all. I would NOT put a serial port adapter directly in the seam evnironment with a EJB bean (this is in conflict, because the bean is not allowed to handle its own threads (EJB3 spec)


          First make it a POJO and test is as a Application scoped bean, but far better, make it a separate process and start it as a separate service.


          Leo