1 2 Previous Next 29 Replies Latest reply on Aug 7, 2008 10:27 PM by sjmenden

    HOWTO - Run bookings example from Eclipse

    franciscoperedo

      Hi!
      I am trying to understand conversation-scoped extended persistence contexts, and, to do that, I decided to create my own example... but I coudln't make it work, so I decided to try the bookings example, but, since I develop my stuff using eclipse and jboss-tools I decided to create a new seam project from eclipse and copy the source from the bookings example inside it...


      But it doesn't work...


      After googling a while I found with this guide but seems to be very obsolete information.


      So I decided to compare my war with the war generated by running the example directly with ant...


      It turns out it is not a WAR!! it is an EAR!!!
      So I tried adding an EAR to my WorkSpace an linking my Seam project to it... and I was finally able to deploy succesfully... but as soon as I try to visit the index page i get:


      16:15:11,000 ERROR [SeamPhaseListener] uncaught exception
      java.lang.IllegalStateException: Could not commit transaction
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:602)
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:330)
           at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:231)
           at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:182)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.transaction.synchronizations
           at org.jboss.seam.Component.newInstance(Component.java:1970)
           at org.jboss.seam.Component.getInstance(Component.java:1873)
           at org.jboss.seam.Component.getInstance(Component.java:1852)
           at org.jboss.seam.Component.getInstance(Component.java:1846)
           at org.jboss.seam.transaction.AbstractUserTransaction.getSynchronizations(AbstractUserTransaction.java:79)
           at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:48)
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:592)
           ... 42 more
      Caused by: javax.naming.NameNotFoundException: EjbSynchronizations not bound
           at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
           at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
           at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
           at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
           at javax.naming.InitialContext.lookup(InitialContext.java:351)
           at org.jboss.seam.Component.instantiateSessionBean(Component.java:1287)
           at org.jboss.seam.Component.instantiate(Component.java:1273)
           at org.jboss.seam.Component.newInstance(Component.java:1966)
           ... 48 more
      



      After further examination of the EAR that is produced by using ant directly I realized that there was a major difference with my project... that EAR is composed by 2 sub modules: jboss-seam-booking.war and jboss-seam-booking.jar.


      But my project only has 1 sumodule:  booking.war.


      It seems that the offical bookings example project splits the java output and the xhtml/jsf pages in to places, and the file application.xml is aware of this and registers jboss-seam-booking.jar as an ejb module... but that is not possible with my eclipse aplication where everything is mixed in to the .war.


      What should I do? is it possible to use conversation-scoped extended persistence contexts like the ones in the booking example from an eclipse jboss tools based application? what am I missing?


      Regards,




        • 1. Re: HOWTO - Run bookings example from Eclipse
          ziphyre

          Hi,


          Can you tell which versions of Seam and JBoss AS do you use?
          If seam 2.0 and jboss 4.2 then here is what i do when I try an example in eclipse


          First, delete any project within eclipse related to booking
          example (remove these from your workspace directory and the server's deploy directory too)

          Download this:

          http://www.michaelyuan.com/download/seam/seambook-src-20071106.zip

          unzip


          Open eclipse, make a new plain empty project (Project under General, not a java or seam project)

          Right click to the created project, select import, then File System.
          In the next page select the booking folder (the one you unzipped from the seambook-src-20071106.zip) Click 'select all' and finish.


          Open build.xml file


          replace the line


          <property file="../build.properties"/>



          with


          <property name="jboss.home" location="path_to_your_jboss_home" />
          <property name="seam.home" location="path_to_your_jboss_home" />



          Replace the paths accordingly (must be absolute paths)

          Right click your build.xml file, Run As -  Ant Build... (with three points), on the targets tab, click main and deploy targets, run


          That must be it, hope this helps...


          • 2. Re: HOWTO - Run bookings example from Eclipse
            franciscoperedo

            Hi!
            Thanks a lot for answering...


            But I am sorry to tell that was no the answer I was looking for...
            I don't want to run the bookings example using ant inside eclipse
            I want it to became an eclipse project, as if it were created using JBossTools 2.0...


            I think my mistake was that I created the project as a WAR, and in the last step of the Seam wizard in eclipse, I should have selected EAR, that is why (I think) I can not use conversation-scoped extended persistence contexts.


            So I am going to try again, with a project created as EAR from the begining...


            Thanks again


            Regards,


            Francisco

            • 3. Re: HOWTO - Run bookings example from Eclipse
              maki96

              Is the zip folder from michael yuans website anywhere else available because the page is down?


              Thx

              • 4. Re: HOWTO - Run bookings example from Eclipse
                1womps1

                i followed step by step the instructions above,but i still can't make work the booking example with eclipse,the files are not compiled and eclipse doesn't notify any error,since it is not considered as a java project.please how can i make it work?

                • 5. Re: HOWTO - Run bookings example from Eclipse
                  sjmenden

                  The best way to run the booking example in Eclipse/JBoss Tools, is to create a new Seam web project  and manually copy the src/ view/ and configuration over to the new project.  It does work as I've done it several times to help with customer issues.


                  You should be able to do a WAR project, just convert any EJB3s to Seam JavaBeans and any PCs to SMPC, otherwise, do EAR.

                  • 6. Re: HOWTO - Run bookings example from Eclipse
                    admin.admin.email.tld

                    Whether using JBDS or MyEclipse, I create a java project based on the booking codebase (one high level folder, not 4 like the Seam project creation from the JBossTools).  I change the build path libs and re-build workspace and it just works after ant deploy or ant explode is run.


                    I wonder how many real Seam projects use that 4 high level project method?  must be based on WTP...

                    • 7. Re: HOWTO - Run bookings example from Eclipse
                      sjmenden

                      Many enterprise customers use the EAR projects actually, once you get use to it, it isn't a big deal, but, yes, it is a direct result of WTP.  It was a hard transition for me to go from 1 to 4 project folders, I'm use it it now personally, and I don't use that any more in testing, only WAR projects.


                      The best approach with JBDS, depending on one's needs is using a WAR project (Can't use EJB3).  Then you get hot-deploy of your Seam code with just a ctrl-s, can't beat that for turn around time.

                      • 8. Re: HOWTO - Run bookings example from Eclipse

                        And it is even faster if you use (Pure, no Embedded Jboss) Tomcat 6 instead of JBoss AS 4.2.x.

                        • 9. Re: HOWTO - Run bookings example from Eclipse
                          tony.herstell1

                          I have, for 18 months of using seam (or more!) only ever run as EAR mode in Exploded mode on MyEclipse (took a while to map all the files into their right place in the 3 projects Ear, EJB and WAR but well worth it).


                          I find it annoying that when I change an xhtml file I get something in Seam do soemthing in the server to do with that file at some random time later as its simply not needed as I work in exploded mode and just alter any of the files and that IS altering the files on the server so it just takes effect instantly. It annoys me I have to wait a minute for Seam to reload the file thats already happily been working since I changed it!


                          Anyhow, If you change an interface or core xml file then you have to click the red button (stop) and then the green button (start) to restart the server and you just carry on working.


                          I can't see what all the fuss is about.


                          Its amazingly quick to delelop this way.. No Ant/Maven scripts to run or any of that stuff at all (this was critical with the Richfaces stuff as its a lot of trial and error in xhmtl files)


                          I was going to do a Wink presentation and stick on MyEclipse site for example of how to develop quickly in Seam; but still not done it yet as I assumed everyone did it this way.


                          I can see a need for Ant/Maven if you drag in stuff from outside your project (but would fight hard to find a way not to do it).

                          • 10. Re: HOWTO - Run bookings example from Eclipse
                            sjmenden

                            And it is even faster if you use (Pure, no Embedded Jboss) Tomcat 6 instead of JBoss AS 4.2.x.

                            JBoss 4.2 should be close to if not identical in speed with Tomcat 6 at processing requests as JBossWeb is just a repackaged Tomcat 6. The added time comes from starting JBoss as additional services other than JBossWeb are started, but after they are started, that is it.

                            • 11. Re: HOWTO - Run bookings example from Eclipse

                              Samuel Mendenhall wrote on Aug 07, 2008 00:20:


                              And it is even faster if you use (Pure, no Embedded Jboss) Tomcat 6 instead of JBoss AS 4.2.x.

                              JBoss 4.2 should be close to if not identical in speed with Tomcat 6 at processing requests as JBossWeb is just a repackaged Tomcat 6. The added time comes from starting JBoss as additional services other than JBossWeb are started, but after they are started, that is it.



                              At processing requests as JBoss and Tomcat 6 are, as you say, close to if not identical in speed, but at development time, where time is lost not because of processing requests  but because one makes changes and needs to restart/redeploy, tomcat is significantly faster.


                              With JBoss it takes around 30 secs to (cold) start my application while in tomcat it takes just 8 seconds. Do it a couple of hundred times in a day, and you will find that the difference is very significant.


                              I hope this gets fixed in JBoss 5 (I have heard that the next version of Glassfish will be very impressive in this regard, starting cold in less than 3 seconds)

                              • 12. Re: HOWTO - Run bookings example from Eclipse

                                In my experience, EAR was painfully slow (application cold start in around 1 minute), WAR was better (application cold start in 30 seconds) but the best, is to switch to Tomcat (Without Jboss Embedded) (application cold start in 8 seconds)

                                • 13. Re: HOWTO - Run bookings example from Eclipse
                                  sjmenden

                                  I would love for you to experience JBoss Developer Studio (or Eclipse + JBossTools) with a Seam Web Project (WAR not EAR), it deploys in ~4 seconds, and hot-deploys are almost instantaneous (1-2 seconds by default for copying to the server which is adjustable).  Development time is blazing fast when using this combination.


                                  And the benefit with JBoss over Tomcat is you really never need to restart JBoss throughout the day considering you can hotdeploy your WARs or EARs, so you take one hit in the morning to start up JBDS and the EAP, then after that you just code, hot-deploy, and do a full publish of the way (4 seconds) when you need to add an entity or make some other modification that requires a full re-hot-deploy.


                                  Try it out, I think you'll be pleasantly surprised: http://www.jboss.com/products/devstudio


                                  Or the free JBossTools which you can install in Eclipse: http://wiki.jboss.org/wiki/JBossTools

                                  • 14. Re: HOWTO - Run bookings example from Eclipse

                                    Hi!



                                    Samuel Mendenhall wrote on Aug 07, 2008 04:11:


                                    I would love for you to experience JBoss Developer Studio (or Eclipse + JBossTools) with a Seam Web Project (WAR not EAR), it deploys in ~4 seconds, and hot-deploys are almost instantaneous (1-2 seconds by default for copying to the server which is adjustable).



                                    I am already using it (JBossTools 2.1.2) and do like it a lot, but not for its performance. I guess it depends on you machine, currently I am using a Core 2 Duo at 1.8 Ghz with 4Gbyets the RAM on Windows XP SP2 32-bit (so I can not take advantage of the 64bits of my processor and it only uses 3Gbytes, and, WAR takes between 25 and 30 secs to start (cold start). Hot-deploys do feel faster (around 3 to 4 secs) but the sad thing is that any changes to the entities prevent you from using hot deploy.



                                    Development time is blazing fast when using this combination.

                                    And the benefit with JBoss over Tomcat is you really never need to restart JBoss throughout the day considering you can hotdeploy your WARs or EARs, so you take one hit in the morning to start up JBDS and the EAP, then after that you just code, hot-deploy, and do a full publish of the way (4 seconds) when you need to add an entity or make some other modification that requires a full re-hot-deploy.



                                    That has not been my experience... the only way I know to do a a full re-hot-deploy is to touch web.xml (by writing a whitespace and then delete it, which is akward, I really wish somebody added a button for full re-hot-deploy ). Anyway, this touch web.xml takes around 15 to 20 seconds. (I still wonder, why Eclipse WTP doesn't have an easy start/stop button just for the application, not the whole app server, it would be nice featur to add to JBossTools)



                                    Try it out, I think you'll be pleasantly surprised: http://www.jboss.com/products/devstudio

                                    Or the free JBossTools which you can install in Eclipse: http://wiki.jboss.org/wiki/JBossTools


                                    As I wrote, I have alredy tried, it, and I was pleasantly surprised with it design time support for JSF and Facelets, and I like the wizard to create a Seam project, and I love its hibernate-tools based code generation, and the ability to run my hql queries directly in the IDE, and the code completion for EL expressions, and so on, but, performances is not, in my opinion, one of its strong points.


                                    Regards,

                                    1 2 Previous Next