I all, i try to implement a sevice to booking a room. I must to deploiy it on jboss 3.2.7 and i use CMT
The problem is when 2 client A, B call at same time booking method: 1)A: call "booking" with big Collection, order by date, include booking for tomorrow 2) A: call "verifyAvaibleBooking(bookingVO)" and nobody booking for tomorrow 3) B: call "booking" with only booking for tomorrow A: continues to verifyAvaibleBooking 4) B call "verifyAvaibleBooking(bookingVO)" and nobody booking for tomorrow and create a booking for tomorrow 5) A: terminate to verifyAvaibleBooking and create booking At the end of this computation i have 2 booking for tomorrow on the same room! This is my bookingBean: | /* @ejb.bean name="Booking" display-name="Name for Booking" | * description="Description for Booking" jndi-name="ejb/Booking" | * local-jndi-name = "ejb/BookingLocal" type="CMP" cmp-version="2.x" | * view-type="local" primkey-field = "id" | * | */ | | public abstract class BookingBean implements EntityBean { | //every get method have this tag | /** | * Getter for CMP Field id | * | * @ejb.persistent-field | * @ejb.interface-method view-type="local" | * | */ | set...(); | get...(); | } | Now i have a Stateful antity bean to manage previews bean: | ** | * @ejb.bean name="ManageBooking" display-name="Name for ManageBooking" | * description="Description for ManageBooking" | * jndi-name="ejb/ManageBooking" type="Stateful" view-type="both" | * | * @ejb.resource-ref res-ref-name="jdbc/DefaultDS" | * res-type="javax.sql.Datasource" | * res-auth="Container" | * | [EMAIL PROTECTED] res-ref-name="jdbc/DefaultDS" | * jndi-name="java:/DefaultDS" | * | * @jboss.container-configuration name="Standard Stateful SessionBean" | * | * @ejb.ejb-ref ejb-name="Booking" view-type="local" ref-name="ejb/BookingLocal" | * | * @ejb.ejb-ref ejb-name="User" view-type="local" ref-name="ejb/UserLocal" | * | * @ejb.ejb-ref ejb-name="ClassRoom" view-type="local" | * ref-name="ejb/ClassRoomLocal" | * | * @ejb.ejb-ref ejb-name="Privilege" view-type="local" | * ref-name="ejb/PrivilegeLocal" | * | * @ejb.ejb-ref ejb-name="MyConstraint" view-type="local" | * ref-name="ejb/MyConstraintLocal" | * | */ | public abstract class ManageBookingBean implements SessionBean{ | | //Define some variable | | /** | * Sets the session context | * @param javax.ejb.SessionContext the new ctx value | * @ejb.method setSessionContext | **/ | public void setSessionContext(SessionContext ctx) throws EJBException, | RemoteException { | this.ctx = ctx; | } | | /** | * Unsets the session context | * @param javax.ejb.SessionContext ctx value | * @ejb.method unsetSessionContext | */ | public void unsetSessionContext() { | this.ctx=null; | } | | /** | * Default create method | * | * @throws CreateException | * @ejb.create-method | */ | public void ejbCreate() throws CreateException { | try { | userLocalHome = UserUtil.getLocalHome(); | classRoomLocalHome = ClassRoomUtil.getLocalHome(); | bookingLocalHome = BookingUtil.getLocalHome(); | constraintLocalHome = MyConstraintUtil.getLocalHome(); | } catch (NamingException e) { | // TODO Auto-generated catch block | e.printStackTrace(); | } | } | | | //There are some (not transaction) method | | /** | * Business method | * | * @ejb.interface-method view-type = "remote" | * @ejb.transaction type = "Required" | */ | public String booking(Collection bookingVO) { | ..... | } | } | This is a booking mathod: | /** | * Business method | * | * @ejb.interface-method view-type = "remote" | * @ejb.transaction type = "Required" | */ | public String booking(Collection bookingVO) { | UserLocal userBean = null; | ClassRoomLocal classRoomBean = null; | Iterator iter; | | // Verifico la disponibilità | Collection collBooking = verifyAvaibleBooking(bookingVO); | | if (collBooking.isEmpty()) { | String tmp = computeConstraint(bookingVO); | if (tmp.startsWith("Danied")) { | return tmp; | } | iter = bookingVO.iterator(); | while (iter.hasNext()) { | BookingValue booking = (BookingValue) iter.next(); | try { | userBean = userLocalHome.findByPrimaryKey(booking.getUser() | .getUserName()); | classRoomBean = classRoomLocalHome.findByPrimaryKey(booking | .getClassRoom().getName()); | } catch (FinderException e1) { | // TODO Auto-generated catch block | e1.printStackTrace(); | } | try { | BookingLocal bookingBean = bookingLocalHome.create(); | bookingBean.setBookingValue(booking); | bookingBean.setClassRoom(classRoomBean); | bookingBean.setUser(userBean); | } catch (CreateException e) { | Costanti.debug("Errore nella creazione delle prenotazione"); | ctx.setRollbackOnly(); | } | } | } else { | return Costanti.DANIED_BOOKING | + "<br>Impossibile effettuare la prenotazione" | + "<br>Ci sono altre prenotazioni negli stessi orari e nelle stesse aule"; | } | return Costanti.OK_BOOKING + "<br>Prenotazione effettuata con successo"; | } | | How can I make to resolve this problem? I know that i can use UserTransaction but i'm know that CMT make this for me! Someone can say me because i have this problem? Thanks for your help everyone View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3948975#3948975 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3948975 _______________________________________________ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user