[jboss-user] [EJB/JBoss] - rollbacked transaction exception

kedzol do-not-reply at jboss.com
Fri Mar 21 18:51:19 EDT 2008


Hi everyone!

I have a serious problem with my code, and I don't know how to solve it.

The following codefragments search the Clients and the Client's addresses and sets transient fields with localized values. The localized (language versions) values are stored in the Reference entity. Varref is a sessionbean for Reference.

Code in StartPage.java backingbean:

  | List<Client> cList = turulSessionBean.searchLocalizedClient(new String("TARSASHAZ KAZAN"), TurulLanguage.HUNGARIAN);
  |              
  | List<ClientAddress> addrList = turulSessionBean.localizeClientAddressByClientId(cList.get(0).getClientId(),  TurulLanguage.HUNGARIAN);
  | for(ClientAddress addr : addrList)
  |    System.out.println("address localized: " + addr.getLocalCountry() + ", " + addr.getLocalTown());
  | 


Code in TurulSessionBean for client localization:

  | public List<Client> searchLocalizedClient(String name, long language)
  |  {
  |         List<Client> clientList = em.createNamedQuery("Client.findByName").setParameter("name", name).getResultList();
  |         System.out.println("cList size: " + clientList.size());
  |         if( ! clientList.isEmpty() )
  |             localizeClients(clientList, language);
  |         
  |         return clientList;
  |     }
  |     
  |     
  |     
  |     private List<Client> localizeClients(List<Client> clientList, long language)
  |     {
  |         for(Client client : clientList)
  |             localizeClient(client, language);
  | 
  |         return clientList;
  |     }
  |     
  |     private void localizeClient(Client client, long language)
  |     {
  |         Reference ref;
  |         
  |         /* localize clientclass */
  |         ref = varref.getReference(TurulReference.CLIENT_CLASS, client.getClientClass(), language);
  |         client.setLocalClientClass(ref.getName());
  | 
  |         /* localize payingqualification */
  |         ref = varref.getReference(TurulReference.PAYING_QUALITY_DESIGNATIONS, client.getPayingQualification(), language);
  |         client.setLocalPayingQualification(ref.getName());
  | 
  |         /* localize usidtype */
  |         if(client.getClientClass().longValue() == 1)
  |             ref = varref.getReference(TurulReference.PERSONAL_ID_TYPE, client.getUsidType(), language);
  |         else
  |             ref = varref.getReference(TurulReference.ENTERPRISE_ID_TYPE, client.getUsidType(), language);
  |         client.setLocalUsidType(ref.getName());
  | 
  |         /* localize repidtype */
  |         ref = varref.getReference(TurulReference.PERSONAL_ID_TYPE, client.getRepidType(), language);
  |         client.setLocalRepidType(ref.getName());
  | 
  |         /* localize clienttype */
  |         ref = varref.getReference(TurulReference.CLIENT_TYPE, client.getClientType(), language);
  |         client.setLocalClientType(ref.getName());
  |     }
  | 

