4 Replies Latest reply on Aug 24, 2009 11:26 PM by asookazian

    WAR to EAR upgrade

    asookazian

      I have a WAR for now to take advantage of the incremental hot deploy of JavaBeans.  I may want to upgrade my project to an EAR to take advantage of EJB container services (like tx's, interceptors, EJB timers, etc.).


      What is the best/easiest way to upgrade?  I assume there is no seam-gen or ant target that handles this?

        • 1. Re: WAR to EAR upgrade

          Arbi Sookazian wrote on Aug 21, 2009 20:02:


          I have a WAR for now to take advantage of the incremental hot deploy of JavaBeans.  I may want to upgrade my project to an EAR to take advantage of EJB container services (like tx's, interceptors, EJB timers, etc.).


          What I did was to create a new EAR project with seam-gen, understood the differences in the project structure, and reorganized my WAR in to an EAR (only to go back to WAR because the project became sluggishly slow, and i found not use for any of the EJB features.


          So I am very curious:


          -EJB tx's only make sense if you need 2 phase commits... do you need them?
          -Interceptors... Seam already provides you with Interceptors..
          -EJB times... why do you need them? Seam alredy provides you with support for Asynchronous operations...



          What is the best/easiest way to upgrade?  I assume there is no seam-gen or ant target that handles this?


          Abandon Hope, All Ye Who Enter The EAR

          • 2. Re: WAR to EAR upgrade
            asookazian

            Nice comeback.  I was thinking I'd have to re-seam-gen the project skeleton and copy/paste, etc.


            You have some valid arguments.  I was watching an interview of Adam Bien (Java super star?) and he was saying that those who state that Java EE is overly complex do not understand the nature of distributed computing.  He then starts talking about transactions, concurrency management, etc.  Well, I'd say that Spring is overly complex as well (specifically AOP).


            I personally do not think that the tx propagation types are sufficient in Seam (i.e. lack of NOT_SUPPORTED).  They are sufficient in Spring and EJB 3.


            How can I write an interceptor that will output the amount of time to execute a business method using Seam interceptors?


            e.g. EJB interceptor for EJB business methods


            public class ProfilingInterceptor {
                 
                 Log log = Logging.getLog(ProfilingInterceptor.class); 
            
                @AroundInvoke
                public Object profile(InvocationContext ic) throws Exception {
                     
                     log.info("*** Entering method: " + ic.getMethod().getName());
                    
                    long startTime = 0;
                    long endTime = 0;
                    try {
                        startTime = System.currentTimeMillis();            
                        return ic.proceed();
                    } finally {
                        endTime = System.currentTimeMillis();
                        log.info("*** Method " + ic.getClass() + "." + ic.getMethod() + " executed in " + (endTime - startTime) + "ms ***");
                    }
                }
            }
            



            I am not really needing EJB 3 method level security, so that's not a big deal.  And perhaps you're correct about using @Asynchronous or Quartz instead of EJB 3 timers.


            The only other thing that EJB offers that I can think of is web services, SLSB instance pooling, JMS/MDB (what's the Seam equivalent?), and thread-safety (e.g., only one thread can access a session bean method at one time).


            So does Seam have all these bases covered?  And how does a JavaBean compare to a SFSB as a backing bean for a JSF page?  SFSBs are passivated to disk, what about Seam container-managed JavaBeans that are conversation-scoped?  Are they pooled or not?  How can I write/expose a web service (web method) in Seam without EJB?  And I'm not talking about Javascript remoting.


            Is the performance really much slower with EAR vs. WAR in Seam?

            • 3. Re: WAR to EAR upgrade

              Arbi Sookazian wrote on Aug 21, 2009 23:53:




              I personally do not think that the tx propagation types are sufficient in Seam (i.e. lack of NOT_SUPPORTED).  They are sufficient in Spring and EJB 3.


              Then, for your own sake, go for Spring and avoid EJB3.




              How can I write an interceptor that will output the amount of time to execute a business method using Seam interceptors?

              e.g. EJB interceptor for EJB business methods



              Just use org.jboss.seam.annotations.intercept.AroundInvoke



              I am not really needing EJB 3 method level security, so that's not a big deal.


              And AFAIK Seam also provides you with POJO method level security (without EJBs)...



              And perhaps you're correct about using @Asynchronous or Quartz instead of EJB 3 timers.


              Of course I am ;-)




              The only other thing that EJB offers that I can think of is web services,


              I use CeltiXFire + Spring in tomcat and I do not need to have any EJBs (and my app runs in Oc4j, Tomcat, and JBoss)



              SLSB instance pooling, JMS/MDB (what's the Seam equivalent?)


              I have never needed them... what feature in your app requires them?



              and thread-safety (e.g., only one thread can access a session bean method at one time).


              Seam @Syncronized annotation can do that... or not?



              So does Seam have all these bases covered?  And how does a JavaBean compare to a SFSB as a backing bean for a JSF page?  SFSBs are passivated to disk, what about Seam container-managed JavaBeans that are conversation-scoped?  Are they pooled or not?  How can I write/expose a web service (web method) in Seam without EJB?  And I'm not talking about Javascript remoting.

              Is the performance really much slower with EAR vs. WAR in Seam?


              I had an app with around 100 xhtml files, with EAR and EJBs in JBoss it took around 30 seconds to start, with POJOs in Tomcat it takes 10 seconds... you tell me what is faster.

              • 4. Re: WAR to EAR upgrade
                asookazian

                Thanks.  I got the Seam interceptor working (and wrote a custom annotation along the way!)