6 Replies Latest reply on Aug 1, 2008 9:05 AM by Ales Justin

    Diff behavior with diff AnnotatedMetaDataDeployer

    Ales Justin Master

      I'm testing new AnnotationMetaDataDeployer impl.
      But none of them seems to work for me. ;-(
      And I don't see what's so different between the new one's and the old one.

      This is what the old one processes:

      2008-07-30 19:16:49,203 TRACE [org.jboss.deployment.AnnotationMetaDataDeployer] (RMI TCP Connection(4)-127.0.0.1) Annotated classes:
      
      {ZipEntryHandler@22643817[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/BookingListAction.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/BookingListAction.class]=class org.jboss.seam.example.booking.BookingListAction,
      
      ZipEntryHandler@264752[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/AuthenticatorAction.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/AuthenticatorAction.class]=class org.jboss.seam.example.booking.AuthenticatorAction,
      
      ZipEntryHandler@20505518[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/HotelSearching.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/HotelSearching.class]=interface org.jboss.seam.example.booking.HotelSearching,
      
      ZipEntryHandler@32234525[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/HotelBooking.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/HotelBooking.class]=interface org.jboss.seam.example.booking.HotelBooking,
      
      ZipEntryHandler@29367791[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/HotelSearchingAction.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/HotelSearchingAction.class]=class org.jboss.seam.example.booking.HotelSearchingAction,
      
      ZipEntryHandler@32334045[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/Register.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/Register.class]=interface org.jboss.seam.example.booking.Register,
      
      ZipEntryHandler@24281983[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/ChangePasswordAction.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/ChangePasswordAction.class]=class org.jboss.seam.example.booking.ChangePasswordAction,
      
      ZipEntryHandler@18298829[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/HotelBookingAction.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/HotelBookingAction.class]=class org.jboss.seam.example.booking.HotelBookingAction,
      
      ZipEntryHandler@22061158[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/Booking.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/Booking.class]=class org.jboss.seam.example.booking.Booking,
      
      ZipEntryHandler@5415906[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/Hotel.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/Hotel.class]=class org.jboss.seam.example.booking.Hotel,
      
      ZipEntryHandler@25521003[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/ChangePassword.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/ChangePassword.class]=interface org.jboss.seam.example.booking.ChangePassword,
      
      ZipEntryHandler@5208070[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/User.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/User.class]=class org.jboss.seam.example.booking.User,
      
      ZipEntryHandler@22088318[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/RegisterAction.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/RegisterAction.class]=class org.jboss.seam.example.booking.RegisterAction,
      
      ZipEntryHandler@25684047[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/Authenticator.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/Authenticator.class]=interface org.jboss.seam.example.booking.Authenticator,
      
      ZipEntryHandler@27568558[path=jboss-seam-booking.jar/org/jboss/seam/example/booking/BookingList.class context=file:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear real=vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar/org/jboss/seam/example/booking/BookingList.class]=interface org.jboss.seam.example.booking.BookingList}
      


      The already existing AltAMDD:
      2008-07-30 19:42:37,015 TRACE [org.jboss.deployment.AltAnnotationMetaDataDeployer] (RMI TCP Connection(4)-127.0.0.1) Annotated classes:
      
      class org.jboss.seam.persistence.HibernateSessionProxyInterceptor,
      class org.jboss.seam.example.booking.BookingListAction,
      class org.jboss.seam.example.booking.RegisterAction,
      class org.jboss.seam.async.TimerServiceDispatcher,
      class org.jboss.seam.framework.EntityNotFoundException,
      class org.jboss.seam.security.AuthorizationException,
      interface org.jboss.seam.example.booking.HotelSearching,
      interface org.jboss.seam.example.booking.Register,
      class org.jboss.seam.example.booking.Booking,
      interface org.jboss.seam.async.LocalTimerServiceDispatcher,
      class org.jboss.seam.example.booking.HotelBookingAction,
      class org.jboss.seam.example.booking.HotelSearchingAction,
      class org.jboss.seam.example.booking.AuthenticatorAction,
      class org.jboss.seam.security.NotLoggedInException,
      class org.jboss.seam.transaction.EjbSynchronizations,
      class org.jboss.seam.example.booking.User,
      class org.jboss.seam.example.booking.Hotel,
      interface org.jboss.seam.example.booking.Authenticator,
      class org.jboss.seam.persistence.EntityManagerProxyInterceptor,
      class org.jboss.seam.intercept.SessionBeanInterceptor,
      interface org.jboss.seam.transaction.LocalEjbSynchronizations,
      interface org.jboss.seam.example.booking.ChangePassword,
      class org.jboss.seam.mock.MockSecureEntity,
      class org.jboss.seam.example.booking.ChangePasswordAction,
      interface org.jboss.seam.example.booking.HotelBooking,
      interface org.jboss.seam.example.booking.BookingList
      


      And my new Opt (code in next post):
      2008-07-30 17:17:31,625 TRACE [org.jboss.deployment.OptAnnotationMetaDataDeployer] (RMI TCP Connection(4)-127.0.0.1) Annotated classes [AbstractVFSDeploymentContext@22869899{vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear}, org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator@78049b]:
      
      org.jboss.seam.example.booking.AuthenticatorAction,
      org.jboss.seam.example.booking.BookingListAction,
      org.jboss.seam.example.booking.ChangePasswordAction,
      org.jboss.seam.example.booking.HotelBookingAction,
      org.jboss.seam.example.booking.HotelSearchingAction,
      org.jboss.seam.example.booking.RegisterAction,
      
      org.jboss.seam.async.TimerServiceDispatcher,
      org.jboss.seam.transaction.EjbSynchronizations,
      
      org.jboss.seam.framework.EntityNotFoundException,
      org.jboss.seam.security.AuthorizationException,
      org.jboss.seam.security.NotLoggedInException]
      


      All this runs on the trunk versions of deployers, cl, vfs, microcontainer.

      What does the old one do differently with classes that alternative two don't?
      Isn't it all just about the classes you push to creators?
      And with my Opt this should be optimized/good?

        • 1. Re: Diff behavior with diff AnnotatedMetaDataDeployer
          Ales Justin Master

          Opt:

          public class OptAnnotationMetaDataDeployer extends AnnotationMetaDataDeployer
          {
           public OptAnnotationMetaDataDeployer()
           {
           super();
           setInput(AnnotationEnvironment.class);
           }
          
           protected void processMetaData(VFSDeploymentUnit unit, WebMetaData webMetaData, ApplicationClientMetaData clientMetaData, List<VirtualFile> classpath) throws Exception
           {
           AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
           if(webMetaData != null)
           {
           processJBossWebMetaData(unit, finder);
           }
           else
           {
           if (clientMetaData != null)
           {
           processJBossClientMetaData(unit, finder);
           }
           else
           {
           String mainClassName = getMainClassName(unit);
           if (mainClassName != null)
           {
           processJBossClientMetaData(unit, finder);
           }
           else
           {
           processJBossMetaData(unit, finder);
           }
           }
           }
           }
          
           /**
           * Process jboss web meta data.
           *
           * @param unit the deployment unit
           * @param finder the finder
           */
           protected void processJBossWebMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder)
           {
           Web25MetaDataCreator creator = new Web25MetaDataCreator(finder);
           Collection<Class<?>> classes = getClasses(unit, creator);
           WebMetaData annotationMetaData = creator.create(classes);
           if(annotationMetaData != null)
           unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, WebMetaData.class);
           }
          
           /**
           * Process jboss app client meta data.
           *
           * @param unit the deployment unit
           * @param finder the finder
           */
           protected void processJBossClientMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder)
           {
           ApplicationClient5MetaDataCreator creator = new ApplicationClient5MetaDataCreator(finder);
           Collection<Class<?>> classes = getClasses(unit, creator);
           ApplicationClientMetaData annotationMetaData = creator.create(classes);
           if(annotationMetaData != null)
           unit.addAttachment(CLIENT_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, ApplicationClientMetaData.class);
           }
          
           /**
           * Process jboss meta data.
           *
           * @param unit the deployment unit
           * @param finder the finder
           */
           protected void processJBossMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder)
           {
           // Create the metadata model from the annotations
           JBoss50Creator creator = new JBoss50Creator(finder);
           Collection<Class<?>> classes = getClasses(unit, creator);
           JBossMetaData annotationMetaData = creator.create(classes);
           if(annotationMetaData != null)
           unit.addAttachment(EJB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, JBossMetaData.class);
           }
          
           /**
           * Get the classes for creator to process.
           *
           * @param unit the deployment unit
           * @param creator the creator
           * @return classes to process
           */
           @SuppressWarnings("unchecked")
           protected Collection<Class<?>> getClasses(VFSDeploymentUnit unit, AbstractCreator creator)
           {
           boolean trace = log.isTraceEnabled();
          
           AnnotationEnvironment env = unit.getAttachment(AnnotationEnvironment.class);
           if (env == null)
           {
           if (trace)
           log.trace("Cannot scan classes, missing AnnotationEnvironment as attachment: " + unit.getName());
          
           return Collections.emptySet();
           }
          
           String creatorInfo = creator.toString();
           AnnotationContext context = creator.getAnnotationContext();
           Set<Class<?>> classes = new HashSet<Class<?>>();
          
           Collection<Class<? extends Annotation>> typeAnnotations = context.getTypeAnnotations();
           if (trace)
           log.trace("Creator: " + creatorInfo + ", type annotations: " + typeAnnotations);
           for(Class<? extends Annotation> annotation : typeAnnotations)
           {
           Class<Annotation> annotationClass = (Class<Annotation>)annotation;
           Set<Element<Annotation, Class<?>>> elements = env.classIsAnnotatedWith(annotationClass);
           for(Element<Annotation, Class<?>> elt : elements)
           classes.add(elt.getOwner());
           }
          
           Collection<Class<? extends Annotation>> methodAnnotations = context.getMethodAnnotations();
           if (trace)
           log.trace("Creator: " + creatorInfo + ", method annotations: " + methodAnnotations);
           for(Class<? extends Annotation> annotation : methodAnnotations)
           {
           Class<Annotation> annotationClass = (Class<Annotation>)annotation;
           Set<Element<Annotation, Method>> elements = env.classHasMethodAnnotatedWith(annotationClass);
           for(Element<Annotation, Method> elt : elements)
           classes.add(elt.getOwner());
           }
          
           Collection<Class<? extends Annotation>> fieldAnnotations = context.getFieldAnnotations();
           if (trace)
           log.trace("Creator: " + creatorInfo + ", field annotations: " + fieldAnnotations);
           for(Class<? extends Annotation> annotation : fieldAnnotations)
           {
           Class<Annotation> annotationClass = (Class<Annotation>)annotation;
           Set<Element<Annotation, Field>> elements = env.classHasFieldAnnotatedWith(annotationClass);
           for(Element<Annotation, Field> elt : elements)
           classes.add(elt.getOwner());
           }
          
           if (trace)
           log.trace("Annotated classes [" + unit.getName() + ", " + creatorInfo + "]: " + classes);
          
           return classes;
           }
          }
          


          • 2. Re: Diff behavior with diff AnnotatedMetaDataDeployer
            Ales Justin Master

             

            "alesj" wrote:

            But none of them seems to work for me. ;-(

            This is the error:
            2008-07-30 20:18:30,593 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (RMI TCP Connection(4)-127.0.0.1) Error installing to Start: name=jboss.j2ee:ear=jboss-seam-booking.ear,jar=jboss-seam-booking.jar,name=HotelSearchingAction,service=EJB3 state=Create
            java.lang.NullPointerException
             at javax.naming.NameImpl.<init>(NameImpl.java:264)
             at javax.naming.CompoundName.<init>(CompoundName.java:187)
             at org.jnp.interfaces.NamingParser.parse(NamingParser.java:62)
             at org.jboss.util.naming.Util.rebind(Util.java:116)
             at org.jboss.ejb3.proxy.factory.BaseSessionProxyFactory.bindProxy(BaseSessionProxyFactory.java:192)
             at org.jboss.ejb3.proxy.factory.stateful.BaseStatefulProxyFactory.start(BaseStatefulProxyFactory.java:104)
             at org.jboss.ejb3.proxy.factory.stateful.StatefulLocalProxyFactory.start(StatefulLocalProxyFactory.java:136)
             at org.jboss.ejb3.session.ProxyDeployer.start(ProxyDeployer.java:135)
             at org.jboss.ejb3.session.SessionContainer.lockedStart(SessionContainer.java:188)
             at org.jboss.ejb3.stateful.StatefulContainer.lockedStart(StatefulContainer.java:286)
             at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:855)
            

            And
            jboss.j2ee:ear=jboss-seam-booking.ear,jar=jboss-seam-booking.ear,name=ChangePasswordAction,service=EJB3 -> java.lang.IllegalArgumentException: Can't find a persistence unit named '' in AbstractVFSDeploymentContext@21034618{vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear}
            
            jboss.j2ee:ear=jboss-seam-booking.ear,jar=jboss-seam-booking.ear,name=RegisterAction,service=EJB3 -> java.lang.IllegalArgumentException: Can't find a persistence unit named 'null' in AbstractVFSDeploymentContext@21034618{vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear}
            


            Probably meaning that not enough information is passed into EJB3 metadata.

            • 3. Re: Diff behavior with diff AnnotatedMetaDataDeployer
              Emanuel Muckenhuber Master

               

              "alesj" wrote:

              Isn't it all just about the classes you push to creators?
              And with my Opt this should be optimized/good?

              That should be fine.. much smarter now :)
              The current annotation deployer actually just do hasAnnotation() on the class, method, field and so on...

              The only difference i can see in the behaviour is:
              "alesj" wrote:

              jboss.j2ee:ear=jboss-seam-booking.ear,jar=jboss-seam-booking.ear,name=ChangePasswordAction,service=EJB3 -> java.lang.IllegalArgumentException: Can't find a persistence unit named '' in AbstractVFSDeploymentContext@21034618{vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear}
              



              with the current annotation deployer it's smth like:

              jboss.j2ee:ear=jboss-seam-booking.ear,jar=jboss-seam-booking.jar,name=ChangePasswordAction,service=EJB3


              note: the jar=jboss-seam-booking.jar :)

              • 4. Re: Diff behavior with diff AnnotatedMetaDataDeployer
                Emanuel Muckenhuber Master

                 

                "emuckenhuber" wrote:

                note: the jar=jboss-seam-booking.jar :)


                basically what i wanted to say, is that i don't think it's going to work if the annotated meta data gets processed for the whole ear.
                This seems to be the case now ?


                • 5. Re: Diff behavior with diff AnnotatedMetaDataDeployer
                  Ales Justin Master

                   

                  "emuckenhuber" wrote:
                  "emuckenhuber" wrote:

                  note: the jar=jboss-seam-booking.jar :)


                  basically what i wanted to say, is that i don't think it's going to work if the annotated meta data gets processed for the whole ear.
                  This seems to be the case now ?

                  You are right. :-)
                  I know what the problem is, and what the proper fix should look like.
                  All discussed with Adrian today - on our Slovenia walkabout :-).

                  • 6. Re: Diff behavior with diff AnnotatedMetaDataDeployer
                    Ales Justin Master

                     

                    "alesj" wrote:
                    I know what the problem is, and what the proper fix should look like.

                    Fixed, and it works like a charm :-)
                    2008-08-01 14:54:30,625 TRACE [org.jboss.deployment.OptAnnotationMetaDataDeployer] (RMI TCP Connection(4)-127.0.0.1) Annotated classes [vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam.jar, org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator@146a226]: [class org.jboss.seam.security.NotLoggedInException, class org.jboss.seam.security.AuthorizationException, class org.jboss.seam.framework.EntityNotFoundException, class org.jboss.seam.async.TimerServiceDispatcher, class org.jboss.seam.transaction.EjbSynchronizations]
                    
                    2008-08-01 14:54:30,578 TRACE [org.jboss.deployment.OptAnnotationMetaDataDeployer] (RMI TCP Connection(4)-127.0.0.1) Annotated classes [vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.jar, org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator@7962ea]: [class org.jboss.seam.example.booking.ChangePasswordAction, class org.jboss.seam.example.booking.AuthenticatorAction, class org.jboss.seam.example.booking.RegisterAction, class org.jboss.seam.example.booking.HotelSearchingAction, class org.jboss.seam.example.booking.BookingListAction, class org.jboss.seam.example.booking.HotelBookingAction]
                    
                    2008-08-01 14:54:30,562 TRACE [org.jboss.deployment.OptAnnotationMetaDataDeployer] (RMI TCP Connection(4)-127.0.0.1) Annotated classes [vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear/jboss-seam-booking.war, org.jboss.metadata.annotation.creator.web.Web25MetaDataCreator@a72445]: []
                    
                    2008-08-01 14:54:30,546 TRACE [org.jboss.deployment.OptAnnotationMetaDataDeployer] (RMI TCP Connection(4)-127.0.0.1) Annotated classes [vfszip:/C:/projects/jboss5/trunk/testsuite/output/lib/jboss-seam-booking.ear, org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator@5fb7c4]: []