8 Replies Latest reply on Mar 13, 2010 1:08 AM by Dean Hiller

    do NOT use XA datasources with Seam!!!!!

    Dean Hiller Expert

      If your database goes down(and at some point it will...evil laugh), no static pages including your /error.xhtml page will be accessible with XA....fun....

      Using postgres JDBC driver(non-XA)..works fine...using oracle JDBC driver...not so fine, but you can write a proxy to only do commits if sql was run(just create a proxy with a dirty flag) which fixes the problem and we did that while we were not using XA.

      With XA Datasource's(postgres AND oracle tested) however, I have been in one big nightmare the past day!!!!  I tried a proxy and to not open connection until was absolutely needed, BUT jboss/seam calls getTransactionIsolation on every http request forcing me to open a connection immediately which fails when the database is down meaning I then needed to move my static pages to JSF outside of seam to protected them, BUT I wanted to leverage pages.xml and exception handling there so I tried redirect url="" on ViewExpiredException which is a common case....it completely did not work.

      I then moved to another trick where I use <http-error error-code="591" /> and in web.xml file, I add the page to display.  In my testing in tomcat just using postgres driver, all was fine.  I then moved to jboss5.1.0 which is our platform and well, it results in a completely blank page.

      I have not been able to solve this problem at all.  AFAIK, seam 2.2.0 does not work with XA at all very well even with workarounds. 

      It works great with postgres JDBC though.  Has anyone else tested their database going down AFTER startup is finished? 

      We also ran tests on exceptions in setters vs. getters vs. action methods vs. login which all resulted in different results(2 of the 4 were broken and did not work properly redirecting user to the /error.xhtml page :( ).

      I have filed bugs in seam database on both of these issues of course but would love to hear from others here and their experiences????

      Test your DB outage!!!!!

      fun fun fun....I wish I wish I wish.


        • 1. Re: do NOT use XA datasources with Seam!!!!!
          Craig Bensemann Novice

          Hi Dean,

          After reading your post I thought oh no! and promptly went and shutdown my DB to test the application I'm currently working on. I'm using mysql 5.1.38 with an XA datasource. After shutting down mysql seam immediately logs the loss of connection however all static content (images and xhtml pages without DB access) still render fine. When attempting to connect to the DB to login etc you are redirected to a page and a nice message of connection refused is displayed - which is what I would expect given that the DB is down. :)

          So unless I've missed the point it appears that seam + mysql + XA works just fine.

          MySQL might be worth a try if you are not tied to either postgres or oracle.


          • 2. Re: do NOT use XA datasources with Seam!!!!!
            Dean Hiller Expert

            I am jealous ;).  I assume the page you are redirected to is a typical facelets/seam error.xhtml page or some sort, correct? 

            and you are using the exception handlers in pages.xml, correct?

            (ie. just hoping maybe I could steal a way to workaround this from you).

            thanks for responding with info on mysql!!!


            • 3. Re: do NOT use XA datasources with Seam!!!!!
              Tomaz Cerar Master


              I also have no problems using MS SQL server 2000,2005 or 2008, same goes for Postgres 8.3 and up
              XA data sources work just fine.. I had some minor problems with my code with it but nothing with seam...

              Must be oracle jdbc problem, which wouldnt surprise me too much :)


              • 4. Re: do NOT use XA datasources with Seam!!!!!
                Dean Hiller Expert

                Tomaz, I thought I tested postgres XA...I know postgres JDBC worked fine.  You are using XA ds not JDBC with postgres, right?

                Also, your test is logging in while the db is down results in a nice error page from seam, correct?  (maybe I messed my postgres XA test up somehow but I could have sworn it tried to open a db connection when any http request came in for every request which ended in infinite redirect).


                • 5. Re: do NOT use XA datasources with Seam!!!!!
                  Craig Bensemann Novice

                  Happy to help if I can. Am about to go away for a couple of days though (back sunday). But briefly - Yes the page I redirect users back to on error is the home.xhtml page where I display error/info messages and it is defined as the page to go to for exceptions in pages.xhtml. Am happy to provide code examples on my return if needed.


                  • 6. Re: do NOT use XA datasources with Seam!!!!!
                    Dean Hiller Expert

                       can you run this full test case...(I beleive this new test case fails for all databases including yours but wanted to verify)...

                    Full test case discovered has to be specifically run this way
                    1. hit a web page in your app
                    2. take down the database
                    3. hit a web page in your app
                    RESULT A: goes to a a nice error page
                    our result when adding check-valid-connection-sql was getting infinite redirect regardless of postgres or oracle now
                    4. bring db back up
                    5. hit a web page
                    RESULT B: app works again
                    our result 'without' check-valid-connection-sql was the connection was hosed and never worked again.

                    ie. we needed check-valid for result B but then needed to go solve the infinite redirect problem.

                    • 7. Re: do NOT use XA datasources with Seam!!!!!
                      Craig Bensemann Novice

                      Sorry for the delay. I'm happy to check this for you but I had a major hardware failure a couple of days ago and am busy rebuilding. Am back on deck today and will hopefully get to this soon.

                      • 8. Re: do NOT use XA datasources with Seam!!!!!
                        Dean Hiller Expert

                        thanks, we did work around it but the solution is not as clean as it would be had this test case worked to begin with :(.  I will be looking forward to your results...I can be patient now that we have a hack in place for this.