2 Replies Latest reply on Jul 3, 2008 5:00 PM by M. Parker

    SEAM, Remoting, SSB

    M. Parker Newbie

      I'm trying to access a Stateful Session Bean from an action this was activated via Seam's remoting library.

      Everytime I trigger the remote action, it creates a new SSB even though the Scope is set to SESSION. When the AS is shutdown, you can see the application server run through all the created beans when their destory method is called.

      Here is the code that I have setup. I have a bean to track a user's location in a display, which is defined as the following:

      public class DisplayBean implements Display {
           float left = 0f;
               float right = 0f;
               float top = 0f;
               float bottom = 0f;
           public DisplayBean(){
           public void destroy(){
                log.info("******** DESTROY DISPLAY BEAN **********");
                  public void init(){
                log.info("******** CREATING DISPLAY BEAN **********");
           public void dragMapWindow(double left, double bottom, double right, double top) {
                this.left = left;
                this.bottom = bottom;
                this.right = right;
                this.top = top;
      public interface Display {  
         public void init();
         public void destroy();
         public String dragMapWindow();  

      And the action used to manipulate the SSB.

      public class DragMapWindowAction implements DragMapWindow {
           @In @Out  
           protected Display display;
           protected Log log;
           public String execute(float left, float bottom, float right, float top) {
                log.info("Changing the map view to (" + left + ", " + bottom + ", "     + right + ", " + top + ")");
                if (display == null) {
                     log.info("CANNOT adjust display. Not found using paramaters.");
                } else {
                     log.info("Found DISPLAY.");
                return "";
      public interface DragMapWindow {
           public String execute(float left, float bottom, float right, float top);

      Here is the javascript code that is called by an OpenMap event handler:

                     // Used to retrieve data for the interface based on the map's extent.
                     function dragMapWindow(){
                          var extent = map.getExtent();
                               //Use SEAM Remoting to retrieve the data to fit the current window.
                          if ( extent != null ){                             
                              var viewbox = extent.toArray();
                              Seam.Component.getInstance("dragMapWindow").execute(viewbox[0], viewbox[1], viewbox[2], viewbox[3], generalCallback );                                        

      Here is the debug trace, where you can see the bean being repetively created:

      13:15:44,226 INFO  [Contexts] starting up: org.jboss.seam.web.session
      13:15:48,240 INFO  [Contexts] starting up: org.jboss.seam.security.identity
      13:15:48,240 INFO  [Contexts] starting up: org.jboss.seam.web.session
      13:15:48,256 INFO  [DisplayBean] **** CREATING DISPLAY BEAN ****
      13:15:48,271 INFO  [DragMapWindowAction] Changing the map view to (19.016113, -5.4370117, 60.983887, 15.437012)
      13:15:48,334 INFO  [DragMapWindowAction] Found DISPLAY.
      13:15:48,365 INFO  [AlarmGeneratorService] Adding global variables.
      13:15:48,365 INFO  [AlarmGeneratorService] Global variables defined in each package...1 found.
      13:15:48,365 INFO  [AlarmGeneratorService] Package userx
      13:15:48,365 INFO  [AlarmGeneratorService] userx alarmGeneratorService
      13:15:48,381 INFO  [AlarmGeneratorService] 4 alarm definitions added.
      13:15:48,381 INFO  [AlarmGeneratorService] Loading unalarmed data...
      13:15:50,474 INFO  [AlarmGeneratorService] Loading unalarmed convolved data...
      13:15:50,490 INFO  [AlarmGeneratorService] 4992 raw data points processed.
      13:16:15,905 INFO  [Contexts] starting up: org.jboss.seam.security.identity
      13:16:15,905 INFO  [Contexts] starting up: org.jboss.seam.web.session
      13:16:15,905 INFO  [DisplayBean] **** CREATING DISPLAY BEAN ****
      13:16:15,952 INFO  [DragMapWindowAction] Changing the map view to (-2.692871, -18.444824, 39.978027, 2.4291992)
      13:16:15,952 INFO  [DragMapWindowAction] Found DISPLAY.
      13:16:21,732 INFO  [Contexts] starting up: org.jboss.seam.security.identity
      13:16:21,732 INFO  [Contexts] starting up: org.jboss.seam.web.session
      13:16:21,748 INFO  [DisplayBean] **** CREATING DISPLAY BEAN ****
      13:16:21,748 INFO  [DragMapWindowAction] Changing the map view to (-9.240723, -23.3667, 33.430176, -2.4926758)
      13:16:21,748 INFO  [DragMapWindowAction] Found DISPLAY.

      This is all being called from within an OpenLayers event that is triggered when the user drags the map on a webpage, which is a JavaScript map library. Are there any restrictions to calling Seam components within the event structure of another JavaScript library? Is there something that must be initialized within SEAM to make this work with another JavaScript library? The code is called, but I cannot retrieve the SSB, which essentially destroys the session tracking.

      Any help you can provide would be greatly appreciated.