2 Replies Latest reply on Jul 26, 2006 6:16 PM by Martin Goik

    booking example and db2

    Martin Goik Newbie

      Starting the 'booking' example with 1.0.1 GA I tried to configure a db2 DB server. Following http://wiki.jboss.org/wiki/Wiki.jsp?page=SetUpADB2Datasource I changed booking-ds.xml to:


      My persistence.xml has an added DB2 dialect property:

       <persistence-unit name="bookingDatabase">
       <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
       <property name="hibernate.show_sql" value="true"/>
       <property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect"/>
       <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
       <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

      Starting the application on jboss-4.0.4.GA app. server I can register a new user, browse the list of available hotels. When I try to create a reservation I can still reach the "confirmation" window. But by clicking the "Confirm" button the application hangs.

      The corresponding log entries are:

      00:09:44,726 INFO [STDOUT] Hibernate: select user_.username, user_.name as name2_, user_.password as password2_ from User user_ where user_.username=?
      00:09:44,732 INFO [STDOUT] Hibernate: insert into Booking (id, user_username, checkinDate, checkoutDate, hotel_id, creditCard, smoking, beds, creditCardName, creditCardExpiryMonth, creditCardExpiryYear) values (default, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
      00:09:44,742 INFO [STDOUT] Hibernate: values identity_val_local()
      00:09:44,747 INFO [HotelBookingAction] New booking: 1 for goiki
      00:09:44,754 INFO [STDOUT] Hibernate: select booking0_.id as id0_, booking0_.user_username as user10_0_, booking0_.checkinDate as checkinD2_0_, booking0_.checkoutDate as checkout3_0_, booking0_.hotel_id as hotel11_0_, booking0_.creditCard as creditCard0_, booking0_.smoking as smoking0_, booking0_.beds as beds0_, booking0_.creditCardName as creditCa7_0_, booking0_.creditCardExpiryMonth as creditCa8_0_, booking0_.creditCardExpiryYear as creditCa9_0_ from Booking booking0_ where booking0_.user_username=? order by booking0_.checkinDate
      00:14:44,739 WARN [TransactionImpl] Transaction TransactionImpl:XidImpl[FormatId=257, GlobalId=goiki/32, BranchQual=, localId=32] timed out. status=STATUS_ACTIVE
      00:14:44,756 WARN [TransactionImpl] Transaction TransactionImpl:XidImpl[FormatId=257, GlobalId=goiki/33, BranchQual=, localId=33] timed out. status=STATUS_ACTIVE

      I can still access the 'User' and 'Hotel' tables via SQL. The 'booking' table cannot be accessed so there seems to be some sort of locked up transaction. There are definitely no other users accessing the RDBMS. Am I missing something?

      My system: Linux Fedora core 5, DB2 UDB 8.2, IBM's standard JDBC driver, SUN's java 1.5.0_07-b03 .

        • 1. Re: booking example and db2
          Stas Garifulin Newbie

          Got same problem with MSSQL and Derby on Glassfish.

          Booking conformation action handler (HotelBookingAction.confirm method) invokes BookingListAction.getBookings method to update bookings list used in main page after inserting new booking to DB:

          // HotelBookingAction.java
           public String confirm()
           if (booking==null || hotel==null) return "main";
           facesMessages.add("Thank you, #{user.name}, your confimation number for #{hotel.name} is #{booking.id}");
           log.info("New booking: #{booking.id} for #{user.username}");
           return "confirmed";
          // BookingListAction.java
           public void getBookings() {
           bookings = em
           "from Booking b where b.user.username = :username order by b.checkinDate")
           .setParameter("username", user.getUsername()).getResultList();

          BookingListAction is annotated with @TransactionAttribute(REQUIRES_NEW). That's why deadlock.

          • 2. Re: booking example and db2
            Martin Goik Newbie

            Thanks a lot! I read SUN's j2ee 1.5 introduction, changing the annotation to javax.ejb.TransactionAttributeType.REQUIRED thus avoiding a deadlock. I still wonder about impacts to the business logic, Maybe reading further will clarify my open questions.