Code in TurulSessionBean for clientaddress localization:

  | public List<ClientAddress> localizeClientAddressByClientId(Long clientId, long language) {
  |         List<ClientAddress> addrList = em.createNamedQuery("ClientAddress.findByClientId").setParameter("clientId", clientId).getResultList();
  |         if( !addrList.isEmpty() )
  |             localizeClientAddresses(addrList, language);
  |         
  |         return addrList;
  |     }
  |     
  |     private void localizeClientAddresses(List<ClientAddress> addrList, long language)
  |     {
  |         for(ClientAddress address : addrList)
  |             localizeClientAddress(address, language);
  |     }    
  |     
  | private void localizeClientAddress(ClientAddress address, long language)
  |     {
  |         Reference ref;
  | 
  |         /* localize locationtype */
  |         ref = varref.getReference(TurulReference.CONTACT_LOCATION_TYPE, address.getLocationType(), language);
  |         address.setLocalLocationType(ref.getName());
  |         System.out.println("locationtype: " + address.getLocalLocationType());
  |         System.out.println("----------- 1");
  | 
  |         /* localize addresstype */
  |         ref = varref.getReference(TurulReference.ADDRESS_TYPES, address.getAddressType(), language);
  |         System.out.println("----------- 2");
  |         address.setLocalAddressType(ref.getName());
  |         System.out.println("addresstype: " + address.getLocalAddressType());
  |         System.out.println("----------- 3");
  | 
  |         /* localize country */
  |         if( address.getAddrId() != null )
  |         {    
  |             ref = varref.getReference(TurulReference.COUNTRIES, address.getAddrId().getCountry(), language);
  |             address.setLocalCountry(ref.getName());
  |         }    
  |         else if ( address.getCountry() != null )
  |         {    
  |             ref = varref.getReference(TurulReference.COUNTRIES, address.getCountry(), language);
  |             address.setLocalCountry(ref.getName());
  |         }    
  |         System.out.println("country: " + address.getLocalCountry());
  |         System.out.println("----------- 4");
  | 
  |         /* localize county */
  |         if ( address.getCounty() != null )
  |         {    
  |             ref = varref.getReference(TurulReference.COUNTIES, address.getCounty(), language);
  |             address.setLocalCounty(ref.getName());
  |         }   
  |         System.out.println("----------- 5");
  | 
  |         /* localize town */
  |         if( address.getAddrId() != null )
  |         {    
  |             ref = varref.getReference(TurulReference.TOWNS, address.getAddrId().getTown(), language);
  |             address.setLocalTown(ref.getName());
  |         }    
  |         else if ( address.getTown() != null )
  |         {    
  |             System.out.println("----------- 6");
  |  

The exception is thrown at this point.


  |              ref = varref.getReference(TurulReference.TOWNS, address.getTown(), language);
  |             System.out.println("----------- 7" + ref.getName());
  |             address.setLocalTown(ref.getName());
  |             System.out.println("town: " + address.getLocalTown());
  |         }
  |         System.out.println("----------- 8");
  | 
  |         /* localize placetype */
  |         if( address.getPlaceType() != null )
  |         {
  |             ref = varref.getReference(TurulReference.ADDRESS_LOCATION_TYPES, address.getPlaceType(), language);
  |             System.out.println("----------- 9");
  |             address.setLocalPlaceType(ref.getName());
  |         }
  |     } 

Here you can see the log:
16:14:30,484 INFO  [STDOUT] >>>>>>>>>>>>>>>>>>>>>>>lokalization starts
16:14:30,687 INFO  [STDOUT] cList size: 2
16:14:30,703 WARN  [loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.multipleWarning] [com.arjuna.ats.internal.jta.transacti
on.arjunacore.lastResource.multipleWarning] Multiple last resources have been added to the current transaction. This is transactionally unsafe and shoul
d not be relied upon. Current resource is org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource at 14fa4a2
16:14:30,843 INFO  [STDOUT] clientList.0: 117790, TARSASHAZ, SZELSOSEGESEN ROSSZ
16:14:30,843 INFO  [STDOUT] >>> ADDRESSES:
16:14:30,875 WARN  [loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.multipleWarning] [com.arjuna.ats.internal.jta.transacti
on.arjunacore.lastResource.multipleWarning] Multiple last resources have been added to the current transaction. This is transactionally unsafe and shoul
d not be relied upon. Current resource is org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource at 14fa4a2
16:14:30,890 INFO  [STDOUT] locationtype: SZEKHELY
16:14:30,890 INFO  [STDOUT] ----------- 1
16:14:30,906 INFO  [STDOUT] ----------- 2
16:14:30,906 INFO  [STDOUT] addresstype: SZABADSZOVEGES CIM
16:14:30,906 INFO  [STDOUT] ----------- 3
16:14:30,921 INFO  [STDOUT] country: MAGYARORSZAG
16:14:30,921 INFO  [STDOUT] ----------- 4
16:14:30,937 INFO  [STDOUT] ----------- 5
16:14:30,945 INFO  [STDOUT] ----------- 6
16:14:30,953 ERROR [TxPolicy] javax.ejb.EJBTransactionRolledbackException
16:14:31,000 INFO  [STDOUT] StartPage: client find error:javax.ejb.EJBTransactionRolledbackException


I put printlines to trace the error and to follow up the state of the progress.
It seems - for me - that both transactions run well, but the second one calls a rollback at "6" and I don't know why.

Any suggestion could help.

Please let me know if you need further information.

Thanx Zoli

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4138386#4138386

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4138386



More information about the jboss-user mailing list