Many thanks Jeff, I had messed up my WEB-INF\lib folder...problem solved.
But now that my transactions properly work, I have one more question.
In my library management application, I have a one-to-one relationship
between a Customer and his Id card. So when a customer comes to the
librarty and signs in, the employee manually inserts the customer's
data (surname, address and so on) in a form and I need the system to
automatically create the Id card when the employee submits the form
data. This is the code I'm using:
public static const millisecondsPerDay:int = 1000 * 60 * 60 * 24;
public var uuid:String;
private var token1:AsyncToken;
private var hibernatecustomer:DataService;
private var hibernatecard:DataService;
[Bindable]
private var clienteVo:Cliente;
[Bindable]
private var tesseraVo:Tessera;
private function addCliente():void {
clienteVo = new Cliente();
var date:Date = new Date();
var year:String = date.getUTCFullYear().toString();
var month:String = date.getUTCMonth().toString();
var day:String = date.getUTCDay().toString();
var hour:String = date.getUTCHours().toString();
var minutes:String = date.getUTCMinutes().toString();
var millisecs:String = date.getUTCMilliseconds().toString();
uuid = year + month + day + hour + minutes + millisecs;
clienteVo.idcliente = uuid;
clienteVo.cognome = newcognome.text;
clienteVo.nome = newnome.text;
clienteVo.datanascita = newdatanascita.text;
clienteVo.indirizzo = newindirizzo.text;
clienteVo.citta = newcitta.text;
clienteVo.provincia = newprovincia.text;
clienteVo.cap = newcap.text;
clienteVo.email = newemail.text;
clienteVo.telefono = newtelefono.text;
hibernatecustomer = new DataService("cliente.hibernate");
hibernatecustomer.addEventListener(ResultEvent.RESULT, addTessera);
hibernatecustomer.autoCommit = false;
var ir1:ItemReference = hibernatecustomer.createItem(clienteVo);
var token1:AsyncToken = AsyncToken(hibernatecustomer.commit());
token1.kind = "committed";
PopUpManager.removePopUp(this);
}
private function addTessera(event:ResultEvent):void {
if (event.token.kind == "committed") {
tesseraVo = new Tessera();
var currentDate:Date = new Date();
tesseraVo.idcliente = uuid;
tesseraVo.cliente = clienteVo;
tesseraVo.tprestiti = new ArrayCollection();
tesseraVo.datarilascio = currentDate;
tesseraVo.datascadenza = new Date(currentDate.getTime() + (3650
* millisecondsPerDay));
hibernatecard = new DataService("tessera.hibernate");
hibernatecard.autoCommit = false;
var ir2:ItemReference = hibernatecard.createItem(tesseraVo);
hibernatecard.commit();
}
}
Looks fine but I get this error:
Could not invoke sync method on data adapter for destination
'tessera.hibernate' due to the following error: class
org.hibernate.PropertyValueException:not-null property references a
null or transient value: fdspack.Tessera.datarilascio."
fdspack.Tessera.datarilascio is set by the code as:
var currentDate:Date = new Date();
tesseraVo.datarilascio = currentDate;
So why it tells me it is a "null or transient" value?
Riccardo
--- In [email protected], "Jeff Vroom" <[EMAIL PROTECTED]> wrote:
>
> I think that somehow you have got two versions of the UserTransaction
> class in your classpath. Maybe you followed the tomcat instructions for
> installing JOTM? If so, that is not necessary (and will break) jboss.
>
>
>
> Here's a simple JSP you can use to debug this problem without DS in the
> way:
>
>
>
> <%@ page import="javax.transaction.UserTransaction" %>
>
> <%@ page import="javax.naming.InitialContext" %>
>
> <%@ page import="javax.naming.Context" %>
>
> <body>
>
>
>
> start<br>
>
> <%
>
> try
>
> {
>
> Context ctx = new InitialContext();
>
>
>
> String userTransactionJndi = "java:comp/UserTransaction";
>
> String userSpecified = System.getProperty("UserTxJndiName");
>
> if (userSpecified != null)
>
> {
>
> userTransactionJndi = userSpecified;
>
> }
>
> UserTransaction userTransaction = (UserTransaction)
> ctx.lookup(userTransactionJndi);
>
> if (userTransaction != null)
>
> {
>
> userTransaction.begin();
>
> out.println("begin ok!<br>");
>
> userTransaction.commit();
>
> out.println("commit ok!<br>");
>
> }
>
> else
>
> {
>
> out.println("returned null");
>
> }
>
> }
>
> catch (Exception ne)
>
> {
>
> out.println(ne.toString());
>
> }
>
> %>
>
>
>
> done
>
>
>
> </body>
>
>
>
> When this works, DS with use-transactions=true should also work.
>
>
>
> Jeff
>
>
>
> ________________________________
>
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of mancer82
> Sent: Monday, August 27, 2007 9:17 AM
> To: [email protected]
> Subject: [flexcoders] Issue with transactions on Data Management Service
>
>
>
> Hello, I'm actually creating an application for a library and I'm
> running it on JBoss 4.2.0.GA with underlying DB2 8.2.
>
> The application relies on a POJO + Hibernate3 server backend,
> communicating with the Flex client thru Data Management Service
> destinations.
>
> The problem I get is the following; as long as I ask for records using
> the dataservice.fill() method, I encounter no issue and the app works
> fine. But as soon as I try to create a new item, or modify an existing
> one, I get this error in STDOUT:
>
> 2004-10-24 20:26:35,125 INFO [STDOUT] [Flex] Exception when invoking
> service: data-service
> with message: Flex Message (flex.data.messages.DataMessage)
> operation = transacted
> id = null
> clientId = 81828BBA-8E7A-B668-86B3-76D34BF1071F
> correlationId =
> destination = utente.hibernate
> messageId = ADE53343-F3F1-D938-A31D-CC308E3F66B1
> timestamp = 1098642394734
> timeToLive = 0
> body =
> [
> Flex Message (flex.data.messages.DataMessage)
> operation = create_and_sequence
> id = ASObject(19507034){id=2004901826687}
> clientId = 43BC3541-8881-F29B-B186-CC3039979243
> correlationId = ADE53343-F3F1-D938-A31D-CC308E3F66B1
> destination = utente.hibernate
> messageId = 59933554-59E2-8624-EA5B-CC308E3F279A
> timestamp = 0
> timeToLive = 0
> body = [EMAIL PROTECTED]
> ]
> hdr(DSEndpoint) = my-rtmp
> exception: flex.data.DataServiceException: Unable to access
> UserTransaction in DataService.
> 2004-10-24 20:26:35,125 INFO [STDOUT] [Flex] Error handling rtmp
> message: flex.data.DataServiceException: Unable to access
> UserTransaction in DataService.
> incomingMessage: Flex Message (flex.data.messages.DataMessage)
> operation = transacted
> id = null
> clientId = 81828BBA-8E7A-B668-86B3-76D34BF1071F
> correlationId =
> destination = utente.hibernate
> messageId = ADE53343-F3F1-D938-A31D-CC308E3F66B1
> timestamp = 1098642394734
> timeToLive = 0
> body =
> [
> Flex Message (flex.data.messages.DataMessage)
> operation = create_and_sequence
> id = ASObject(19507034){id=2004901826687}
> clientId = 43BC3541-8881-F29B-B186-CC3039979243
> correlationId = ADE53343-F3F1-D938-A31D-CC308E3F66B1
> destination = utente.hibernate
> messageId = 59933554-59E2-8624-EA5B-CC308E3F279A
> timestamp = 0
> timeToLive = 0
> body = [EMAIL PROTECTED]
> ]
> hdr(DSEndpoint) = my-rtmp
> errorReply: Flex Message (flex.messaging.messages.ErrorMessage)
> clientId = null
> correlationId = ADE53343-F3F1-D938-A31D-CC308E3F66B1
> destination = utente.hibernate
> messageId = 81828F75-2508-726A-7B40-2ECD5E71CF75
> timestamp = 1098642395125
> timeToLive = 0
> body = null
> code = Server.Processing
> message = Unable to access UserTransaction in DataService.
> details = null
> rootCause = java.lang.ClassCastException:
> org.jboss.tm.usertx.client.ServerVMClientUserTransaction cannot be
> cast to javax.transaction.UserTransaction
> body = null
> extendedData = null
> 2004-10-24 20:26:35,125 INFO [STDOUT] [Flex]
> cause=java.lang.ClassCastException:
> org.jboss.tm.usertx.client.ServerVMClientUserTransaction cannot be
> cast to javax.transaction.UserTransaction type=class
> java.lang.ClassCastException
> java.lang.ClassCastException:
> org.jboss.tm.usertx.client.ServerVMClientUserTransaction cannot be
> cast to javax.transaction.UserTransaction
> at
> flex.data.DataServiceTransaction.doBegin(DataServiceTransaction.java:653
> )
> at
> flex.data.DataServiceTransaction.begin(DataServiceTransaction.java:624)
> at flex.data.DataService.serviceTransactedMessage(DataService.java:474)
> at flex.data.DataService.serviceMessage(DataService.java:241)
> at
> flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:54
> 8)
> at
> flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoin
> t.java:302)
> at
> flex.messaging.endpoints.rtmp.AbstractRTMPServer.dispatchMessage(Abstrac
> tRTMPServer.java:682)
> at
> flex.messaging.endpoints.rtmp.NIORTMPConnection$RTMPReader.run(NIORTMPCo
> nnection.java:665)
> at
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker
> .runTask(ThreadPoolExecutor.java:665)
> at
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker
> .run(ThreadPoolExecutor.java:690)
> at java.lang.Thread.run(Thread.java:619)
> 2004-10-24 20:26:35,140 INFO [STDOUT] [Flex] Serializing AMF/RTMP
> response
> Version: 3
> (Command method=_error (0) trxId=17)
> (Typed Object #0 'flex.messaging.messages.ErrorMessage')
> headers = (Object #1)
> rootCause = (Typed Object #2 'java.lang.ClassCastException')
> message =
> "org.jboss.tm.usertx.client.ServerVMClientUserTransaction cannot be
> cast to javax.transaction.UserTransaction"
> localizedMessage =
> "org.jboss.tm.usertx.client.ServerVMClientUserTransaction cannot be
> cast to javax.transaction.UserTransaction"
> cause = null
> body = null
> correlationId = "ADE53343-F3F1-D938-A31D-CC308E3F66B1"
> faultDetail = null
> faultString = "Unable to access UserTransaction in DataService."
> clientId = null
> timeToLive = 0.0
> destination = "utente.hibernate"
> timestamp = 1.098642395125E12
> extendedData = null
> faultCode = "Server.Processing"
> messageId = "81828F75-2508-726A-7B40-2ECD5E71CF75"
>
> I'm going crazy trying to solve this...any suggestions? Maybe a JBoss
> configuration problem?
>
> Riccardo
>