2 Replies Latest reply on Sep 28, 2006 5:28 AM by Widura Schwittek

    Problem in Booking Ex. from Seam 1.0.1 GA causes misbehaviou

    Widura Schwittek Newbie

      Hello,

      I am getting in touch with Seam intensively for days now and I'm already seriously addicted to this, I think, outstanding framework. But during experimenting I ran over a misbehaviour I cannot explain. The booking example shipped with Seam 1.0.1 GA doesn't correctly display the "Current Hotel Bookings" after a successful new booking. You need to login again to see the "Current Hotel Bookings" or book another hotel. But in latter case the recent booking isn't displayed either.

      So I played around a bit by calling the factory method "getBookings()" in BookingListAction explicitly after "booking confirmation" (see the code block) but no change.

      @In
       HotelBooking bookingList;
      
       ...
      
       @End
       public String confirm(User user)
       {
       if (booking==null || hotel==null) return "main";
       em.persist(booking);
       facesMessages.add("Thank you, #{user.name}, your confimation number for #{hotel.name} is #{booking.id}");
       log.info("New booking: #{booking.id} for #{user.username}");
       bookingList.getBookings();
       events.raiseEvent("bookingConfirmed");
       return "confirmed";
       }


      Fortunatly I've recognized that the Online Example on the Seam website does function properly. So I downloaded the latest nightly build (23.09.2006). But it seems like new taglib syntax is introduced since the last stable release. Ex.:
      <s:link value="View Hotel" action="#{hotelBooking.selectHotel(hotelSearch.selectedHotel)}"/>


      Even though it is not possible to run the example with the bundled Seam Jars shipped within this nightly build because of syntactical errors caused i.e by above code block. So could someone please tell me, where the problem is/was and on which nightly build the working example on the Seam website is based on.

      Thanks in advance,

      Widura

        • 1. Re: Problem in Booking Ex. from Seam 1.0.1 GA causes misbeha
          Gavin King Master

           

          "widura" wrote:
          I am getting in touch with Seam intensively for days now and I'm already seriously addicted to this, I think, outstanding framework. But during experimenting I ran over a misbehaviour I cannot explain. The booking example shipped with Seam 1.0.1 GA doesn't correctly display the "Current Hotel Bookings" after a successful new booking. You need to login again to see the "Current Hotel Bookings" or book another hotel. But in latter case the recent booking isn't displayed either.


          Are you *sure*, I find this difficult to believe.

          • 2. Re: Problem in Booking Ex. from Seam 1.0.1 GA causes misbeha
            Widura Schwittek Newbie

            Indeed, you're right! After deploying the original Seam 1.0.1 GA Booking Example I haven't encountered this problem again. So I tried to figure out what my problem is. The only thing I changed in the booking example was the booking-ds.xml which I defined to use a MySQL Database as datasource:

            <?xml version="1.0" encoding="UTF-8"?>
            <datasources>
             <local-tx-datasource>
             <jndi-name>bookingDatasource</jndi-name>
             <connection-url>jdbc:mysql://localhost:3306/seam-booking</connection-url>
             <driver-class>com.mysql.jdbc.Driver</driver-class>
             <user-name>syscom</user-name>
             <password>ysy758</password>
             </local-tx-datasource>
            </datasources>


            I am using MySQL 5.0.11 and the MySQL Connector 3.1.13. To sum it up: The misbehaviour does exist but only when using MySQL as datasource with the configuration above. And it must have to do something with transactions. Because after commenting out @TransactionAttribute(REQUIRES_NEW) in BookingListAction everything worked out again.

            Then I checked if my database tables support transactions and they do by being InnoDB tables. I also checked my persistence.xml which defines the appropriate MySQLInnoDB dialect.

            <persistence>
             <persistence-unit name="bookingDatabase">
             <provider>org.hibernate.ejb.HibernatePersistence</provider>
             <jta-data-source>java:/bookingDatasource</jta-data-source>
             <properties>
             <property name="hibernate.hbm2ddl.auto" value="create"/>
             <property name="hibernate.show_sql" value="true"/>
             <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
             <!-- These are the default for JBoss EJB3, but not for HEM: -->
             <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
             <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
             </properties>
             </persistence-unit>
            </persistence>


            Is there maybe something missing related to transactions in my datasource definition or anywhere else?

            Widura