3 Replies Latest reply on Jun 2, 2009 8:07 AM by Nicklas Karlsson

    Event test

    fiorenzo pizza Newbie

      Hi,


      i'm testing JSR 299 event mechanism (in jboss-5.1.0.GA), with a stupid example.
      A simple JSF Handler (NoteHandler) with property 'note'.


      I want fire a new event (in a internal method of NoteHandler and in other jsf handler NoteObserver)  when the NoteHandler change note value.
      If i don't use @SessionScoped notation for NoteHandler, my example work correctly, but if i use @SessionScoped, at deploy time, thi is the error:




      00:54:33,231 ERROR [AbstractKernelController] Error installing to Start: name=vfsfile:/usr/jboss/jboss-5.1.0.GA/server/webbeans/deploy/prenotazioniScooter.ear/_WebBeansBootstrapBean state=Create
      javax.inject.UnserializableDependencyException: The bean Session scoped simple bean 'osservato' it.reservations.web.Osservato,  API types = [Osservato, Object, Serializable], binding types = [@Current] declares a passivating scopes but has non-serializable dependency: Built-in implicit javax.event.Event bean
           at org.jboss.webbeans.BeanValidator.validate(BeanValidator.java:129)
           at org.jboss.webbeans.bootstrap.WebBeansBootstrap.boot(WebBeansBootstrap.java:207)
           at org.jboss.webbeans.bootstrap.api.helpers.BootstrapBean.boot(BootstrapBean.java:120)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
           at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
           at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
           at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
           at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
           at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
           at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
           at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
           at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
           at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
           at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
           at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
           at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
           at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
           at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
           at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121)
           at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)
           at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
           at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
           at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
           at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
           at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
           at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
           at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
           at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362)
           at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
           at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
           at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
           at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
           at java.lang.Thread.run(Thread.java:619)




      Where is my error??


      Thanks,


      Fiorenzo


      NoteHandler:


      @Named
      @SessionScoped
      public class NoteHandler implements Serializable {
      
           private String note;
      
           private boolean editMode;
      
           @Fires
           Event<ChangeNoteEvent> event;
      
           public NoteHandler() {}
      
           public String addNote1() {
                System.out.println("addNote1");
                setNote("");
                setEditMode(false);
                return "/test/test.xhtml";
           }
      
           public String addNote2() {
                System.out.println("addNote2");
                event.fire(new ChangeNoteEvent(getNote()),
                          new AnnotationLiteral<Created>() {
                          });
                return "/test/testOk.xhtml";
           }
      
           public String modNote1() {
                System.out.println("modNote1");
                setEditMode(true);
                return "/test/test.xhtml";
           }
      
           public String modNote2() {
                System.out.println("modNote2");
                setEditMode(false);
                event.fire(new ChangeNoteEvent(getNote()),
                          new AnnotationLiteral<Updated>() {
                          });
                return "/test/testOk.xhtml";
           }
      
           public String getNote() {
                return note;
           }
      
           public void setNote(String note) {
                System.out.println("setNote: " + note);
                this.note = note;
      
           }
      
           public void afterCreated(@Observes @Created ChangeNoteEvent event) {
                System.out.println("Osservato - CREAZIONE: " + event.getNote());
           }
      
           public void afterUpdated(@Observes @Updated ChangeNoteEvent event) {
                System.out.println("Osservato - UPDATE: " + event.getNote());
           }
      
           public boolean isEditMode() {
                return editMode;
           }
      
           public void setEditMode(boolean editMode) {
                this.editMode = editMode;
           }
      
      }
      



      NoteObserver:


      @Named
      @SessionScoped
      public class NoteObserver implements Serializable {
      
           public NoteObserver() {
                // TODO Auto-generated constructor stub
           }
      
           public void afterCreated(@Observes @Created ChangeNoteEvent event) {
                System.out.println("NoteObserver - @Created: " + event.getNote());
           }
      
           public void afterUpdated(@Observes @Updated ChangeNoteEvent event) {
                System.out.println("NoteObserver - @Updated: " + event.getNote());
           }
      }




      ChangeNoteEvent:


      public class ChangeNoteEvent implements Serializable {
      
           private String note;
      
           public ChangeNoteEvent() {
      
           }
      
           public ChangeNoteEvent(String note) {
                this.note = note;
           }
      
           public String getNote() {
                return note;
           }
      
           public void setNote(String note) {
                this.note = note;
           }
      
      }



        • 1. Re: Event test
          Gavin King Master

          certainly looks like a bug in the RI

          • 2. Re: Event test
            fiorenzo pizza Newbie

            Little Update...


            if i use:



            @Current 
            Manager manager;



            and




            manager.fireEvent(new ChangeNoteEvent(getNote()),
                                new AnnotationLiteral<Created>() {
                                });





            IT WORKS!


            Now I can sleep peaceful!


            Fiorenzo




            @Named
            @SessionScoped
            public class NoteHandler implements Serializable {
            
                 private String note;
            
                 private boolean editMode;
            
                 @Current
                 Manager manager;
            
            //     @Fires
            //     Event<ChangeNoteEvent> event;
            
                 public NoteHandler() {
                      // TODO Auto-generated constructor stub
                 }
            
                 public String addNote1() {
                      System.out.println("addNote1");
                      setNote("");
                      setEditMode(false);
                      return "/test/test.xhtml";
                 }
            
                 public String addNote2() {
                      System.out.println("addNote2");
            //          event.fire(new ChangeNoteEvent(getNote()),
            //                    new AnnotationLiteral<Created>() {
            //                    });
                      manager.fireEvent(new ChangeNoteEvent(getNote()),
                                new AnnotationLiteral<Created>() {
                                });
                      return "/test/testOk.xhtml";
                 }
            
                 public String modNote1() {
                      System.out.println("modNote1");
                      setEditMode(true);
                      return "/test/test.xhtml";
                 }
            
                 public String modNote2() {
                      System.out.println("modNote2");
                      setEditMode(false);
                      manager.fireEvent(new ChangeNoteEvent(getNote()),
                                new AnnotationLiteral<Updated>() {
                                });
            //          event.fire(new ChangeNoteEvent(getNote()),
            //                    new AnnotationLiteral<Updated>() {
            //                    });
                      return "/test/testOk.xhtml";
                 }
            
                 public String getNote() {
                      return note;
                 }
            
                 public void setNote(String note) {
                      System.out.println("setNote: " + note);
                      this.note = note;
            
                 }
            
                 public void afterCreated(@Observes @Created ChangeNoteEvent event) {
                      System.out.println("Osservato - CREAZIONE: " + event.getNote());
                 }
            
                 public void afterUpdated(@Observes @Updated ChangeNoteEvent event) {
                      System.out.println("Osservato - UPDATE: " + event.getNote());
                 }
            
                 public boolean isEditMode() {
                      return editMode;
                 }
            
                 public void setEditMode(boolean editMode) {
                      this.editMode = editMode;
                 }
            
            }



            • 3. Re: Event test
              Nicklas Karlsson Master

              Yes, but the built-in Event bean not being serializable still sounds strange so a JIRA would be appreciated