Hi all,
I am customizing the onePageCheckout (the anonymous part) and I found something strange. I've changed the client-side validation in order to allow the customer to only introduce the phone, cell phone or both. But on server-side I didn't change anything in the PartyContactMechMapProcs.xml yet. So, it is throwing an error of course, but the ajax handler does not consider it as an error. It always executes the success ajax handler! This is the stack trace: 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] Request Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 requests, 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ ServiceEcaRule.java:150:INFO ] Running Service ECA Service: setAnonUserLogin, triggered by rule on Service: createUpdateCustomerAndShippingAddress 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ ServiceDispatcher.java:599:INFO ] Sync service [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with response [{responseMessage=success}] 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ TransactionUtil.java:374:WARN ] ---- exception report ---------------------------------------------------------- [TransactionUtil.setRollbackOnly] Calling transaction setRollbackOnly; this stack trace shows where this is happening: Exception: java.lang.Exception Message: Error in simple-method [Create/Update Customer, Shipping Address and other contact details. [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: ; {Area code is missing, Falta Teléfono de Contacto} ---- stack trace --------------------------------------------------------------- java.lang.Exception: Error in simple-method [Create/Update Customer, Shipping Address and other contact details. [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: ; {Area code is missing, Falta Teléfono de Contacto} org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) java.lang.Thread.run(Thread.java:619) -------------------------------------------------------------------------------- 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ ServiceDispatcher.java:543:ERROR] Error in Service [createUpdateCustomerAndShippingAddress]: Area code is missing, Falta Teléfono de Contacto 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ TransactionUtil.java:338:ERROR] ---- exception report ---------------------------------------------------------- [TransactionUtil.rollback] Exception: java.lang.Exception Message: Stack Trace ---- stack trace --------------------------------------------------------------- java.lang.Exception: Stack Trace org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) java.lang.Thread.run(Thread.java:619) -------------------------------------------------------------------------------- 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] transaction rolled back 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ ServiceDispatcher.java:599:INFO ] Sync service [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] milliseconds with response [{errorMessageList={Area code is missing, Falta Teléfono de Contacto}, responseMessage=error}] 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ RequestHandler.java:639:INFO ] Ran Event [service:#createUpdateCustomerAndShippingAddress] from [request], result is [error] 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ RequestHandler.java:425:ERROR] Request createUpdateShippingAddress caused an error with the following message: {Area code is missing, Falta Teléfono de Contacto} 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response is a chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: requestUri=json overrideViewUri=null sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ RequestHandler.java:639:INFO ] Ran Event [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] from [request], result is [success] 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, ServerHitBin delegatorName=default#JF 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for [ServerHitBin]; curSeqId=53390, maxSeqId=53400, bankSize=10 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] Request Done- total:0.386,since last([createUpdateShip...):0.386]] ----------------------------------------------------------------------------------------------- After a bit of investigation I found this: The event 'createUpdateCustomerAndShippingAddress' is returning an error as a result but since the request is chained (with a json request) the controller takes the response from the event 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' which is always 'success'. So that's why I figure out the ajax error handler is never invoked. What do you think? For further details, I am using a 3 months old trunk version with MySql. I've checked out the latest version of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still the same code as I have. Thanks in advance. -- ----- Jonatan Soto |
[traditional#JF/setAnonUserLogin] finished in [105] milliseconds with
response [{responseMessage=success}] it is evaluating a good lognin. this is where to debug. Jonatan Soto sent the following on 7/16/2011 10:59 AM: > Hi all, > > I am customizing the onePageCheckout (the anonymous part) and I found > something strange. I've changed the client-side validation in order to allow > the customer to only introduce the phone, cell phone or both. But on > server-side I didn't change anything in the PartyContactMechMapProcs.xml > yet. So, it is throwing an error of course, but the ajax handler does not > consider it as an error. It always executes the success ajax handler! > > This is the stack trace: > > 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ > ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] Request > Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] > 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ > ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 requests, > 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml > 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ > ServiceEcaRule.java:150:INFO ] Running Service ECA Service: > setAnonUserLogin, triggered by rule on Service: > createUpdateCustomerAndShippingAddress > 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ > ServiceDispatcher.java:599:INFO ] Sync service > [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with > response [{responseMessage=success}] > 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ > TransactionUtil.java:374:WARN ] > ---- exception report > ---------------------------------------------------------- > [TransactionUtil.setRollbackOnly] Calling transaction setRollbackOnly; this > stack trace shows where this is happening: > Exception: java.lang.Exception > Message: Error in simple-method [Create/Update Customer, Shipping Address > and other contact details. > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > ; {Area code is missing, Falta Teléfono de Contacto} > ---- stack trace > --------------------------------------------------------------- > java.lang.Exception: Error in simple-method [Create/Update Customer, > Shipping Address and other contact details. > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > ; {Area code is missing, Falta Teléfono de Contacto} > org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) > org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) > org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) > org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) > org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) > org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) > org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) > _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > java.lang.Thread.run(Thread.java:619) > -------------------------------------------------------------------------------- > > 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > ServiceDispatcher.java:543:ERROR] Error in Service > [createUpdateCustomerAndShippingAddress]: Area code is missing, Falta > Teléfono de Contacto > 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > TransactionUtil.java:338:ERROR] > ---- exception report > ---------------------------------------------------------- > [TransactionUtil.rollback] > Exception: java.lang.Exception > Message: Stack Trace > ---- stack trace > --------------------------------------------------------------- > java.lang.Exception: Stack Trace > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > java.lang.Thread.run(Thread.java:619) > -------------------------------------------------------------------------------- > > 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ > TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] transaction > rolled back > 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > ServiceDispatcher.java:599:INFO ] Sync service > [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] > milliseconds with response [{errorMessageList={Area code is missing, Falta > Teléfono de Contacto}, responseMessage=error}] > 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > RequestHandler.java:639:INFO ] Ran Event > [service:#createUpdateCustomerAndShippingAddress] from [request], result is > [error] > 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ > RequestHandler.java:425:ERROR] Request createUpdateShippingAddress caused an > error with the following message: {Area code is missing, Falta Teléfono de > Contacto} > 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response is a > chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: > requestUri=json overrideViewUri=null > sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > RequestHandler.java:639:INFO ] Ran Event > [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] from > [request], result is [success] > 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ > ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, ServerHitBin > delegatorName=default#JF > 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ > SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for [ServerHitBin]; > curSeqId=53390, maxSeqId=53400, bankSize=10 > 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ > ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] Request Done- > total:0.386,since last([createUpdateShip...):0.386]] > > > ----------------------------------------------------------------------------------------------- > > After a bit of investigation I found this: > > The event 'createUpdateCustomerAndShippingAddress' is returning an error as > a result but since the request is chained (with a json request) the > controller takes the response from the event > 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' which > is always 'success'. So that's why I figure out the ajax error handler is > never invoked. > > What do you think? > > For further details, I am using a 3 months old trunk version with MySql. > I've checked out the latest version > of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still the same > code as I have. > > Thanks in advance. > |
Hi BJ,
The setAnonuserLogin is an ECA triggered before. The problem is after it if I'm not wrong. Look at: 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ ServiceDispatcher.java:599:INFO ] Sync service [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] milliseconds with response [{errorMessageList={Area code is missing, Falta Teléfono de Contacto}, responseMessage=error}] ... 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ RequestHandler.java:639:INFO ] Ran Event [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] from [request], result is [success] The service that is called from ajax is returning 'error' but the chained json request is returning 'success'. I guess this is the problem. Thanks anyway! On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> wrote: > [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with > response [{responseMessage=success}] > > it is evaluating a good lognin. this is where to debug. > > Jonatan Soto sent the following on 7/16/2011 10:59 AM: > > Hi all, > > > > I am customizing the onePageCheckout (the anonymous part) and I found > > something strange. I've changed the client-side validation in order to > allow > > the customer to only introduce the phone, cell phone or both. But on > > server-side I didn't change anything in the PartyContactMechMapProcs.xml > > yet. So, it is throwing an error of course, but the ajax handler does not > > consider it as an error. It always executes the success ajax handler! > > > > This is the stack trace: > > > > 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ > > ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] Request > > Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] > > 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ > > ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 > requests, > > 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml > > 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ > > ServiceEcaRule.java:150:INFO ] Running Service ECA Service: > > setAnonUserLogin, triggered by rule on Service: > > createUpdateCustomerAndShippingAddress > > 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ > > ServiceDispatcher.java:599:INFO ] Sync service > > [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with > > response [{responseMessage=success}] > > 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ > > TransactionUtil.java:374:WARN ] > > ---- exception report > > ---------------------------------------------------------- > > [TransactionUtil.setRollbackOnly] Calling transaction setRollbackOnly; > this > > stack trace shows where this is happening: > > Exception: java.lang.Exception > > Message: Error in simple-method [Create/Update Customer, Shipping Address > > and other contact details. > > > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > > ; {Area code is missing, Falta Teléfono de Contacto} > > ---- stack trace > > --------------------------------------------------------------- > > java.lang.Exception: Error in simple-method [Create/Update Customer, > > Shipping Address and other contact details. > > > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > > ; {Area code is missing, Falta Teléfono de Contacto} > > > org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) > > org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) > > org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) > > org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) > > > org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) > > > org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) > > > org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) > > > _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > > > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > > > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > > javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > > javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > > > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > > > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > > > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > > > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > > > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > > > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > > > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > > java.lang.Thread.run(Thread.java:619) > > > -------------------------------------------------------------------------------- > > > > 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > > ServiceDispatcher.java:543:ERROR] Error in Service > > [createUpdateCustomerAndShippingAddress]: Area code is missing, Falta > > Teléfono de Contacto > > 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > > TransactionUtil.java:338:ERROR] > > ---- exception report > > ---------------------------------------------------------- > > [TransactionUtil.rollback] > > Exception: java.lang.Exception > > Message: Stack Trace > > ---- stack trace > > --------------------------------------------------------------- > > java.lang.Exception: Stack Trace > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > > > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > > > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > > javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > > javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > > > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > > > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > > > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > > > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > > > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > > > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > > > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > > java.lang.Thread.run(Thread.java:619) > > > -------------------------------------------------------------------------------- > > > > 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ > > TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] transaction > > rolled back > > 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > > ServiceDispatcher.java:599:INFO ] Sync service > > [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] > > milliseconds with response [{errorMessageList={Area code is missing, > Falta > > Teléfono de Contacto}, responseMessage=error}] > > 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > > RequestHandler.java:639:INFO ] Ran Event > > [service:#createUpdateCustomerAndShippingAddress] from [request], result > is > > [error] > > 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ > > RequestHandler.java:425:ERROR] Request createUpdateShippingAddress caused > an > > error with the following message: {Area code is missing, Falta Teléfono > de > > Contacto} > > 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > > RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response is a > > chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > > 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > > RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: > > requestUri=json overrideViewUri=null > > sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > > 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > > RequestHandler.java:639:INFO ] Ran Event > > [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] > from > > [request], result is [success] > > 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ > > ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, ServerHitBin > > delegatorName=default#JF > > 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ > > SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for > [ServerHitBin]; > > curSeqId=53390, maxSeqId=53400, bankSize=10 > > 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ > > ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] Request > Done- > > total:0.386,since last([createUpdateShip...):0.386]] > > > > > > > ----------------------------------------------------------------------------------------------- > > > > After a bit of investigation I found this: > > > > The event 'createUpdateCustomerAndShippingAddress' is returning an error > as > > a result but since the request is chained (with a json request) the > > controller takes the response from the event > > 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' > which > > is always 'success'. So that's why I figure out the ajax error handler is > > never invoked. > > > > What do you think? > > > > For further details, I am using a 3 months old trunk version with MySql. > > I've checked out the latest version > > of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still the > same > > code as I have. > > > > Thanks in advance. > > > -- ----- Jonatan Soto |
Well, I did a little read on the jquery ajax documentation (
http://api.jquery.com/jQuery.ajax/) and some of my assertions were wrong. It is definitively not related to the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when I realized that the result the controller returns has nothing to do with the ajax callbacks :) According to this doc the error callback is: "A function to be called if the request fails...." In the case I'm exposing, obviously the request is not failing so the error I'm getting should be handled in the success callback. Please, tell me if there is another way to do it. I found a js function in the CheckoutProcess.js called getServerError(...) which is never invoked. I think it should be included in the success callback like the following code: (chekoutProcess.js) // Check server side error function getServerError(data) { var serverErrorHash = []; var serverError = ""; if (data._ERROR_MESSAGE_LIST_ != undefined) { serverErrorHash = data._ERROR_MESSAGE_LIST_; jQuery.each(serverErrorHash, function(i, error) { serverError += error.message + '<br/>'; }); } if (data._ERROR_MESSAGE_ != undefined) { serverError = data._ERROR_MESSAGE_; } return serverError; } function createUpdateCustomerAndShippingAddress() { var result = false; jQuery.ajax({ url: 'createUpdateShippingAddress', type: 'POST', dataType: 'json', async: false, data: jQuery('#shippingForm').serialize(), success: function(json) { var serverError = getServerError(json); if (!serverError) { jQuery('#shippingFormServerError').fadeOut('fast'); // Process Shipping data response. jQuery('#shipToPartyId').val(json.partyId); jQuery('#billToPartyId').val(json.partyId); jQuery('#shipToContactMechId').val(json.contactMechId); jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); jQuery('#emailContactMechId').val(json.emailContactMechId); //jQuery('#completedShippingMethod').html(json.shippingDescription); updateShippingSummary(); getShipOptions(); result = true; } else { jQuery('#shippingFormServerError').html(serverError); jQuery('#shippingFormServerError').css("display","block"); result = false; } }, error: function(error) { if (error != "") { jQuery('#shippingFormServerError').html(error); } result = false; } }); return result; } Now with this modifications I am showing the server side error messages correctly. HTH On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto <[hidden email]>wrote: > Hi BJ, > > The setAnonuserLogin is an ECA triggered before. The problem is after it if > I'm not wrong. > > Look at: > 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > ServiceDispatcher.java:599:INFO ] Sync service > [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] > milliseconds with response [{errorMessageList={Area code is missing, Falta > Teléfono de Contacto}, responseMessage=error}] > ... > 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > RequestHandler.java:639:INFO ] Ran Event > [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] from > [request], result is [success] > > The service that is called from ajax is returning 'error' but the chained > json request is returning 'success'. I guess this is the problem. > > Thanks anyway! > > > On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> wrote: > >> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >> response [{responseMessage=success}] >> >> it is evaluating a good lognin. this is where to debug. >> >> Jonatan Soto sent the following on 7/16/2011 10:59 AM: >> > Hi all, >> > >> > I am customizing the onePageCheckout (the anonymous part) and I found >> > something strange. I've changed the client-side validation in order to >> allow >> > the customer to only introduce the phone, cell phone or both. But on >> > server-side I didn't change anything in the PartyContactMechMapProcs.xml >> > yet. So, it is throwing an error of course, but the ajax handler does >> not >> > consider it as an error. It always executes the success ajax handler! >> > >> > This is the stack trace: >> > >> > 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ >> > ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] Request >> > Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] >> > 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ >> > ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 >> requests, >> > 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml >> > 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ >> > ServiceEcaRule.java:150:INFO ] Running Service ECA Service: >> > setAnonUserLogin, triggered by rule on Service: >> > createUpdateCustomerAndShippingAddress >> > 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ >> > ServiceDispatcher.java:599:INFO ] Sync service >> > [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >> > response [{responseMessage=success}] >> > 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ >> > TransactionUtil.java:374:WARN ] >> > ---- exception report >> > ---------------------------------------------------------- >> > [TransactionUtil.setRollbackOnly] Calling transaction setRollbackOnly; >> this >> > stack trace shows where this is happening: >> > Exception: java.lang.Exception >> > Message: Error in simple-method [Create/Update Customer, Shipping >> Address >> > and other contact details. >> > >> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >> > ; {Area code is missing, Falta Teléfono de Contacto} >> > ---- stack trace >> > --------------------------------------------------------------- >> > java.lang.Exception: Error in simple-method [Create/Update Customer, >> > Shipping Address and other contact details. >> > >> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >> > ; {Area code is missing, Falta Teléfono de Contacto} >> > >> org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) >> > >> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) >> > org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) >> > org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) >> > org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) >> > >> org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) >> > >> org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) >> > >> org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) >> > >> _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) >> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) >> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >> > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >> > >> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >> > >> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >> > >> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >> > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >> > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >> > javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >> > javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >> > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >> > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >> > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >> > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> > >> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >> > >> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >> > >> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >> > >> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >> > >> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >> > >> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >> > >> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >> > >> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >> > >> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >> > java.lang.Thread.run(Thread.java:619) >> > >> -------------------------------------------------------------------------------- >> > >> > 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >> > ServiceDispatcher.java:543:ERROR] Error in Service >> > [createUpdateCustomerAndShippingAddress]: Area code is missing, Falta >> > Teléfono de Contacto >> > 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >> > TransactionUtil.java:338:ERROR] >> > ---- exception report >> > ---------------------------------------------------------- >> > [TransactionUtil.rollback] >> > Exception: java.lang.Exception >> > Message: Stack Trace >> > ---- stack trace >> > --------------------------------------------------------------- >> > java.lang.Exception: Stack Trace >> > >> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) >> > >> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) >> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) >> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >> > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >> > >> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >> > >> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >> > >> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >> > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >> > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >> > javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >> > javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >> > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >> > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >> > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >> > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> > >> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >> > >> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >> > >> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >> > >> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >> > >> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >> > >> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >> > >> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >> > >> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >> > >> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >> > java.lang.Thread.run(Thread.java:619) >> > >> -------------------------------------------------------------------------------- >> > >> > 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ >> > TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] transaction >> > rolled back >> > 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >> > ServiceDispatcher.java:599:INFO ] Sync service >> > [traditional#JF/createUpdateCustomerAndShippingAddress] finished in >> [112] >> > milliseconds with response [{errorMessageList={Area code is missing, >> Falta >> > Teléfono de Contacto}, responseMessage=error}] >> > 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >> > RequestHandler.java:639:INFO ] Ran Event >> > [service:#createUpdateCustomerAndShippingAddress] from [request], result >> is >> > [error] >> > 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ >> > RequestHandler.java:425:ERROR] Request createUpdateShippingAddress >> caused an >> > error with the following message: {Area code is missing, Falta Teléfono >> de >> > Contacto} >> > 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >> > RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response is a >> > chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >> > 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >> > RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: >> > requestUri=json overrideViewUri=null >> > sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >> > 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >> > RequestHandler.java:639:INFO ] Ran Event >> > [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] >> from >> > [request], result is [success] >> > 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ >> > ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, >> ServerHitBin >> > delegatorName=default#JF >> > 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ >> > SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for >> [ServerHitBin]; >> > curSeqId=53390, maxSeqId=53400, bankSize=10 >> > 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ >> > ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] Request >> Done- >> > total:0.386,since last([createUpdateShip...):0.386]] >> > >> > >> > >> ----------------------------------------------------------------------------------------------- >> > >> > After a bit of investigation I found this: >> > >> > The event 'createUpdateCustomerAndShippingAddress' is returning an error >> as >> > a result but since the request is chained (with a json request) the >> > controller takes the response from the event >> > 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' >> which >> > is always 'success'. So that's why I figure out the ajax error handler >> is >> > never invoked. >> > >> > What do you think? >> > >> > For further details, I am using a 3 months old trunk version with MySql. >> > I've checked out the latest version >> > of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still the >> same >> > code as I have. >> > >> > Thanks in advance. >> > >> > > > > -- > ----- > > Jonatan Soto > -- ----- Jonatan Soto |
I believe that the UI ajax uses data supplied by ftls, no calls fron the
UI access the ofbiz internals and goes through the Controller. the ajex and jazon used past the controller URI is internal to ofbiz and is not exposed to the UI. There is a Handler to deal with ajax and jason, internal to ofbiz. The ECA is internal to ofbiz and it returns a success that is evaluate by the event/service that spawned it. So something in the ECA called script is not evaluating login data correctly. that is as much as I know. Jonatan Soto sent the following on 7/16/2011 12:56 PM: > Well, I did a little read on the jquery ajax documentation ( > http://api.jquery.com/jQuery.ajax/) and some of my assertions were wrong. > It is definitively not related to > the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when I > realized that the result the controller returns has nothing to do with the > ajax callbacks :) > > According to this doc the error callback is: > "A function to be called if the request fails...." > > In the case I'm exposing, obviously the request is not failing so the error > I'm getting should be handled in the success callback. Please, tell me if > there is another way to do it. > I found a js function in the CheckoutProcess.js called getServerError(...) > which is never invoked. I think it should be included in the success > callback like the following code: > > (chekoutProcess.js) > > // Check server side error > function getServerError(data) { > var serverErrorHash = []; > var serverError = ""; > if (data._ERROR_MESSAGE_LIST_ != undefined) { > serverErrorHash = data._ERROR_MESSAGE_LIST_; > jQuery.each(serverErrorHash, function(i, error) { > serverError += error.message + '<br/>'; > }); > } > if (data._ERROR_MESSAGE_ != undefined) { > serverError = data._ERROR_MESSAGE_; > } > return serverError; > } > > function createUpdateCustomerAndShippingAddress() { > var result = false; > jQuery.ajax({ > url: 'createUpdateShippingAddress', > type: 'POST', > dataType: 'json', > async: false, > data: jQuery('#shippingForm').serialize(), > success: function(json) { > var serverError = getServerError(json); > if (!serverError) { > jQuery('#shippingFormServerError').fadeOut('fast'); > // Process Shipping data response. > jQuery('#shipToPartyId').val(json.partyId); > jQuery('#billToPartyId').val(json.partyId); > jQuery('#shipToContactMechId').val(json.contactMechId); > > jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); > jQuery('#emailContactMechId').val(json.emailContactMechId); > > //jQuery('#completedShippingMethod').html(json.shippingDescription); > updateShippingSummary(); > getShipOptions(); > result = true; > } else { > jQuery('#shippingFormServerError').html(serverError); > jQuery('#shippingFormServerError').css("display","block"); > result = false; > } > }, > error: function(error) { > if (error != "") { > jQuery('#shippingFormServerError').html(error); > } > result = false; > } > }); > return result; > } > > Now with this modifications I am showing the server side error messages > correctly. > > > HTH > > > On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto <[hidden email]>wrote: > >> Hi BJ, >> >> The setAnonuserLogin is an ECA triggered before. The problem is after it if >> I'm not wrong. >> >> Look at: >> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >> ServiceDispatcher.java:599:INFO ] Sync service >> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] >> milliseconds with response [{errorMessageList={Area code is missing, Falta >> Teléfono de Contacto}, responseMessage=error}] >> ... >> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >> RequestHandler.java:639:INFO ] Ran Event >> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] from >> [request], result is [success] >> >> The service that is called from ajax is returning 'error' but the chained >> json request is returning 'success'. I guess this is the problem. >> >> Thanks anyway! >> >> >> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> wrote: >> >>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >>> response [{responseMessage=success}] >>> >>> it is evaluating a good lognin. this is where to debug. >>> >>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: >>>> Hi all, >>>> >>>> I am customizing the onePageCheckout (the anonymous part) and I found >>>> something strange. I've changed the client-side validation in order to >>> allow >>>> the customer to only introduce the phone, cell phone or both. But on >>>> server-side I didn't change anything in the PartyContactMechMapProcs.xml >>>> yet. So, it is throwing an error of course, but the ajax handler does >>> not >>>> consider it as an error. It always executes the success ajax handler! >>>> >>>> This is the stack trace: >>>> >>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ >>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] Request >>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] >>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ >>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 >>> requests, >>>> 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml >>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ >>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: >>>> setAnonUserLogin, triggered by rule on Service: >>>> createUpdateCustomerAndShippingAddress >>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ >>>> ServiceDispatcher.java:599:INFO ] Sync service >>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >>>> response [{responseMessage=success}] >>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ >>>> TransactionUtil.java:374:WARN ] >>>> ---- exception report >>>> ---------------------------------------------------------- >>>> [TransactionUtil.setRollbackOnly] Calling transaction setRollbackOnly; >>> this >>>> stack trace shows where this is happening: >>>> Exception: java.lang.Exception >>>> Message: Error in simple-method [Create/Update Customer, Shipping >>> Address >>>> and other contact details. >>>> >>> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>> ---- stack trace >>>> --------------------------------------------------------------- >>>> java.lang.Exception: Error in simple-method [Create/Update Customer, >>>> Shipping Address and other contact details. >>>> >>> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) >>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) >>>> org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) >>>> org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) >>>> >>> org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) >>>> >>> org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) >>>> >>> org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) >>>> >>> _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>>> >>> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>>> >>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>>> >>> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> >>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>>> >>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>>> >>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>>> >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>>> >>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>>> >>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>>> >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>>> >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>>> >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>>> java.lang.Thread.run(Thread.java:619) >>>> >>> -------------------------------------------------------------------------------- >>>> >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>> ServiceDispatcher.java:543:ERROR] Error in Service >>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, Falta >>>> Teléfono de Contacto >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>> TransactionUtil.java:338:ERROR] >>>> ---- exception report >>>> ---------------------------------------------------------- >>>> [TransactionUtil.rollback] >>>> Exception: java.lang.Exception >>>> Message: Stack Trace >>>> ---- stack trace >>>> --------------------------------------------------------------- >>>> java.lang.Exception: Stack Trace >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>>> >>> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>>> >>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>>> >>> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> >>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>>> >>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>>> >>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>>> >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>>> >>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>>> >>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>>> >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>>> >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>>> >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>>> java.lang.Thread.run(Thread.java:619) >>>> >>> -------------------------------------------------------------------------------- >>>> >>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ >>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] transaction >>>> rolled back >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>> ServiceDispatcher.java:599:INFO ] Sync service >>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in >>> [112] >>>> milliseconds with response [{errorMessageList={Area code is missing, >>> Falta >>>> Teléfono de Contacto}, responseMessage=error}] >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:639:INFO ] Ran Event >>>> [service:#createUpdateCustomerAndShippingAddress] from [request], result >>> is >>>> [error] >>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress >>> caused an >>>> error with the following message: {Area code is missing, Falta Teléfono >>> de >>>> Contacto} >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response is a >>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: >>>> requestUri=json overrideViewUri=null >>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:639:INFO ] Ran Event >>>> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] >>> from >>>> [request], result is [success] >>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ >>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, >>> ServerHitBin >>>> delegatorName=default#JF >>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ >>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for >>> [ServerHitBin]; >>>> curSeqId=53390, maxSeqId=53400, bankSize=10 >>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ >>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] Request >>> Done- >>>> total:0.386,since last([createUpdateShip...):0.386]] >>>> >>>> >>>> >>> ----------------------------------------------------------------------------------------------- >>>> >>>> After a bit of investigation I found this: >>>> >>>> The event 'createUpdateCustomerAndShippingAddress' is returning an error >>> as >>>> a result but since the request is chained (with a json request) the >>>> controller takes the response from the event >>>> 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' >>> which >>>> is always 'success'. So that's why I figure out the ajax error handler >>> is >>>> never invoked. >>>> >>>> What do you think? >>>> >>>> For further details, I am using a 3 months old trunk version with MySql. >>>> I've checked out the latest version >>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still the >>> same >>>> code as I have. >>>> >>>> Thanks in advance. >>>> >>> >> >> >> >> -- >> ----- >> >> Jonatan Soto >> > > > |
In reply to this post by jonatan soto
Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, would be great if you could create a jira issue so this doesn't get lost.
Regards Scott HotWax Media http://www.hotwaxmedia.com On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: > Well, I did a little read on the jquery ajax documentation ( > http://api.jquery.com/jQuery.ajax/) and some of my assertions were wrong. > It is definitively not related to > the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when I > realized that the result the controller returns has nothing to do with the > ajax callbacks :) > > According to this doc the error callback is: > "A function to be called if the request fails...." > > In the case I'm exposing, obviously the request is not failing so the error > I'm getting should be handled in the success callback. Please, tell me if > there is another way to do it. > I found a js function in the CheckoutProcess.js called getServerError(...) > which is never invoked. I think it should be included in the success > callback like the following code: > > (chekoutProcess.js) > > // Check server side error > function getServerError(data) { > var serverErrorHash = []; > var serverError = ""; > if (data._ERROR_MESSAGE_LIST_ != undefined) { > serverErrorHash = data._ERROR_MESSAGE_LIST_; > jQuery.each(serverErrorHash, function(i, error) { > serverError += error.message + '<br/>'; > }); > } > if (data._ERROR_MESSAGE_ != undefined) { > serverError = data._ERROR_MESSAGE_; > } > return serverError; > } > > function createUpdateCustomerAndShippingAddress() { > var result = false; > jQuery.ajax({ > url: 'createUpdateShippingAddress', > type: 'POST', > dataType: 'json', > async: false, > data: jQuery('#shippingForm').serialize(), > success: function(json) { > var serverError = getServerError(json); > if (!serverError) { > jQuery('#shippingFormServerError').fadeOut('fast'); > // Process Shipping data response. > jQuery('#shipToPartyId').val(json.partyId); > jQuery('#billToPartyId').val(json.partyId); > jQuery('#shipToContactMechId').val(json.contactMechId); > > jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); > jQuery('#emailContactMechId').val(json.emailContactMechId); > > //jQuery('#completedShippingMethod').html(json.shippingDescription); > updateShippingSummary(); > getShipOptions(); > result = true; > } else { > jQuery('#shippingFormServerError').html(serverError); > jQuery('#shippingFormServerError').css("display","block"); > result = false; > } > }, > error: function(error) { > if (error != "") { > jQuery('#shippingFormServerError').html(error); > } > result = false; > } > }); > return result; > } > > Now with this modifications I am showing the server side error messages > correctly. > > > HTH > > > On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto <[hidden email]>wrote: > >> Hi BJ, >> >> The setAnonuserLogin is an ECA triggered before. The problem is after it if >> I'm not wrong. >> >> Look at: >> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >> ServiceDispatcher.java:599:INFO ] Sync service >> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] >> milliseconds with response [{errorMessageList={Area code is missing, Falta >> Teléfono de Contacto}, responseMessage=error}] >> ... >> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >> RequestHandler.java:639:INFO ] Ran Event >> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] from >> [request], result is [success] >> >> The service that is called from ajax is returning 'error' but the chained >> json request is returning 'success'. I guess this is the problem. >> >> Thanks anyway! >> >> >> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> wrote: >> >>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >>> response [{responseMessage=success}] >>> >>> it is evaluating a good lognin. this is where to debug. >>> >>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: >>>> Hi all, >>>> >>>> I am customizing the onePageCheckout (the anonymous part) and I found >>>> something strange. I've changed the client-side validation in order to >>> allow >>>> the customer to only introduce the phone, cell phone or both. But on >>>> server-side I didn't change anything in the PartyContactMechMapProcs.xml >>>> yet. So, it is throwing an error of course, but the ajax handler does >>> not >>>> consider it as an error. It always executes the success ajax handler! >>>> >>>> This is the stack trace: >>>> >>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ >>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] Request >>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] >>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ >>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 >>> requests, >>>> 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml >>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ >>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: >>>> setAnonUserLogin, triggered by rule on Service: >>>> createUpdateCustomerAndShippingAddress >>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ >>>> ServiceDispatcher.java:599:INFO ] Sync service >>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >>>> response [{responseMessage=success}] >>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ >>>> TransactionUtil.java:374:WARN ] >>>> ---- exception report >>>> ---------------------------------------------------------- >>>> [TransactionUtil.setRollbackOnly] Calling transaction setRollbackOnly; >>> this >>>> stack trace shows where this is happening: >>>> Exception: java.lang.Exception >>>> Message: Error in simple-method [Create/Update Customer, Shipping >>> Address >>>> and other contact details. >>>> >>> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>> ---- stack trace >>>> --------------------------------------------------------------- >>>> java.lang.Exception: Error in simple-method [Create/Update Customer, >>>> Shipping Address and other contact details. >>>> >>> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) >>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) >>>> org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) >>>> org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) >>>> >>> org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) >>>> >>> org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) >>>> >>> org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) >>>> >>> _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>>> >>> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>>> >>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>>> >>> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> >>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>>> >>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>>> >>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>>> >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>>> >>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>>> >>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>>> >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>>> >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>>> >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>>> java.lang.Thread.run(Thread.java:619) >>>> >>> -------------------------------------------------------------------------------- >>>> >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>> ServiceDispatcher.java:543:ERROR] Error in Service >>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, Falta >>>> Teléfono de Contacto >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>> TransactionUtil.java:338:ERROR] >>>> ---- exception report >>>> ---------------------------------------------------------- >>>> [TransactionUtil.rollback] >>>> Exception: java.lang.Exception >>>> Message: Stack Trace >>>> ---- stack trace >>>> --------------------------------------------------------------- >>>> java.lang.Exception: Stack Trace >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>>> >>> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>>> >>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>>> >>> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> >>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>>> >>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>>> >>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>>> >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>>> >>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>>> >>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>>> >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>>> >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>>> >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>>> java.lang.Thread.run(Thread.java:619) >>>> >>> -------------------------------------------------------------------------------- >>>> >>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ >>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] transaction >>>> rolled back >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>> ServiceDispatcher.java:599:INFO ] Sync service >>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in >>> [112] >>>> milliseconds with response [{errorMessageList={Area code is missing, >>> Falta >>>> Teléfono de Contacto}, responseMessage=error}] >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:639:INFO ] Ran Event >>>> [service:#createUpdateCustomerAndShippingAddress] from [request], result >>> is >>>> [error] >>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress >>> caused an >>>> error with the following message: {Area code is missing, Falta Teléfono >>> de >>>> Contacto} >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response is a >>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: >>>> requestUri=json overrideViewUri=null >>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:639:INFO ] Ran Event >>>> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] >>> from >>>> [request], result is [success] >>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ >>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, >>> ServerHitBin >>>> delegatorName=default#JF >>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ >>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for >>> [ServerHitBin]; >>>> curSeqId=53390, maxSeqId=53400, bankSize=10 >>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ >>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] Request >>> Done- >>>> total:0.386,since last([createUpdateShip...):0.386]] >>>> >>>> >>>> >>> ----------------------------------------------------------------------------------------------- >>>> >>>> After a bit of investigation I found this: >>>> >>>> The event 'createUpdateCustomerAndShippingAddress' is returning an error >>> as >>>> a result but since the request is chained (with a json request) the >>>> controller takes the response from the event >>>> 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' >>> which >>>> is always 'success'. So that's why I figure out the ajax error handler >>> is >>>> never invoked. >>>> >>>> What do you think? >>>> >>>> For further details, I am using a 3 months old trunk version with MySql. >>>> I've checked out the latest version >>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still the >>> same >>>> code as I have. >>>> >>>> Thanks in advance. >>>> >>> >> >> >> >> -- >> ----- >> >> Jonatan Soto >> > > > > -- > ----- > > Jonatan Soto smime.p7s (3K) Download Attachment |
Done. Patch provided, not fully tested.
https://issues.apache.org/jira/browse/OFBIZ-4342 <https://issues.apache.org/jira/browse/OFBIZ-4342>Regards, On Sun, Jul 17, 2011 at 1:34 PM, Scott Gray <[hidden email]>wrote: > Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, would > be great if you could create a jira issue so this doesn't get lost. > > Regards > Scott > > HotWax Media > http://www.hotwaxmedia.com > > On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: > > > Well, I did a little read on the jquery ajax documentation ( > > http://api.jquery.com/jQuery.ajax/) and some of my assertions were > wrong. > > It is definitively not related to > > the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when I > > realized that the result the controller returns has nothing to do with > the > > ajax callbacks :) > > > > According to this doc the error callback is: > > "A function to be called if the request fails...." > > > > In the case I'm exposing, obviously the request is not failing so the > error > > I'm getting should be handled in the success callback. Please, tell me if > > there is another way to do it. > > I found a js function in the CheckoutProcess.js called > getServerError(...) > > which is never invoked. I think it should be included in the success > > callback like the following code: > > > > (chekoutProcess.js) > > > > // Check server side error > > function getServerError(data) { > > var serverErrorHash = []; > > var serverError = ""; > > if (data._ERROR_MESSAGE_LIST_ != undefined) { > > serverErrorHash = data._ERROR_MESSAGE_LIST_; > > jQuery.each(serverErrorHash, function(i, error) { > > serverError += error.message + '<br/>'; > > }); > > } > > if (data._ERROR_MESSAGE_ != undefined) { > > serverError = data._ERROR_MESSAGE_; > > } > > return serverError; > > } > > > > function createUpdateCustomerAndShippingAddress() { > > var result = false; > > jQuery.ajax({ > > url: 'createUpdateShippingAddress', > > type: 'POST', > > dataType: 'json', > > async: false, > > data: jQuery('#shippingForm').serialize(), > > success: function(json) { > > var serverError = getServerError(json); > > if (!serverError) { > > jQuery('#shippingFormServerError').fadeOut('fast'); > > // Process Shipping data response. > > jQuery('#shipToPartyId').val(json.partyId); > > jQuery('#billToPartyId').val(json.partyId); > > jQuery('#shipToContactMechId').val(json.contactMechId); > > > > jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); > > jQuery('#emailContactMechId').val(json.emailContactMechId); > > > > //jQuery('#completedShippingMethod').html(json.shippingDescription); > > updateShippingSummary(); > > getShipOptions(); > > result = true; > > } else { > > jQuery('#shippingFormServerError').html(serverError); > > jQuery('#shippingFormServerError').css("display","block"); > > result = false; > > } > > }, > > error: function(error) { > > if (error != "") { > > jQuery('#shippingFormServerError').html(error); > > } > > result = false; > > } > > }); > > return result; > > } > > > > Now with this modifications I am showing the server side error messages > > correctly. > > > > > > HTH > > > > > > On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto <[hidden email] > >wrote: > > > >> Hi BJ, > >> > >> The setAnonuserLogin is an ECA triggered before. The problem is after it > if > >> I'm not wrong. > >> > >> Look at: > >> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > >> ServiceDispatcher.java:599:INFO ] Sync service > >> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in > [112] > >> milliseconds with response [{errorMessageList={Area code is missing, > Falta > >> Teléfono de Contacto}, responseMessage=error}] > >> ... > >> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > >> RequestHandler.java:639:INFO ] Ran Event > >> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] > from > >> [request], result is [success] > >> > >> The service that is called from ajax is returning 'error' but the > chained > >> json request is returning 'success'. I guess this is the problem. > >> > >> Thanks anyway! > >> > >> > >> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> > wrote: > >> > >>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with > >>> response [{responseMessage=success}] > >>> > >>> it is evaluating a good lognin. this is where to debug. > >>> > >>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: > >>>> Hi all, > >>>> > >>>> I am customizing the onePageCheckout (the anonymous part) and I found > >>>> something strange. I've changed the client-side validation in order to > >>> allow > >>>> the customer to only introduce the phone, cell phone or both. But on > >>>> server-side I didn't change anything in the > PartyContactMechMapProcs.xml > >>>> yet. So, it is throwing an error of course, but the ajax handler does > >>> not > >>>> consider it as an error. It always executes the success ajax handler! > >>>> > >>>> This is the stack trace: > >>>> > >>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ > >>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] Request > >>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] > >>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ > >>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 > >>> requests, > >>>> 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml > >>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ > >>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: > >>>> setAnonUserLogin, triggered by rule on Service: > >>>> createUpdateCustomerAndShippingAddress > >>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ > >>>> ServiceDispatcher.java:599:INFO ] Sync service > >>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with > >>>> response [{responseMessage=success}] > >>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ > >>>> TransactionUtil.java:374:WARN ] > >>>> ---- exception report > >>>> ---------------------------------------------------------- > >>>> [TransactionUtil.setRollbackOnly] Calling transaction setRollbackOnly; > >>> this > >>>> stack trace shows where this is happening: > >>>> Exception: java.lang.Exception > >>>> Message: Error in simple-method [Create/Update Customer, Shipping > >>> Address > >>>> and other contact details. > >>>> > >>> > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > >>>> ; {Area code is missing, Falta Teléfono de Contacto} > >>>> ---- stack trace > >>>> --------------------------------------------------------------- > >>>> java.lang.Exception: Error in simple-method [Create/Update Customer, > >>>> Shipping Address and other contact details. > >>>> > >>> > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > >>>> ; {Area code is missing, Falta Teléfono de Contacto} > >>>> > >>> > org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) > >>>> > >>> > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) > >>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) > >>>> org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) > >>>> > org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) > >>>> > >>> > org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) > >>>> > >>> > org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) > >>>> > >>> > org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) > >>>> > >>> > _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) > >>>> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) > >>>> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > >>>> > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > >>>> > >>> > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > >>>> > >>> > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > >>>> > >>> > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > >>>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > >>>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > >>>> > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > >>>> > >>> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > >>>> > >>> > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > >>>> > >>> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > >>>> > >>> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > >>>> > >>> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > >>>> > >>> > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > >>>> > >>> > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > >>>> > >>> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > >>>> > >>> > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > >>>> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > >>>> java.lang.Thread.run(Thread.java:619) > >>>> > >>> > -------------------------------------------------------------------------------- > >>>> > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > >>>> ServiceDispatcher.java:543:ERROR] Error in Service > >>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, Falta > >>>> Teléfono de Contacto > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > >>>> TransactionUtil.java:338:ERROR] > >>>> ---- exception report > >>>> ---------------------------------------------------------- > >>>> [TransactionUtil.rollback] > >>>> Exception: java.lang.Exception > >>>> Message: Stack Trace > >>>> ---- stack trace > >>>> --------------------------------------------------------------- > >>>> java.lang.Exception: Stack Trace > >>>> > >>> > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) > >>>> > >>> > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) > >>>> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) > >>>> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > >>>> > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > >>>> > >>> > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > >>>> > >>> > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > >>>> > >>> > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > >>>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > >>>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > >>>> > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > >>>> > >>> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > >>>> > >>> > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > >>>> > >>> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > >>>> > >>> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > >>>> > >>> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > >>>> > >>> > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > >>>> > >>> > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > >>>> > >>> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > >>>> > >>> > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > >>>> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > >>>> java.lang.Thread.run(Thread.java:619) > >>>> > >>> > -------------------------------------------------------------------------------- > >>>> > >>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ > >>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] transaction > >>>> rolled back > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > >>>> ServiceDispatcher.java:599:INFO ] Sync service > >>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in > >>> [112] > >>>> milliseconds with response [{errorMessageList={Area code is missing, > >>> Falta > >>>> Teléfono de Contacto}, responseMessage=error}] > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > >>>> RequestHandler.java:639:INFO ] Ran Event > >>>> [service:#createUpdateCustomerAndShippingAddress] from [request], > result > >>> is > >>>> [error] > >>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ > >>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress > >>> caused an > >>>> error with the following message: {Area code is missing, Falta > Teléfono > >>> de > >>>> Contacto} > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > >>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response is > a > >>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > >>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: > >>>> requestUri=json overrideViewUri=null > >>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > >>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > >>>> RequestHandler.java:639:INFO ] Ran Event > >>>> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] > >>> from > >>>> [request], result is [success] > >>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ > >>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, > >>> ServerHitBin > >>>> delegatorName=default#JF > >>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ > >>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for > >>> [ServerHitBin]; > >>>> curSeqId=53390, maxSeqId=53400, bankSize=10 > >>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ > >>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] Request > >>> Done- > >>>> total:0.386,since last([createUpdateShip...):0.386]] > >>>> > >>>> > >>>> > >>> > ----------------------------------------------------------------------------------------------- > >>>> > >>>> After a bit of investigation I found this: > >>>> > >>>> The event 'createUpdateCustomerAndShippingAddress' is returning an > error > >>> as > >>>> a result but since the request is chained (with a json request) the > >>>> controller takes the response from the event > >>>> 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' > >>> which > >>>> is always 'success'. So that's why I figure out the ajax error handler > >>> is > >>>> never invoked. > >>>> > >>>> What do you think? > >>>> > >>>> For further details, I am using a 3 months old trunk version with > MySql. > >>>> I've checked out the latest version > >>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still > the > >>> same > >>>> code as I have. > >>>> > >>>> Thanks in advance. > >>>> > >>> > >> > >> > >> > >> -- > >> ----- > >> > >> Jonatan Soto > >> > > > > > > > > -- > > ----- > > > > Jonatan Soto > > -- ----- Jonatan Soto |
Jonatan,
I think if you use <response name="error" type="request" value="json"/> (it is used in several places in ecommerce and other components' controller.xml) and then use the getServerError() function (used in specialpurpose/ecommerce/webapp/ecommerce/images/profile.js) to parse the JSON response, then you should be able to retrieve the error message to display it to the user. I'm not sure if it will be helpful, I didn't got the problem completely either ;-) ----- Original Message ----- From: "Jonatan Soto" <[hidden email]> To: [hidden email] Sent: Sunday, July 17, 2011 5:56:10 PM Subject: Re: Issue with ajax and json response Done. Patch provided, not fully tested. https://issues.apache.org/jira/browse/OFBIZ-4342 <https://issues.apache.org/jira/browse/OFBIZ-4342>Regards, On Sun, Jul 17, 2011 at 1:34 PM, Scott Gray <[hidden email]>wrote: > Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, would > be great if you could create a jira issue so this doesn't get lost. > > Regards > Scott > > HotWax Media > http://www.hotwaxmedia.com > > On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: > > > Well, I did a little read on the jquery ajax documentation ( > > http://api.jquery.com/jQuery.ajax/) and some of my assertions were > wrong. > > It is definitively not related to > > the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when I > > realized that the result the controller returns has nothing to do with > the > > ajax callbacks :) > > > > According to this doc the error callback is: > > "A function to be called if the request fails...." > > > > In the case I'm exposing, obviously the request is not failing so the > error > > I'm getting should be handled in the success callback. Please, tell me if > > there is another way to do it. > > I found a js function in the CheckoutProcess.js called > getServerError(...) > > which is never invoked. I think it should be included in the success > > callback like the following code: > > > > (chekoutProcess.js) > > > > // Check server side error > > function getServerError(data) { > > var serverErrorHash = []; > > var serverError = ""; > > if (data._ERROR_MESSAGE_LIST_ != undefined) { > > serverErrorHash = data._ERROR_MESSAGE_LIST_; > > jQuery.each(serverErrorHash, function(i, error) { > > serverError += error.message + '<br/>'; > > }); > > } > > if (data._ERROR_MESSAGE_ != undefined) { > > serverError = data._ERROR_MESSAGE_; > > } > > return serverError; > > } > > > > function createUpdateCustomerAndShippingAddress() { > > var result = false; > > jQuery.ajax({ > > url: 'createUpdateShippingAddress', > > type: 'POST', > > dataType: 'json', > > async: false, > > data: jQuery('#shippingForm').serialize(), > > success: function(json) { > > var serverError = getServerError(json); > > if (!serverError) { > > jQuery('#shippingFormServerError').fadeOut('fast'); > > // Process Shipping data response. > > jQuery('#shipToPartyId').val(json.partyId); > > jQuery('#billToPartyId').val(json.partyId); > > jQuery('#shipToContactMechId').val(json.contactMechId); > > > > jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); > > jQuery('#emailContactMechId').val(json.emailContactMechId); > > > > //jQuery('#completedShippingMethod').html(json.shippingDescription); > > updateShippingSummary(); > > getShipOptions(); > > result = true; > > } else { > > jQuery('#shippingFormServerError').html(serverError); > > jQuery('#shippingFormServerError').css("display","block"); > > result = false; > > } > > }, > > error: function(error) { > > if (error != "") { > > jQuery('#shippingFormServerError').html(error); > > } > > result = false; > > } > > }); > > return result; > > } > > > > Now with this modifications I am showing the server side error messages > > correctly. > > > > > > HTH > > > > > > On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto <[hidden email] > >wrote: > > > >> Hi BJ, > >> > >> The setAnonuserLogin is an ECA triggered before. The problem is after it > if > >> I'm not wrong. > >> > >> Look at: > >> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > >> ServiceDispatcher.java:599:INFO ] Sync service > >> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in > [112] > >> milliseconds with response [{errorMessageList={Area code is missing, > Falta > >> Teléfono de Contacto}, responseMessage=error}] > >> ... > >> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > >> RequestHandler.java:639:INFO ] Ran Event > >> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] > from > >> [request], result is [success] > >> > >> The service that is called from ajax is returning 'error' but the > chained > >> json request is returning 'success'. I guess this is the problem. > >> > >> Thanks anyway! > >> > >> > >> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> > wrote: > >> > >>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with > >>> response [{responseMessage=success}] > >>> > >>> it is evaluating a good lognin. this is where to debug. > >>> > >>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: > >>>> Hi all, > >>>> > >>>> I am customizing the onePageCheckout (the anonymous part) and I found > >>>> something strange. I've changed the client-side validation in order to > >>> allow > >>>> the customer to only introduce the phone, cell phone or both. But on > >>>> server-side I didn't change anything in the > PartyContactMechMapProcs.xml > >>>> yet. So, it is throwing an error of course, but the ajax handler does > >>> not > >>>> consider it as an error. It always executes the success ajax handler! > >>>> > >>>> This is the stack trace: > >>>> > >>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ > >>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] Request > >>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] > >>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ > >>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 > >>> requests, > >>>> 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml > >>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ > >>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: > >>>> setAnonUserLogin, triggered by rule on Service: > >>>> createUpdateCustomerAndShippingAddress > >>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ > >>>> ServiceDispatcher.java:599:INFO ] Sync service > >>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with > >>>> response [{responseMessage=success}] > >>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ > >>>> TransactionUtil.java:374:WARN ] > >>>> ---- exception report > >>>> ---------------------------------------------------------- > >>>> [TransactionUtil.setRollbackOnly] Calling transaction setRollbackOnly; > >>> this > >>>> stack trace shows where this is happening: > >>>> Exception: java.lang.Exception > >>>> Message: Error in simple-method [Create/Update Customer, Shipping > >>> Address > >>>> and other contact details. > >>>> > >>> > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > >>>> ; {Area code is missing, Falta Teléfono de Contacto} > >>>> ---- stack trace > >>>> --------------------------------------------------------------- > >>>> java.lang.Exception: Error in simple-method [Create/Update Customer, > >>>> Shipping Address and other contact details. > >>>> > >>> > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > >>>> ; {Area code is missing, Falta Teléfono de Contacto} > >>>> > >>> > org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) > >>>> > >>> > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) > >>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) > >>>> org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) > >>>> > org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) > >>>> > >>> > org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) > >>>> > >>> > org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) > >>>> > >>> > org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) > >>>> > >>> > _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) > >>>> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) > >>>> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > >>>> > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > >>>> > >>> > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > >>>> > >>> > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > >>>> > >>> > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > >>>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > >>>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > >>>> > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > >>>> > >>> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > >>>> > >>> > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > >>>> > >>> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > >>>> > >>> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > >>>> > >>> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > >>>> > >>> > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > >>>> > >>> > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > >>>> > >>> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > >>>> > >>> > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > >>>> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > >>>> java.lang.Thread.run(Thread.java:619) > >>>> > >>> > -------------------------------------------------------------------------------- > >>>> > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > >>>> ServiceDispatcher.java:543:ERROR] Error in Service > >>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, Falta > >>>> Teléfono de Contacto > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > >>>> TransactionUtil.java:338:ERROR] > >>>> ---- exception report > >>>> ---------------------------------------------------------- > >>>> [TransactionUtil.rollback] > >>>> Exception: java.lang.Exception > >>>> Message: Stack Trace > >>>> ---- stack trace > >>>> --------------------------------------------------------------- > >>>> java.lang.Exception: Stack Trace > >>>> > >>> > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) > >>>> > >>> > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) > >>>> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) > >>>> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > >>>> > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > >>>> > >>> > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > >>>> > >>> > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > >>>> > >>> > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > >>>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > >>>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > >>>> > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > >>>> > >>> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > >>>> > >>> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > >>>> > >>> > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > >>>> > >>> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > >>>> > >>> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > >>>> > >>> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > >>>> > >>> > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > >>>> > >>> > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > >>>> > >>> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > >>>> > >>> > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > >>>> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > >>>> java.lang.Thread.run(Thread.java:619) > >>>> > >>> > -------------------------------------------------------------------------------- > >>>> > >>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ > >>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] transaction > >>>> rolled back > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > >>>> ServiceDispatcher.java:599:INFO ] Sync service > >>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in > >>> [112] > >>>> milliseconds with response [{errorMessageList={Area code is missing, > >>> Falta > >>>> Teléfono de Contacto}, responseMessage=error}] > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > >>>> RequestHandler.java:639:INFO ] Ran Event > >>>> [service:#createUpdateCustomerAndShippingAddress] from [request], > result > >>> is > >>>> [error] > >>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ > >>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress > >>> caused an > >>>> error with the following message: {Area code is missing, Falta > Teléfono > >>> de > >>>> Contacto} > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > >>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response is > a > >>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > >>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: > >>>> requestUri=json overrideViewUri=null > >>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > >>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > >>>> RequestHandler.java:639:INFO ] Ran Event > >>>> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] > >>> from > >>>> [request], result is [success] > >>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ > >>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, > >>> ServerHitBin > >>>> delegatorName=default#JF > >>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ > >>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for > >>> [ServerHitBin]; > >>>> curSeqId=53390, maxSeqId=53400, bankSize=10 > >>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ > >>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] Request > >>> Done- > >>>> total:0.386,since last([createUpdateShip...):0.386]] > >>>> > >>>> > >>>> > >>> > ----------------------------------------------------------------------------------------------- > >>>> > >>>> After a bit of investigation I found this: > >>>> > >>>> The event 'createUpdateCustomerAndShippingAddress' is returning an > error > >>> as > >>>> a result but since the request is chained (with a json request) the > >>>> controller takes the response from the event > >>>> 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' > >>> which > >>>> is always 'success'. So that's why I figure out the ajax error handler > >>> is > >>>> never invoked. > >>>> > >>>> What do you think? > >>>> > >>>> For further details, I am using a 3 months old trunk version with > MySql. > >>>> I've checked out the latest version > >>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still > the > >>> same > >>>> code as I have. > >>>> > >>>> Thanks in advance. > >>>> > >>> > >> > >> > >> > >> -- > >> ----- > >> > >> Jonatan Soto > >> > > > > > > > > -- > > ----- > > > > Jonatan Soto > > -- ----- Jonatan Soto |
Hi Atul,
I've didn't got server error messages using what you said. Probably is something wrong in my code, but what I have noticed is that no matters what kind of response I set, the 'success' callback method is called. Anyway, how is handled the server response in this case? I mean, where can I find the code where the getServerError() JS function is called once we return the error response? Many thanks Atul. On Fri, Aug 26, 2011 at 7:32 PM, Atul Vani <[hidden email]>wrote: > Jonatan, > > I think if you use > <response name="error" type="request" value="json"/> > (it is used in several places in ecommerce and other components' > controller.xml) > > and then use the getServerError() function > (used in specialpurpose/ecommerce/webapp/ecommerce/images/profile.js) > to parse the JSON response, > then you should be able to retrieve the error message to display it to the > user. > > I'm not sure if it will be helpful, I didn't got the problem completely > either ;-) > > > ----- Original Message ----- > From: "Jonatan Soto" <[hidden email]> > To: [hidden email] > Sent: Sunday, July 17, 2011 5:56:10 PM > Subject: Re: Issue with ajax and json response > > Done. Patch provided, not fully tested. > https://issues.apache.org/jira/browse/OFBIZ-4342 > > <https://issues.apache.org/jira/browse/OFBIZ-4342>Regards, > > > On Sun, Jul 17, 2011 at 1:34 PM, Scott Gray <[hidden email] > >wrote: > > > Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, would > > be great if you could create a jira issue so this doesn't get lost. > > > > Regards > > Scott > > > > HotWax Media > > http://www.hotwaxmedia.com > > > > On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: > > > > > Well, I did a little read on the jquery ajax documentation ( > > > http://api.jquery.com/jQuery.ajax/) and some of my assertions were > > wrong. > > > It is definitively not related to > > > the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when > I > > > realized that the result the controller returns has nothing to do with > > the > > > ajax callbacks :) > > > > > > According to this doc the error callback is: > > > "A function to be called if the request fails...." > > > > > > In the case I'm exposing, obviously the request is not failing so the > > error > > > I'm getting should be handled in the success callback. Please, tell me > if > > > there is another way to do it. > > > I found a js function in the CheckoutProcess.js called > > getServerError(...) > > > which is never invoked. I think it should be included in the success > > > callback like the following code: > > > > > > (chekoutProcess.js) > > > > > > // Check server side error > > > function getServerError(data) { > > > var serverErrorHash = []; > > > var serverError = ""; > > > if (data._ERROR_MESSAGE_LIST_ != undefined) { > > > serverErrorHash = data._ERROR_MESSAGE_LIST_; > > > jQuery.each(serverErrorHash, function(i, error) { > > > serverError += error.message + '<br/>'; > > > }); > > > } > > > if (data._ERROR_MESSAGE_ != undefined) { > > > serverError = data._ERROR_MESSAGE_; > > > } > > > return serverError; > > > } > > > > > > function createUpdateCustomerAndShippingAddress() { > > > var result = false; > > > jQuery.ajax({ > > > url: 'createUpdateShippingAddress', > > > type: 'POST', > > > dataType: 'json', > > > async: false, > > > data: jQuery('#shippingForm').serialize(), > > > success: function(json) { > > > var serverError = getServerError(json); > > > if (!serverError) { > > > jQuery('#shippingFormServerError').fadeOut('fast'); > > > // Process Shipping data response. > > > jQuery('#shipToPartyId').val(json.partyId); > > > jQuery('#billToPartyId').val(json.partyId); > > > jQuery('#shipToContactMechId').val(json.contactMechId); > > > > > > jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); > > > jQuery('#emailContactMechId').val(json.emailContactMechId); > > > > > > //jQuery('#completedShippingMethod').html(json.shippingDescription); > > > updateShippingSummary(); > > > getShipOptions(); > > > result = true; > > > } else { > > > jQuery('#shippingFormServerError').html(serverError); > > > > jQuery('#shippingFormServerError').css("display","block"); > > > result = false; > > > } > > > }, > > > error: function(error) { > > > if (error != "") { > > > jQuery('#shippingFormServerError').html(error); > > > } > > > result = false; > > > } > > > }); > > > return result; > > > } > > > > > > Now with this modifications I am showing the server side error messages > > > correctly. > > > > > > > > > HTH > > > > > > > > > On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto < > [hidden email] > > >wrote: > > > > > >> Hi BJ, > > >> > > >> The setAnonuserLogin is an ECA triggered before. The problem is after > it > > if > > >> I'm not wrong. > > >> > > >> Look at: > > >> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > > >> ServiceDispatcher.java:599:INFO ] Sync service > > >> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in > > [112] > > >> milliseconds with response [{errorMessageList={Area code is missing, > > Falta > > >> Teléfono de Contacto}, responseMessage=error}] > > >> ... > > >> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > > >> RequestHandler.java:639:INFO ] Ran Event > > >> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] > > from > > >> [request], result is [success] > > >> > > >> The service that is called from ajax is returning 'error' but the > > chained > > >> json request is returning 'success'. I guess this is the problem. > > >> > > >> Thanks anyway! > > >> > > >> > > >> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> > > wrote: > > >> > > >>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with > > >>> response [{responseMessage=success}] > > >>> > > >>> it is evaluating a good lognin. this is where to debug. > > >>> > > >>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: > > >>>> Hi all, > > >>>> > > >>>> I am customizing the onePageCheckout (the anonymous part) and I > found > > >>>> something strange. I've changed the client-side validation in order > to > > >>> allow > > >>>> the customer to only introduce the phone, cell phone or both. But on > > >>>> server-side I didn't change anything in the > > PartyContactMechMapProcs.xml > > >>>> yet. So, it is throwing an error of course, but the ajax handler > does > > >>> not > > >>>> consider it as an error. It always executes the success ajax > handler! > > >>>> > > >>>> This is the stack trace: > > >>>> > > >>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ > > >>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] > Request > > >>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] > > >>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ > > >>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 > > >>> requests, > > >>>> 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml > > >>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ > > >>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: > > >>>> setAnonUserLogin, triggered by rule on Service: > > >>>> createUpdateCustomerAndShippingAddress > > >>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ > > >>>> ServiceDispatcher.java:599:INFO ] Sync service > > >>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds > with > > >>>> response [{responseMessage=success}] > > >>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ > > >>>> TransactionUtil.java:374:WARN ] > > >>>> ---- exception report > > >>>> ---------------------------------------------------------- > > >>>> [TransactionUtil.setRollbackOnly] Calling transaction > setRollbackOnly; > > >>> this > > >>>> stack trace shows where this is happening: > > >>>> Exception: java.lang.Exception > > >>>> Message: Error in simple-method [Create/Update Customer, Shipping > > >>> Address > > >>>> and other contact details. > > >>>> > > >>> > > > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > > >>>> ; {Area code is missing, Falta Teléfono de Contacto} > > >>>> ---- stack trace > > >>>> --------------------------------------------------------------- > > >>>> java.lang.Exception: Error in simple-method [Create/Update Customer, > > >>>> Shipping Address and other contact details. > > >>>> > > >>> > > > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > > >>>> ; {Area code is missing, Falta Teléfono de Contacto} > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) > > >>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) > > >>>> > org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) > > >>>> > > org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) > > >>>> > > >>> > > > org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) > > >>>> > > >>> > > > org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) > > >>>> > > >>> > > > org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) > > >>>> > > >>> > > > _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > > >>>> > > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > > >>>> > > >>> > > > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > > >>>> > > >>> > > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > > >>>> > > >>> > > > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > >>> > > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > > >>>> > > >>> > > > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > > >>>> > > >>> > > > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > > >>>> > > >>> > > > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > > >>>> > > >>> > > > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > > >>>> > > >>> > > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > > >>>> > > >>> > > > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > > >>>> > > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > > >>>> java.lang.Thread.run(Thread.java:619) > > >>>> > > >>> > > > -------------------------------------------------------------------------------- > > >>>> > > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > > >>>> ServiceDispatcher.java:543:ERROR] Error in Service > > >>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, > Falta > > >>>> Teléfono de Contacto > > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > > >>>> TransactionUtil.java:338:ERROR] > > >>>> ---- exception report > > >>>> ---------------------------------------------------------- > > >>>> [TransactionUtil.rollback] > > >>>> Exception: java.lang.Exception > > >>>> Message: Stack Trace > > >>>> ---- stack trace > > >>>> --------------------------------------------------------------- > > >>>> java.lang.Exception: Stack Trace > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > > >>>> > > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > > >>>> > > >>> > > > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > > >>>> > > >>> > > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > > >>>> > > >>> > > > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > >>> > > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > > >>>> > > >>> > > > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > > >>>> > > >>> > > > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > > >>>> > > >>> > > > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > > >>>> > > >>> > > > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > > >>>> > > >>> > > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > > >>>> > > >>> > > > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > > >>>> > > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > > >>>> java.lang.Thread.run(Thread.java:619) > > >>>> > > >>> > > > -------------------------------------------------------------------------------- > > >>>> > > >>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ > > >>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] > transaction > > >>>> rolled back > > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > > >>>> ServiceDispatcher.java:599:INFO ] Sync service > > >>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in > > >>> [112] > > >>>> milliseconds with response [{errorMessageList={Area code is missing, > > >>> Falta > > >>>> Teléfono de Contacto}, responseMessage=error}] > > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:639:INFO ] Ran Event > > >>>> [service:#createUpdateCustomerAndShippingAddress] from [request], > > result > > >>> is > > >>>> [error] > > >>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress > > >>> caused an > > >>>> error with the following message: {Area code is missing, Falta > > Teléfono > > >>> de > > >>>> Contacto} > > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response > is > > a > > >>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: > > >>>> requestUri=json overrideViewUri=null > > >>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > > >>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:639:INFO ] Ran Event > > >>>> > [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] > > >>> from > > >>>> [request], result is [success] > > >>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ > > >>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, > > >>> ServerHitBin > > >>>> delegatorName=default#JF > > >>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ > > >>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for > > >>> [ServerHitBin]; > > >>>> curSeqId=53390, maxSeqId=53400, bankSize=10 > > >>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ > > >>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] > Request > > >>> Done- > > >>>> total:0.386,since last([createUpdateShip...):0.386]] > > >>>> > > >>>> > > >>>> > > >>> > > > ----------------------------------------------------------------------------------------------- > > >>>> > > >>>> After a bit of investigation I found this: > > >>>> > > >>>> The event 'createUpdateCustomerAndShippingAddress' is returning an > > error > > >>> as > > >>>> a result but since the request is chained (with a json request) the > > >>>> controller takes the response from the event > > >>>> > 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' > > >>> which > > >>>> is always 'success'. So that's why I figure out the ajax error > handler > > >>> is > > >>>> never invoked. > > >>>> > > >>>> What do you think? > > >>>> > > >>>> For further details, I am using a 3 months old trunk version with > > MySql. > > >>>> I've checked out the latest version > > >>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still > > the > > >>> same > > >>>> code as I have. > > >>>> > > >>>> Thanks in advance. > > >>>> > > >>> > > >> > > >> > > >> > > >> -- > > >> ----- > > >> > > >> Jonatan Soto > > >> > > > > > > > > > > > > -- > > > ----- > > > > > > Jonatan Soto > > > > > > > -- > ----- > > Jonatan Soto > -- ----- Jonatan Soto |
Administrator
|
Hi Jonatan,
Your patch looks good at 1st glance, but you say below "not fully tested" what do you mean by that? Do we need to test something which could be specifically missing or has not been tested, or is it just a point in the dark? Thanks Jacques Jonatan Soto wrote: > Hi Atul, > > I've didn't got server error messages using what you said. Probably is > something wrong in my code, but what I have noticed is that no matters what > kind of response I set, the 'success' callback method is called. > Anyway, how is handled the server response in this case? I mean, where can I > find the code where the getServerError() JS function is called once we > return the error response? > > Many thanks Atul. > > On Fri, Aug 26, 2011 at 7:32 PM, Atul Vani <[hidden email]>wrote: > >> Jonatan, >> >> I think if you use >> <response name="error" type="request" value="json"/> >> (it is used in several places in ecommerce and other components' >> controller.xml) >> >> and then use the getServerError() function >> (used in specialpurpose/ecommerce/webapp/ecommerce/images/profile.js) >> to parse the JSON response, >> then you should be able to retrieve the error message to display it to the >> user. >> >> I'm not sure if it will be helpful, I didn't got the problem completely >> either ;-) >> >> >> ----- Original Message ----- >> From: "Jonatan Soto" <[hidden email]> >> To: [hidden email] >> Sent: Sunday, July 17, 2011 5:56:10 PM >> Subject: Re: Issue with ajax and json response >> >> Done. Patch provided, not fully tested. >> https://issues.apache.org/jira/browse/OFBIZ-4342 >> >> <https://issues.apache.org/jira/browse/OFBIZ-4342>Regards, >> >> >> On Sun, Jul 17, 2011 at 1:34 PM, Scott Gray <[hidden email] >>> wrote: >> >>> Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, would >>> be great if you could create a jira issue so this doesn't get lost. >>> >>> Regards >>> Scott >>> >>> HotWax Media >>> http://www.hotwaxmedia.com >>> >>> On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: >>> >>>> Well, I did a little read on the jquery ajax documentation ( >>>> http://api.jquery.com/jQuery.ajax/) and some of my assertions were wrong. >>>> It is definitively not related to >>>> the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when I >>>> realized that the result the controller returns has nothing to do with the >>>> ajax callbacks :) >>>> >>>> According to this doc the error callback is: >>>> "A function to be called if the request fails...." >>>> >>>> In the case I'm exposing, obviously the request is not failing so the error >>>> I'm getting should be handled in the success callback. Please, tell me if >>>> there is another way to do it. >>>> I found a js function in the CheckoutProcess.js called getServerError(...) >>>> which is never invoked. I think it should be included in the success >>>> callback like the following code: >>>> >>>> (chekoutProcess.js) >>>> >>>> // Check server side error >>>> function getServerError(data) { >>>> var serverErrorHash = []; >>>> var serverError = ""; >>>> if (data._ERROR_MESSAGE_LIST_ != undefined) { >>>> serverErrorHash = data._ERROR_MESSAGE_LIST_; >>>> jQuery.each(serverErrorHash, function(i, error) { >>>> serverError += error.message + '<br/>'; >>>> }); >>>> } >>>> if (data._ERROR_MESSAGE_ != undefined) { >>>> serverError = data._ERROR_MESSAGE_; >>>> } >>>> return serverError; >>>> } >>>> >>>> function createUpdateCustomerAndShippingAddress() { >>>> var result = false; >>>> jQuery.ajax({ >>>> url: 'createUpdateShippingAddress', >>>> type: 'POST', >>>> dataType: 'json', >>>> async: false, >>>> data: jQuery('#shippingForm').serialize(), >>>> success: function(json) { >>>> var serverError = getServerError(json); >>>> if (!serverError) { >>>> jQuery('#shippingFormServerError').fadeOut('fast'); >>>> // Process Shipping data response. >>>> jQuery('#shipToPartyId').val(json.partyId); >>>> jQuery('#billToPartyId').val(json.partyId); >>>> jQuery('#shipToContactMechId').val(json.contactMechId); >>>> >>>> jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); >>>> jQuery('#emailContactMechId').val(json.emailContactMechId); >>>> >>>> //jQuery('#completedShippingMethod').html(json.shippingDescription); >>>> updateShippingSummary(); >>>> getShipOptions(); >>>> result = true; >>>> } else { >>>> jQuery('#shippingFormServerError').html(serverError); >>>> >> jQuery('#shippingFormServerError').css("display","block"); >>>> result = false; >>>> } >>>> }, >>>> error: function(error) { >>>> if (error != "") { >>>> jQuery('#shippingFormServerError').html(error); >>>> } >>>> result = false; >>>> } >>>> }); >>>> return result; >>>> } >>>> >>>> Now with this modifications I am showing the server side error messages >>>> correctly. >>>> >>>> >>>> HTH >>>> >>>> >>>> On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto < [hidden email] >>>> wrote: >>>> >>>>> Hi BJ, >>>>> >>>>> The setAnonuserLogin is an ECA triggered before. The problem is after it if >>>>> I'm not wrong. >>>>> >>>>> Look at: >>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>> ServiceDispatcher.java:599:INFO ] Sync service >>>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] >>>>> milliseconds with response [{errorMessageList={Area code is missing, Falta >>>>> Teléfono de Contacto}, responseMessage=error}] >>>>> ... >>>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>>>> RequestHandler.java:639:INFO ] Ran Event >>>>> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] from >>>>> [request], result is [success] >>>>> >>>>> The service that is called from ajax is returning 'error' but the chained >>>>> json request is returning 'success'. I guess this is the problem. >>>>> >>>>> Thanks anyway! >>>>> >>>>> >>>>> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> wrote: >>>>> >>>>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >>>>>> response [{responseMessage=success}] >>>>>> >>>>>> it is evaluating a good lognin. this is where to debug. >>>>>> >>>>>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: >>>>>>> Hi all, >>>>>>> >>>>>>> I am customizing the onePageCheckout (the anonymous part) and I found >>>>>>> something strange. I've changed the client-side validation in order to allow >>>>>>> the customer to only introduce the phone, cell phone or both. But on >>>>>>> server-side I didn't change anything in the PartyContactMechMapProcs.xml >>>>>>> yet. So, it is throwing an error of course, but the ajax handler does not >>>>>>> consider it as an error. It always executes the success ajax handler! >>>>>>> >>>>>>> This is the stack trace: >>>>>>> >>>>>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ >>>>>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] Request >>>>>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] >>>>>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ >>>>>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 requests, >>>>>>> 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml >>>>>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ >>>>>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: >>>>>>> setAnonUserLogin, triggered by rule on Service: >>>>>>> createUpdateCustomerAndShippingAddress >>>>>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ >>>>>>> ServiceDispatcher.java:599:INFO ] Sync service >>>>>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >>>>>>> response [{responseMessage=success}] >>>>>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ >>>>>>> TransactionUtil.java:374:WARN ] >>>>>>> ---- exception report >>>>>>> ---------------------------------------------------------- >>>>>>> [TransactionUtil.setRollbackOnly] Calling transaction setRollbackOnly; this >>>>>>> stack trace shows where this is happening: >>>>>>> Exception: java.lang.Exception >>>>>>> Message: Error in simple-method [Create/Update Customer, Shipping Address >>>>>>> and other contact details. >>>>>>> >>>>>> >>> >> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>>>>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>>>>> ---- stack trace >>>>>>> --------------------------------------------------------------- >>>>>>> java.lang.Exception: Error in simple-method [Create/Update Customer, >>>>>>> Shipping Address and other contact details. >>>>>>> >>>>>> >>> >> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>>>>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>>>>> >>>>>> >>> >> org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) >>>>>>> >>>>>> >>> >> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) >>>>>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) >>>>>>> >> org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) >>>>>>> >>> org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) >>>>>>> >>>>>> >>> >> org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) >>>>>>> >>>>>> >>> >> org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) >>>>>>> >>>>>> >>> >> org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) >>>>>>> >>>>>> >>> >> _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) >>>>>>> >>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) >>>>>>> >>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>>>>>> >>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>>>>>> >>>>>> >>> >> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>>>>>> >>>>>> >>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>>>>>> >>>>>> >>> >> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>>>>>> >> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>>>>>> >> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>>>>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>>>>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>>>>> >>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>>>>>> >>>>>> >>> >> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>>>>>> >>>>>> >>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>>>>>> >>>>>> >>> >> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>>>>>> >>>>>> >>> >> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>>>>>> >>>>>> >>> >> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>>>>>> >>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>>>>>> java.lang.Thread.run(Thread.java:619) >>>>>>> >>>>>> >>> >> -------------------------------------------------------------------------------- >>>>>>> >>>>>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>>>>> ServiceDispatcher.java:543:ERROR] Error in Service >>>>>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, Falta >>>>>>> Teléfono de Contacto >>>>>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>>>>> TransactionUtil.java:338:ERROR] >>>>>>> ---- exception report >>>>>>> ---------------------------------------------------------- >>>>>>> [TransactionUtil.rollback] >>>>>>> Exception: java.lang.Exception >>>>>>> Message: Stack Trace >>>>>>> ---- stack trace >>>>>>> --------------------------------------------------------------- >>>>>>> java.lang.Exception: Stack Trace >>>>>>> >>>>>> >>> >> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) >>>>>>> >>>>>> >>> >> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) >>>>>>> >>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) >>>>>>> >>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>>>>>> >>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>>>>>> >>>>>> >>> >> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>>>>>> >>>>>> >>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>>>>>> >>>>>> >>> >> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>>>>>> >> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>>>>>> >> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>>>>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>>>>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>>>>> >>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>>>>>> >>>>>> >>> >> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>>>>>> >>>>>> >>> >> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>>>>>> >>>>>> >>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>>>>>> >>>>>> >>> >> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>>>>>> >>>>>> >>> >> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>>>>>> >>>>>> >>> >> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>>>>>> >>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>>>>>> java.lang.Thread.run(Thread.java:619) >>>>>>> >>>>>> >>> >> -------------------------------------------------------------------------------- >>>>>>> >>>>>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ >>>>>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] transaction >>>>>>> rolled back >>>>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>>>> ServiceDispatcher.java:599:INFO ] Sync service >>>>>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] >>>>>>> milliseconds with response [{errorMessageList={Area code is missing, Falta >>>>>>> Teléfono de Contacto}, responseMessage=error}] >>>>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>>>> RequestHandler.java:639:INFO ] Ran Event >>>>>>> [service:#createUpdateCustomerAndShippingAddress] from [request], result is >>>>>>> [error] >>>>>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ >>>>>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress caused an >>>>>>> error with the following message: {Area code is missing, Falta Teléfono de >>>>>>> Contacto} >>>>>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>>>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response is a >>>>>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>>>>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>>>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: >>>>>>> requestUri=json overrideViewUri=null >>>>>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>>>>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>>>>>> RequestHandler.java:639:INFO ] Ran Event >>>>>>> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] from >>>>>>> [request], result is [success] >>>>>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ >>>>>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, ServerHitBin >>>>>>> delegatorName=default#JF >>>>>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ >>>>>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for [ServerHitBin]; >>>>>>> curSeqId=53390, maxSeqId=53400, bankSize=10 >>>>>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ >>>>>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] Request Done- >>>>>>> total:0.386,since last([createUpdateShip...):0.386]] >>>>>>> >>>>>>> >>>>>>> >>>>>> >>> >> ----------------------------------------------------------------------------------------------- >>>>>>> >>>>>>> After a bit of investigation I found this: >>>>>>> >>>>>>> The event 'createUpdateCustomerAndShippingAddress' is returning an error as >>>>>>> a result but since the request is chained (with a json request) the >>>>>>> controller takes the response from the event >>>>>>> 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' which >>>>>>> is always 'success'. So that's why I figure out the ajax error handler is >>>>>>> never invoked. >>>>>>> >>>>>>> What do you think? >>>>>>> >>>>>>> For further details, I am using a 3 months old trunk version with MySql. >>>>>>> I've checked out the latest version >>>>>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still the same >>>>>>> code as I have. >>>>>>> >>>>>>> Thanks in advance. >>>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> ----- >>>>> >>>>> Jonatan Soto >>>>> >>>> >>>> >>>> >>>> -- >>>> ----- >>>> >>>> Jonatan Soto >>> >>> >> >> >> -- >> ----- >> >> Jonatan Soto |
Administrator
|
In reply to this post by jonatan soto
Also I think there are some tabs in your patch (I can see them because your file is automatically rendered in browsers)
I see some jQuery('#shippingFormServerError').html(serverError); lines wrongly formatted Jacques Jacques Le Roux wrote: > Hi Jonatan, > > Your patch looks good at 1st glance, but you say below "not fully tested" what do you mean by that? Do we need to test something > which could be specifically missing or has not been tested, or is it just a point in the dark? > > Thanks > > Jacques > > Jonatan Soto wrote: >> Hi Atul, >> >> I've didn't got server error messages using what you said. Probably is >> something wrong in my code, but what I have noticed is that no matters what >> kind of response I set, the 'success' callback method is called. >> Anyway, how is handled the server response in this case? I mean, where can I >> find the code where the getServerError() JS function is called once we >> return the error response? >> >> Many thanks Atul. >> >> On Fri, Aug 26, 2011 at 7:32 PM, Atul Vani <[hidden email]>wrote: >> >>> Jonatan, >>> >>> I think if you use >>> <response name="error" type="request" value="json"/> >>> (it is used in several places in ecommerce and other components' >>> controller.xml) >>> >>> and then use the getServerError() function >>> (used in specialpurpose/ecommerce/webapp/ecommerce/images/profile.js) >>> to parse the JSON response, >>> then you should be able to retrieve the error message to display it to the >>> user. >>> >>> I'm not sure if it will be helpful, I didn't got the problem completely >>> either ;-) >>> >>> >>> ----- Original Message ----- >>> From: "Jonatan Soto" <[hidden email]> >>> To: [hidden email] >>> Sent: Sunday, July 17, 2011 5:56:10 PM >>> Subject: Re: Issue with ajax and json response >>> >>> Done. Patch provided, not fully tested. >>> https://issues.apache.org/jira/browse/OFBIZ-4342 >>> >>> <https://issues.apache.org/jira/browse/OFBIZ-4342>Regards, >>> >>> >>> On Sun, Jul 17, 2011 at 1:34 PM, Scott Gray <[hidden email] >>>> wrote: >>> >>>> Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, would >>>> be great if you could create a jira issue so this doesn't get lost. >>>> >>>> Regards >>>> Scott >>>> >>>> HotWax Media >>>> http://www.hotwaxmedia.com >>>> >>>> On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: >>>> >>>>> Well, I did a little read on the jquery ajax documentation ( >>>>> http://api.jquery.com/jQuery.ajax/) and some of my assertions were wrong. >>>>> It is definitively not related to >>>>> the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when I >>>>> realized that the result the controller returns has nothing to do with the >>>>> ajax callbacks :) >>>>> >>>>> According to this doc the error callback is: >>>>> "A function to be called if the request fails...." >>>>> >>>>> In the case I'm exposing, obviously the request is not failing so the error >>>>> I'm getting should be handled in the success callback. Please, tell me if >>>>> there is another way to do it. >>>>> I found a js function in the CheckoutProcess.js called getServerError(...) >>>>> which is never invoked. I think it should be included in the success >>>>> callback like the following code: >>>>> >>>>> (chekoutProcess.js) >>>>> >>>>> // Check server side error >>>>> function getServerError(data) { >>>>> var serverErrorHash = []; >>>>> var serverError = ""; >>>>> if (data._ERROR_MESSAGE_LIST_ != undefined) { >>>>> serverErrorHash = data._ERROR_MESSAGE_LIST_; >>>>> jQuery.each(serverErrorHash, function(i, error) { >>>>> serverError += error.message + '<br/>'; >>>>> }); >>>>> } >>>>> if (data._ERROR_MESSAGE_ != undefined) { >>>>> serverError = data._ERROR_MESSAGE_; >>>>> } >>>>> return serverError; >>>>> } >>>>> >>>>> function createUpdateCustomerAndShippingAddress() { >>>>> var result = false; >>>>> jQuery.ajax({ >>>>> url: 'createUpdateShippingAddress', >>>>> type: 'POST', >>>>> dataType: 'json', >>>>> async: false, >>>>> data: jQuery('#shippingForm').serialize(), >>>>> success: function(json) { >>>>> var serverError = getServerError(json); >>>>> if (!serverError) { >>>>> jQuery('#shippingFormServerError').fadeOut('fast'); >>>>> // Process Shipping data response. >>>>> jQuery('#shipToPartyId').val(json.partyId); >>>>> jQuery('#billToPartyId').val(json.partyId); >>>>> jQuery('#shipToContactMechId').val(json.contactMechId); >>>>> >>>>> jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); >>>>> jQuery('#emailContactMechId').val(json.emailContactMechId); >>>>> >>>>> //jQuery('#completedShippingMethod').html(json.shippingDescription); >>>>> updateShippingSummary(); >>>>> getShipOptions(); >>>>> result = true; >>>>> } else { >>>>> jQuery('#shippingFormServerError').html(serverError); >>>>> >>> jQuery('#shippingFormServerError').css("display","block"); >>>>> result = false; >>>>> } >>>>> }, >>>>> error: function(error) { >>>>> if (error != "") { >>>>> jQuery('#shippingFormServerError').html(error); >>>>> } >>>>> result = false; >>>>> } >>>>> }); >>>>> return result; >>>>> } >>>>> >>>>> Now with this modifications I am showing the server side error messages >>>>> correctly. >>>>> >>>>> >>>>> HTH >>>>> >>>>> >>>>> On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto < [hidden email] >>>>> wrote: >>>>> >>>>>> Hi BJ, >>>>>> >>>>>> The setAnonuserLogin is an ECA triggered before. The problem is after it if >>>>>> I'm not wrong. >>>>>> >>>>>> Look at: >>>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>>> ServiceDispatcher.java:599:INFO ] Sync service >>>>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] >>>>>> milliseconds with response [{errorMessageList={Area code is missing, Falta >>>>>> Teléfono de Contacto}, responseMessage=error}] >>>>>> ... >>>>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>>>>> RequestHandler.java:639:INFO ] Ran Event >>>>>> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] from >>>>>> [request], result is [success] >>>>>> >>>>>> The service that is called from ajax is returning 'error' but the chained >>>>>> json request is returning 'success'. I guess this is the problem. >>>>>> >>>>>> Thanks anyway! >>>>>> >>>>>> >>>>>> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> wrote: >>>>>> >>>>>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >>>>>>> response [{responseMessage=success}] >>>>>>> >>>>>>> it is evaluating a good lognin. this is where to debug. >>>>>>> >>>>>>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: >>>>>>>> Hi all, >>>>>>>> >>>>>>>> I am customizing the onePageCheckout (the anonymous part) and I found >>>>>>>> something strange. I've changed the client-side validation in order to allow >>>>>>>> the customer to only introduce the phone, cell phone or both. But on >>>>>>>> server-side I didn't change anything in the PartyContactMechMapProcs.xml >>>>>>>> yet. So, it is throwing an error of course, but the ajax handler does not >>>>>>>> consider it as an error. It always executes the success ajax handler! >>>>>>>> >>>>>>>> This is the stack trace: >>>>>>>> >>>>>>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ >>>>>>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] Request >>>>>>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] >>>>>>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ >>>>>>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 requests, >>>>>>>> 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml >>>>>>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ >>>>>>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: >>>>>>>> setAnonUserLogin, triggered by rule on Service: >>>>>>>> createUpdateCustomerAndShippingAddress >>>>>>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ >>>>>>>> ServiceDispatcher.java:599:INFO ] Sync service >>>>>>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >>>>>>>> response [{responseMessage=success}] >>>>>>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ >>>>>>>> TransactionUtil.java:374:WARN ] >>>>>>>> ---- exception report >>>>>>>> ---------------------------------------------------------- >>>>>>>> [TransactionUtil.setRollbackOnly] Calling transaction setRollbackOnly; this >>>>>>>> stack trace shows where this is happening: >>>>>>>> Exception: java.lang.Exception >>>>>>>> Message: Error in simple-method [Create/Update Customer, Shipping Address >>>>>>>> and other contact details. >>>>>>>> >>>>>>> >>>> >>> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>>>>>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>>>>>> ---- stack trace >>>>>>>> --------------------------------------------------------------- >>>>>>>> java.lang.Exception: Error in simple-method [Create/Update Customer, >>>>>>>> Shipping Address and other contact details. >>>>>>>> >>>>>>> >>>> >>> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>>>>>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>>>>>> >>>>>>> >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) >>>>>>>> >>>>>>> >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) >>>>>>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) >>>>>>>> >>> org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) >>>>>>>> >>>> org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) >>>>>>>> >>>>>>> >>>> >>> org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) >>>>>>>> >>>>>>> >>>> >>> org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) >>>>>>>> >>>>>>> >>>> >>> org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) >>>>>>>> >>>>>>> >>>> >>> _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) >>>>>>>> >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) >>>>>>>> >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>>>>>>> >>>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>>>>>>> >>>>>>> >>>> >>> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>>>>>>> >>>>>>> >>>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>>>>>>> >>>>>>> >>>> >>> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>>>>>>> >>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>>>>>>> >>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>>>>>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>>>>>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>>>>>> >>>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>>>>>>> >>>>>>> >>>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>>>>>>> >>>>>>> >>>> >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>>>>>>> >>>>>>> >>>> >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>>>>>>> >>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>>>>>>> java.lang.Thread.run(Thread.java:619) >>>>>>>> >>>>>>> >>>> >>> -------------------------------------------------------------------------------- >>>>>>>> >>>>>>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>>>>>> ServiceDispatcher.java:543:ERROR] Error in Service >>>>>>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, Falta >>>>>>>> Teléfono de Contacto >>>>>>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>>>>>> TransactionUtil.java:338:ERROR] >>>>>>>> ---- exception report >>>>>>>> ---------------------------------------------------------- >>>>>>>> [TransactionUtil.rollback] >>>>>>>> Exception: java.lang.Exception >>>>>>>> Message: Stack Trace >>>>>>>> ---- stack trace >>>>>>>> --------------------------------------------------------------- >>>>>>>> java.lang.Exception: Stack Trace >>>>>>>> >>>>>>> >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) >>>>>>>> >>>>>>> >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) >>>>>>>> >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) >>>>>>>> >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>>>>>>> >>>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>>>>>>> >>>>>>> >>>> >>> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>>>>>>> >>>>>>> >>>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>>>>>>> >>>>>>> >>>> >>> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>>>>>>> >>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>>>>>>> >>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>>>>>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>>>>>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>>>>>> >>>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>>>>>>> >>>>>>> >>>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>>>>>>> >>>>>>> >>>> >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>>>>>>> >>>>>>> >>>> >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>>>>>>> >>>>>>> >>>> >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>>>>>>> >>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>>>>>>> java.lang.Thread.run(Thread.java:619) >>>>>>>> >>>>>>> >>>> >>> -------------------------------------------------------------------------------- >>>>>>>> >>>>>>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ >>>>>>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] transaction >>>>>>>> rolled back >>>>>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>>>>> ServiceDispatcher.java:599:INFO ] Sync service >>>>>>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] >>>>>>>> milliseconds with response [{errorMessageList={Area code is missing, Falta >>>>>>>> Teléfono de Contacto}, responseMessage=error}] >>>>>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>>>>> RequestHandler.java:639:INFO ] Ran Event >>>>>>>> [service:#createUpdateCustomerAndShippingAddress] from [request], result is >>>>>>>> [error] >>>>>>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ >>>>>>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress caused an >>>>>>>> error with the following message: {Area code is missing, Falta Teléfono de >>>>>>>> Contacto} >>>>>>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>>>>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response is a >>>>>>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>>>>>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>>>>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: >>>>>>>> requestUri=json overrideViewUri=null >>>>>>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>>>>>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>>>>>>> RequestHandler.java:639:INFO ] Ran Event >>>>>>>> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] from >>>>>>>> [request], result is [success] >>>>>>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ >>>>>>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, ServerHitBin >>>>>>>> delegatorName=default#JF >>>>>>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ >>>>>>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for [ServerHitBin]; >>>>>>>> curSeqId=53390, maxSeqId=53400, bankSize=10 >>>>>>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ >>>>>>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] Request Done- >>>>>>>> total:0.386,since last([createUpdateShip...):0.386]] >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>> >>> ----------------------------------------------------------------------------------------------- >>>>>>>> >>>>>>>> After a bit of investigation I found this: >>>>>>>> >>>>>>>> The event 'createUpdateCustomerAndShippingAddress' is returning an error as >>>>>>>> a result but since the request is chained (with a json request) the >>>>>>>> controller takes the response from the event >>>>>>>> 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' which >>>>>>>> is always 'success'. So that's why I figure out the ajax error handler is >>>>>>>> never invoked. >>>>>>>> >>>>>>>> What do you think? >>>>>>>> >>>>>>>> For further details, I am using a 3 months old trunk version with MySql. >>>>>>>> I've checked out the latest version >>>>>>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still the same >>>>>>>> code as I have. >>>>>>>> >>>>>>>> Thanks in advance. >>>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> ----- >>>>>> >>>>>> Jonatan Soto >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> ----- >>>>> >>>>> Jonatan Soto >>>> >>>> >>> >>> >>> -- >>> ----- >>> >>> Jonatan Soto |
In reply to this post by Jacques Le Roux
Hi Jacques,
You're right I didn't specified what is not tested. What I meant is that I tested a few JS methods where I've applied the changes. Other methods aren't tested because I am not using them and didn't have time to see where they are used. Note that I've changed only the JS functions where ajax calls are invoked and I implemented the same logic for all of them, so they should work :) Here is the list of these methods I haven't tested for sure: - getProductLineItemIndex - addPromoCode On Sun, Aug 28, 2011 at 10:49 AM, Jacques Le Roux < [hidden email]> wrote: > Hi Jonatan, > > Your patch looks good at 1st glance, but you say below "not fully tested" > what do you mean by that? Do we need to test something which could be > specifically missing or has not been tested, or is it just a point in the > dark? > > Thanks > > Jacques > > > Jonatan Soto wrote: > >> Hi Atul, >> >> I've didn't got server error messages using what you said. Probably is >> something wrong in my code, but what I have noticed is that no matters >> what >> kind of response I set, the 'success' callback method is called. >> Anyway, how is handled the server response in this case? I mean, where can >> I >> find the code where the getServerError() JS function is called once we >> return the error response? >> >> Many thanks Atul. >> >> On Fri, Aug 26, 2011 at 7:32 PM, Atul Vani <[hidden email]>** >> wrote: >> >> Jonatan, >>> >>> I think if you use >>> <response name="error" type="request" value="json"/> >>> (it is used in several places in ecommerce and other components' >>> controller.xml) >>> >>> and then use the getServerError() function >>> (used in specialpurpose/ecommerce/**webapp/ecommerce/images/** >>> profile.js) >>> to parse the JSON response, >>> then you should be able to retrieve the error message to display it to >>> the >>> user. >>> >>> I'm not sure if it will be helpful, I didn't got the problem completely >>> either ;-) >>> >>> >>> ----- Original Message ----- >>> From: "Jonatan Soto" <[hidden email]> >>> To: [hidden email] >>> Sent: Sunday, July 17, 2011 5:56:10 PM >>> Subject: Re: Issue with ajax and json response >>> >>> Done. Patch provided, not fully tested. >>> https://issues.apache.org/**jira/browse/OFBIZ-4342<https://issues.apache.org/jira/browse/OFBIZ-4342> >>> >>> <https://issues.apache.org/**jira/browse/OFBIZ-4342<https://issues.apache.org/jira/browse/OFBIZ-4342> >>> >**Regards, >>> >>> >>> On Sun, Jul 17, 2011 at 1:34 PM, Scott Gray <[hidden email] >>> >>>> wrote: >>>> >>> >>> Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, >>>> would >>>> be great if you could create a jira issue so this doesn't get lost. >>>> >>>> Regards >>>> Scott >>>> >>>> HotWax Media >>>> http://www.hotwaxmedia.com >>>> >>>> On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: >>>> >>>> Well, I did a little read on the jquery ajax documentation ( >>>>> http://api.jquery.com/jQuery.**ajax/<http://api.jquery.com/jQuery.ajax/>) >>>>> and some of my assertions were wrong. >>>>> It is definitively not related to >>>>> the CommonEvents#**jsonResponseFromRequestAttribu**tes. I felt stupid >>>>> when I >>>>> realized that the result the controller returns has nothing to do with >>>>> the >>>>> ajax callbacks :) >>>>> >>>>> According to this doc the error callback is: >>>>> "A function to be called if the request fails...." >>>>> >>>>> In the case I'm exposing, obviously the request is not failing so the >>>>> error >>>>> I'm getting should be handled in the success callback. Please, tell me >>>>> if >>>>> there is another way to do it. >>>>> I found a js function in the CheckoutProcess.js called >>>>> getServerError(...) >>>>> which is never invoked. I think it should be included in the success >>>>> callback like the following code: >>>>> >>>>> (chekoutProcess.js) >>>>> >>>>> // Check server side error >>>>> function getServerError(data) { >>>>> var serverErrorHash = []; >>>>> var serverError = ""; >>>>> if (data._ERROR_MESSAGE_LIST_ != undefined) { >>>>> serverErrorHash = data._ERROR_MESSAGE_LIST_; >>>>> jQuery.each(serverErrorHash, function(i, error) { >>>>> serverError += error.message + '<br/>'; >>>>> }); >>>>> } >>>>> if (data._ERROR_MESSAGE_ != undefined) { >>>>> serverError = data._ERROR_MESSAGE_; >>>>> } >>>>> return serverError; >>>>> } >>>>> >>>>> function createUpdateCustomerAndShippin**gAddress() { >>>>> var result = false; >>>>> jQuery.ajax({ >>>>> url: 'createUpdateShippingAddress', >>>>> type: 'POST', >>>>> dataType: 'json', >>>>> async: false, >>>>> data: jQuery('#shippingForm').**serialize(), >>>>> success: function(json) { >>>>> var serverError = getServerError(json); >>>>> if (!serverError) { >>>>> jQuery('#**shippingFormServerError').**fadeOut('fast'); >>>>> // Process Shipping data response. >>>>> jQuery('#shipToPartyId').val(**json.partyId); >>>>> jQuery('#billToPartyId').val(**json.partyId); >>>>> jQuery('#shipToContactMechId')**.val(json.contactMechId); >>>>> >>>>> jQuery('#**shipToPhoneContactMechId').**val(json.phoneContactMechId); >>>>> jQuery('#emailContactMechId').** >>>>> val(json.emailContactMechId); >>>>> >>>>> //jQuery('#**completedShippingMethod').** >>>>> html(json.shippingDescription)**; >>>>> updateShippingSummary(); >>>>> getShipOptions(); >>>>> result = true; >>>>> } else { >>>>> jQuery('#**shippingFormServerError').** >>>>> html(serverError); >>>>> >>>>> jQuery('#**shippingFormServerError').css(**"display","block"); >>> >>>> result = false; >>>>> } >>>>> }, >>>>> error: function(error) { >>>>> if (error != "") { >>>>> jQuery('#**shippingFormServerError').**html(error); >>>>> } >>>>> result = false; >>>>> } >>>>> }); >>>>> return result; >>>>> } >>>>> >>>>> Now with this modifications I am showing the server side error messages >>>>> correctly. >>>>> >>>>> >>>>> HTH >>>>> >>>>> >>>>> On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto < >>>>> [hidden email] >>>>> wrote: >>>>> >>>>> Hi BJ, >>>>>> >>>>>> The setAnonuserLogin is an ECA triggered before. The problem is after >>>>>> it if >>>>>> I'm not wrong. >>>>>> >>>>>> Look at: >>>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>>> ServiceDispatcher.java:599:**INFO ] Sync service >>>>>> [traditional#JF/**createUpdateCustomerAndShippin**gAddress] finished >>>>>> in [112] >>>>>> milliseconds with response [{errorMessageList={Area code is missing, >>>>>> Falta >>>>>> Teléfono de Contacto}, responseMessage=error}] >>>>>> ... >>>>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>>>>> RequestHandler.java:639:INFO ] Ran Event >>>>>> [java:org.ofbiz.common.**CommonEvents#** >>>>>> jsonResponseFromRequestAttribu**tes] from >>>>>> [request], result is [success] >>>>>> >>>>>> The service that is called from ajax is returning 'error' but the >>>>>> chained >>>>>> json request is returning 'success'. I guess this is the problem. >>>>>> >>>>>> Thanks anyway! >>>>>> >>>>>> >>>>>> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> >>>>>> wrote: >>>>>> >>>>>> [traditional#JF/**setAnonUserLogin] finished in [105] milliseconds >>>>>>> with >>>>>>> response [{responseMessage=success}] >>>>>>> >>>>>>> it is evaluating a good lognin. this is where to debug. >>>>>>> >>>>>>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: >>>>>>> >>>>>>>> Hi all, >>>>>>>> >>>>>>>> I am customizing the onePageCheckout (the anonymous part) and I >>>>>>>> found >>>>>>>> something strange. I've changed the client-side validation in order >>>>>>>> to allow >>>>>>>> the customer to only introduce the phone, cell phone or both. But on >>>>>>>> server-side I didn't change anything in the >>>>>>>> PartyContactMechMapProcs.xml >>>>>>>> yet. So, it is throwing an error of course, but the ajax handler >>>>>>>> does not >>>>>>>> consider it as an error. It always executes the success ajax >>>>>>>> handler! >>>>>>>> >>>>>>>> This is the stack trace: >>>>>>>> >>>>>>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ >>>>>>>> ControlServlet.java:141:INFO ] [[[**createUpdateShippingAddress] >>>>>>>> Request >>>>>>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] >>>>>>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ >>>>>>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 >>>>>>>> requests, >>>>>>>> 96 views in jndi:/0.0.0.0/ecomm/**traditional/WEB-INF/** >>>>>>>> controller.xml<http://0.0.0.0/ecomm/traditional/WEB-INF/controller.xml> >>>>>>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ >>>>>>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: >>>>>>>> setAnonUserLogin, triggered by rule on Service: >>>>>>>> createUpdateCustomerAndShippin**gAddress >>>>>>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ >>>>>>>> ServiceDispatcher.java:599:**INFO ] Sync service >>>>>>>> [traditional#JF/**setAnonUserLogin] finished in [105] milliseconds >>>>>>>> with >>>>>>>> response [{responseMessage=success}] >>>>>>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ >>>>>>>> TransactionUtil.java:374:WARN ] >>>>>>>> ---- exception report >>>>>>>> ------------------------------**---------------------------- >>>>>>>> [TransactionUtil.**setRollbackOnly] Calling transaction >>>>>>>> setRollbackOnly; this >>>>>>>> stack trace shows where this is happening: >>>>>>>> Exception: java.lang.Exception >>>>>>>> Message: Error in simple-method [Create/Update Customer, Shipping >>>>>>>> Address >>>>>>>> and other contact details. >>>>>>>> >>>>>>>> >>>>>>> >>>> [file:/home/jsoto/workspace/**ofbizcustom/applications/** >>> order/script/org/ofbiz/order/**order/CheckoutServices.xml#** >>> createUpdateCustomerAndShippin**gAddress]]: >>> >>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>>>>>> ---- stack trace >>>>>>>> ------------------------------**------------------------------**--- >>>>>>>> java.lang.Exception: Error in simple-method [Create/Update Customer, >>>>>>>> Shipping Address and other contact details. >>>>>>>> >>>>>>>> >>>>>>> >>>> [file:/home/jsoto/workspace/**ofbizcustom/applications/** >>> order/script/org/ofbiz/order/**order/CheckoutServices.xml#** >>> createUpdateCustomerAndShippin**gAddress]]: >>> >>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>>>>>> >>>>>>>> >>>>>>> >>>> org.ofbiz.entity.transaction.**TransactionUtil.**setRollbackOnly(** >>> TransactionUtil.java:374) >>> >>>> >>>>>>>> >>>>>>> >>>> org.ofbiz.entity.transaction.**TransactionUtil.rollback(** >>> TransactionUtil.java:316) >>> >>>> org.ofbiz.minilang.**SimpleMethod.exec(**SimpleMethod.java:870) >>>>>>>> >>>>>>>> org.ofbiz.minilang.**SimpleMethod.runSimpleMethod(** >>> SimpleMethod.java:160) >>> >>>> >>>>>>>> org.ofbiz.minilang.**SimpleMethod.runSimpleService(** >>>> SimpleMethod.java:142) >>>> >>>>> >>>>>>>> >>>>>>> >>>> org.ofbiz.minilang.**SimpleServiceEngine.**serviceInvoker(** >>> SimpleServiceEngine.java:78) >>> >>>> >>>>>>>> >>>>>>> >>>> org.ofbiz.minilang.**SimpleServiceEngine.runSync(** >>> SimpleServiceEngine.java:53) >>> >>>> >>>>>>>> >>>>>>> >>>> org.ofbiz.service.**ModelServiceReader$**GenericInvokerImpl.runSync(** >>> ModelServiceReader.java:761) >>> >>>> >>>>>>>> >>>>>>> >>>> _$gen.file_58$.home.jsoto.**workspace.ofbizcustom.** >>> applications.order.servicedef.**services_95$checkout_46$xml_**35$** >>> createUpdateCustomerAndShippin**gAddress.runSync(file:/home/** >>> jsoto/workspace/ofbizcustom/**applications/order/servicedef/** >>> services_checkout.xml#**createUpdateCustomerAndShippin**gAddress:24) >>> >>>> >>>>>>>> org.ofbiz.service.**ServiceDispatcher.runSync(** >>>> ServiceDispatcher.java:399) >>>> >>>>> >>>>>>>> org.ofbiz.service.**ServiceDispatcher.runSync(** >>>> ServiceDispatcher.java:226) >>>> >>>>> >>>>>>>> org.ofbiz.service.**GenericDispatcher.runSync(** >>>> GenericDispatcher.java:165) >>>> >>>>> >>>>>>>> >>>>>>> >>>> org.ofbiz.webapp.event.**ServiceEventHandler.invoke(** >>> ServiceEventHandler.java:336) >>> >>>> >>>>>>>> >>>>>>> org.ofbiz.webapp.control.**RequestHandler.runEvent(** >>>> RequestHandler.java:638) >>>> >>>>> >>>>>>>> >>>>>>> >>>> org.ofbiz.webapp.control.**RequestHandler.doRequest(** >>> RequestHandler.java:384) >>> >>>> >>>>>>>> org.ofbiz.webapp.control.**ControlServlet.doGet(** >>> ControlServlet.java:224) >>> >>>> >>>>>>>> org.ofbiz.webapp.control.**ControlServlet.doPost(** >>> ControlServlet.java:87) >>> >>>> javax.servlet.http.**HttpServlet.service(**HttpServlet.java:637) >>>>>>>> javax.servlet.http.**HttpServlet.service(**HttpServlet.java:717) >>>>>>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**ApplicationFilterChain.**internalDoFilter(* >>> *ApplicationFilterChain.java:**290) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**ApplicationFilterChain.**doFilter(** >>> ApplicationFilterChain.java:**206) >>> >>>> >>>>>>>> org.ofbiz.webapp.control.**ContextFilter.doFilter(** >>>> ContextFilter.java:338) >>>> >>>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**ApplicationFilterChain.**internalDoFilter(* >>> *ApplicationFilterChain.java:**235) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**ApplicationFilterChain.**doFilter(** >>> ApplicationFilterChain.java:**206) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**StandardWrapperValve.invoke(** >>> StandardWrapperValve.java:233) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**StandardContextValve.invoke(** >>> StandardContextValve.java:191) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**StandardHostValve.invoke(** >>> StandardHostValve.java:127) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.valves.**ErrorReportValve.invoke(** >>> ErrorReportValve.java:102) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**StandardEngineValve.invoke(** >>> StandardEngineValve.java:109) >>> >>>> >>>>>>>> >>>>>>> org.apache.catalina.valves.**AccessLogValve.invoke(** >>>> AccessLogValve.java:554) >>>> >>>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.connector.**CoyoteAdapter.service(** >>> CoyoteAdapter.java:298) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.coyote.http11.**Http11Processor.process(** >>> Http11Processor.java:859) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.coyote.http11.**Http11Protocol$**Http11ConnectionHandler.** >>> process(Http11Protocol.java:**588) >>> >>>> >>>>>>>> org.apache.tomcat.util.net.**JIoEndpoint$Worker.run(** >>>> JIoEndpoint.java:489) >>>> >>>>> java.lang.Thread.run(Thread.**java:619) >>>>>>>> >>>>>>>> >>>>>>> >>>> ------------------------------**------------------------------** >>> -------------------- >>> >>>> >>>>>>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>>>>>> ServiceDispatcher.java:543:**ERROR] Error in Service >>>>>>>> [**createUpdateCustomerAndShippin**gAddress]: Area code is missing, >>>>>>>> Falta >>>>>>>> Teléfono de Contacto >>>>>>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>>>>>> TransactionUtil.java:338:**ERROR] >>>>>>>> ---- exception report >>>>>>>> ------------------------------**---------------------------- >>>>>>>> [TransactionUtil.rollback] >>>>>>>> Exception: java.lang.Exception >>>>>>>> Message: Stack Trace >>>>>>>> ---- stack trace >>>>>>>> ------------------------------**------------------------------**--- >>>>>>>> java.lang.Exception: Stack Trace >>>>>>>> >>>>>>>> >>>>>>> >>>> org.ofbiz.entity.transaction.**TransactionUtil.rollback(** >>> TransactionUtil.java:337) >>> >>>> >>>>>>>> >>>>>>> >>>> org.ofbiz.entity.transaction.**TransactionUtil.rollback(** >>> TransactionUtil.java:314) >>> >>>> >>>>>>>> org.ofbiz.service.**ServiceDispatcher.runSync(** >>>> ServiceDispatcher.java:547) >>>> >>>>> >>>>>>>> org.ofbiz.service.**ServiceDispatcher.runSync(** >>>> ServiceDispatcher.java:226) >>>> >>>>> >>>>>>>> org.ofbiz.service.**GenericDispatcher.runSync(** >>>> GenericDispatcher.java:165) >>>> >>>>> >>>>>>>> >>>>>>> >>>> org.ofbiz.webapp.event.**ServiceEventHandler.invoke(** >>> ServiceEventHandler.java:336) >>> >>>> >>>>>>>> >>>>>>> org.ofbiz.webapp.control.**RequestHandler.runEvent(** >>>> RequestHandler.java:638) >>>> >>>>> >>>>>>>> >>>>>>> >>>> org.ofbiz.webapp.control.**RequestHandler.doRequest(** >>> RequestHandler.java:384) >>> >>>> >>>>>>>> org.ofbiz.webapp.control.**ControlServlet.doGet(** >>> ControlServlet.java:224) >>> >>>> >>>>>>>> org.ofbiz.webapp.control.**ControlServlet.doPost(** >>> ControlServlet.java:87) >>> >>>> javax.servlet.http.**HttpServlet.service(**HttpServlet.java:637) >>>>>>>> javax.servlet.http.**HttpServlet.service(**HttpServlet.java:717) >>>>>>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**ApplicationFilterChain.**internalDoFilter(* >>> *ApplicationFilterChain.java:**290) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**ApplicationFilterChain.**doFilter(** >>> ApplicationFilterChain.java:**206) >>> >>>> >>>>>>>> org.ofbiz.webapp.control.**ContextFilter.doFilter(** >>>> ContextFilter.java:338) >>>> >>>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**ApplicationFilterChain.**internalDoFilter(* >>> *ApplicationFilterChain.java:**235) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**ApplicationFilterChain.**doFilter(** >>> ApplicationFilterChain.java:**206) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**StandardWrapperValve.invoke(** >>> StandardWrapperValve.java:233) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**StandardContextValve.invoke(** >>> StandardContextValve.java:191) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**StandardHostValve.invoke(** >>> StandardHostValve.java:127) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.valves.**ErrorReportValve.invoke(** >>> ErrorReportValve.java:102) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.core.**StandardEngineValve.invoke(** >>> StandardEngineValve.java:109) >>> >>>> >>>>>>>> >>>>>>> org.apache.catalina.valves.**AccessLogValve.invoke(** >>>> AccessLogValve.java:554) >>>> >>>>> >>>>>>>> >>>>>>> >>>> org.apache.catalina.connector.**CoyoteAdapter.service(** >>> CoyoteAdapter.java:298) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.coyote.http11.**Http11Processor.process(** >>> Http11Processor.java:859) >>> >>>> >>>>>>>> >>>>>>> >>>> org.apache.coyote.http11.**Http11Protocol$**Http11ConnectionHandler.** >>> process(Http11Protocol.java:**588) >>> >>>> >>>>>>>> org.apache.tomcat.util.net.**JIoEndpoint$Worker.run(** >>>> JIoEndpoint.java:489) >>>> >>>>> java.lang.Thread.run(Thread.**java:619) >>>>>>>> >>>>>>>> >>>>>>> >>>> ------------------------------**------------------------------** >>> -------------------- >>> >>>> >>>>>>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ >>>>>>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] >>>>>>>> transaction >>>>>>>> rolled back >>>>>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>>>>> ServiceDispatcher.java:599:**INFO ] Sync service >>>>>>>> [traditional#JF/**createUpdateCustomerAndShippin**gAddress] >>>>>>>> finished in [112] >>>>>>>> milliseconds with response [{errorMessageList={Area code is missing, >>>>>>>> Falta >>>>>>>> Teléfono de Contacto}, responseMessage=error}] >>>>>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>>>>> RequestHandler.java:639:INFO ] Ran Event >>>>>>>> [service:#**createUpdateCustomerAndShippin**gAddress] from >>>>>>>> [request], result is >>>>>>>> [error] >>>>>>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ >>>>>>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress >>>>>>>> caused an >>>>>>>> error with the following message: {Area code is missing, Falta >>>>>>>> Teléfono de >>>>>>>> Contacto} >>>>>>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>>>>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response >>>>>>>> is a >>>>>>>> chained request. sessionId=**4D2FA44B2DA6BCB7E2D9BE245F808E** >>>>>>>> 22.jvm1 >>>>>>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>>>>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: >>>>>>>> requestUri=json overrideViewUri=null >>>>>>>> sessionId=**4D2FA44B2DA6BCB7E2D9BE245F808E**22.jvm1 >>>>>>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>>>>>>> RequestHandler.java:639:INFO ] Ran Event >>>>>>>> [java:org.ofbiz.common.**CommonEvents#** >>>>>>>> jsonResponseFromRequestAttribu**tes] from >>>>>>>> [request], result is [success] >>>>>>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ >>>>>>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, >>>>>>>> ServerHitBin >>>>>>>> delegatorName=default#JF >>>>>>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ >>>>>>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for >>>>>>>> [ServerHitBin]; >>>>>>>> curSeqId=53390, maxSeqId=53400, bankSize=10 >>>>>>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ >>>>>>>> ControlServlet.java:324:INFO ] [[[**createUpdateShippingAddress] >>>>>>>> Request Done- >>>>>>>> total:0.386,since last([createUpdateShip...):0.**386]] >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>> ------------------------------**------------------------------** >>> ------------------------------**----- >>> >>>> >>>>>>>> After a bit of investigation I found this: >>>>>>>> >>>>>>>> The event '**createUpdateCustomerAndShippin**gAddress' is returning >>>>>>>> an error as >>>>>>>> a result but since the request is chained (with a json request) the >>>>>>>> controller takes the response from the event >>>>>>>> 'java:org.ofbiz.common.**CommonEvents#** >>>>>>>> jsonResponseFromRequestAttribu**tes' which >>>>>>>> is always 'success'. So that's why I figure out the ajax error >>>>>>>> handler is >>>>>>>> never invoked. >>>>>>>> >>>>>>>> What do you think? >>>>>>>> >>>>>>>> For further details, I am using a 3 months old trunk version with >>>>>>>> MySql. >>>>>>>> I've checked out the latest version >>>>>>>> of CommonEvents#**jsonResponseFromRequestAttribu**tes in the SVN, >>>>>>>> still the same >>>>>>>> code as I have. >>>>>>>> >>>>>>>> Thanks in advance. >>>>>>>> >>>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> ----- >>>>>> >>>>>> Jonatan Soto >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> ----- >>>>> >>>>> Jonatan Soto >>>>> >>>> >>>> >>>> >>> >>> -- >>> ----- >>> >>> Jonatan Soto >>> >> -- ----- Jonatan Soto |
In reply to this post by Jacques Le Roux
sorry about that. I should change the eclipse formatter rules to meet Ofbiz
format specs. I did it for another workspace but not for the current one I'm using. Well, I will provide a new patch correcting this ASAP. On Sun, Aug 28, 2011 at 11:02 AM, Jacques Le Roux < [hidden email]> wrote: > Also I think there are some tabs in your patch (I can see them because > your file is automatically rendered in browsers) > I see some > jQuery('#**shippingFormServerError').**html(serverError); > lines wrongly formatted > > Jacques > > > Jacques Le Roux wrote: > >> Hi Jonatan, >> >> Your patch looks good at 1st glance, but you say below "not fully tested" >> what do you mean by that? Do we need to test something >> which could be specifically missing or has not been tested, or is it just >> a point in the dark? >> >> Thanks >> >> Jacques >> >> Jonatan Soto wrote: >> >>> Hi Atul, >>> >>> I've didn't got server error messages using what you said. Probably is >>> something wrong in my code, but what I have noticed is that no matters >>> what >>> kind of response I set, the 'success' callback method is called. >>> Anyway, how is handled the server response in this case? I mean, where >>> can I >>> find the code where the getServerError() JS function is called once we >>> return the error response? >>> >>> Many thanks Atul. >>> >>> On Fri, Aug 26, 2011 at 7:32 PM, Atul Vani <[hidden email]>** >>> wrote: >>> >>> Jonatan, >>>> >>>> I think if you use >>>> <response name="error" type="request" value="json"/> >>>> (it is used in several places in ecommerce and other components' >>>> controller.xml) >>>> >>>> and then use the getServerError() function >>>> (used in specialpurpose/ecommerce/**webapp/ecommerce/images/** >>>> profile.js) >>>> to parse the JSON response, >>>> then you should be able to retrieve the error message to display it to >>>> the >>>> user. >>>> >>>> I'm not sure if it will be helpful, I didn't got the problem completely >>>> either ;-) >>>> >>>> >>>> ----- Original Message ----- >>>> From: "Jonatan Soto" <[hidden email]> >>>> To: [hidden email] >>>> Sent: Sunday, July 17, 2011 5:56:10 PM >>>> Subject: Re: Issue with ajax and json response >>>> >>>> Done. Patch provided, not fully tested. >>>> https://issues.apache.org/**jira/browse/OFBIZ-4342<https://issues.apache.org/jira/browse/OFBIZ-4342> >>>> >>>> <https://issues.apache.org/**jira/browse/OFBIZ-4342<https://issues.apache.org/jira/browse/OFBIZ-4342> >>>> >**Regards, >>>> >>>> >>>> On Sun, Jul 17, 2011 at 1:34 PM, Scott Gray <[hidden email] >>>> >>>>> wrote: >>>>> >>>> >>>> Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, >>>>> would >>>>> be great if you could create a jira issue so this doesn't get lost. >>>>> >>>>> Regards >>>>> Scott >>>>> >>>>> HotWax Media >>>>> http://www.hotwaxmedia.com >>>>> >>>>> On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: >>>>> >>>>> Well, I did a little read on the jquery ajax documentation ( >>>>>> http://api.jquery.com/jQuery.**ajax/<http://api.jquery.com/jQuery.ajax/>) >>>>>> and some of my assertions were wrong. >>>>>> It is definitively not related to >>>>>> the CommonEvents#**jsonResponseFromRequestAttribu**tes. I felt stupid >>>>>> when I >>>>>> realized that the result the controller returns has nothing to do with >>>>>> the >>>>>> ajax callbacks :) >>>>>> >>>>>> According to this doc the error callback is: >>>>>> "A function to be called if the request fails...." >>>>>> >>>>>> In the case I'm exposing, obviously the request is not failing so the >>>>>> error >>>>>> I'm getting should be handled in the success callback. Please, tell me >>>>>> if >>>>>> there is another way to do it. >>>>>> I found a js function in the CheckoutProcess.js called >>>>>> getServerError(...) >>>>>> which is never invoked. I think it should be included in the success >>>>>> callback like the following code: >>>>>> >>>>>> (chekoutProcess.js) >>>>>> >>>>>> // Check server side error >>>>>> function getServerError(data) { >>>>>> var serverErrorHash = []; >>>>>> var serverError = ""; >>>>>> if (data._ERROR_MESSAGE_LIST_ != undefined) { >>>>>> serverErrorHash = data._ERROR_MESSAGE_LIST_; >>>>>> jQuery.each(serverErrorHash, function(i, error) { >>>>>> serverError += error.message + '<br/>'; >>>>>> }); >>>>>> } >>>>>> if (data._ERROR_MESSAGE_ != undefined) { >>>>>> serverError = data._ERROR_MESSAGE_; >>>>>> } >>>>>> return serverError; >>>>>> } >>>>>> >>>>>> function createUpdateCustomerAndShippin**gAddress() { >>>>>> var result = false; >>>>>> jQuery.ajax({ >>>>>> url: 'createUpdateShippingAddress', >>>>>> type: 'POST', >>>>>> dataType: 'json', >>>>>> async: false, >>>>>> data: jQuery('#shippingForm').**serialize(), >>>>>> success: function(json) { >>>>>> var serverError = getServerError(json); >>>>>> if (!serverError) { >>>>>> jQuery('#**shippingFormServerError').**fadeOut('fast'); >>>>>> // Process Shipping data response. >>>>>> jQuery('#shipToPartyId').val(**json.partyId); >>>>>> jQuery('#billToPartyId').val(**json.partyId); >>>>>> jQuery('#shipToContactMechId')**.val(json.contactMechId); >>>>>> >>>>>> jQuery('#**shipToPhoneContactMechId').**val(json.phoneContactMechId); >>>>>> jQuery('#emailContactMechId').** >>>>>> val(json.emailContactMechId); >>>>>> >>>>>> //jQuery('#**completedShippingMethod').** >>>>>> html(json.shippingDescription)**; >>>>>> updateShippingSummary(); >>>>>> getShipOptions(); >>>>>> result = true; >>>>>> } else { >>>>>> jQuery('#**shippingFormServerError').** >>>>>> html(serverError); >>>>>> >>>>>> jQuery('#**shippingFormServerError').css(**"display","block"); >>>> >>>>> result = false; >>>>>> } >>>>>> }, >>>>>> error: function(error) { >>>>>> if (error != "") { >>>>>> jQuery('#**shippingFormServerError').**html(error); >>>>>> } >>>>>> result = false; >>>>>> } >>>>>> }); >>>>>> return result; >>>>>> } >>>>>> >>>>>> Now with this modifications I am showing the server side error >>>>>> messages >>>>>> correctly. >>>>>> >>>>>> >>>>>> HTH >>>>>> >>>>>> >>>>>> On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto < >>>>>> [hidden email] >>>>>> wrote: >>>>>> >>>>>> Hi BJ, >>>>>>> >>>>>>> The setAnonuserLogin is an ECA triggered before. The problem is after >>>>>>> it if >>>>>>> I'm not wrong. >>>>>>> >>>>>>> Look at: >>>>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>>>> ServiceDispatcher.java:599:**INFO ] Sync service >>>>>>> [traditional#JF/**createUpdateCustomerAndShippin**gAddress] finished >>>>>>> in [112] >>>>>>> milliseconds with response [{errorMessageList={Area code is missing, >>>>>>> Falta >>>>>>> Teléfono de Contacto}, responseMessage=error}] >>>>>>> ... >>>>>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>>>>>> RequestHandler.java:639:INFO ] Ran Event >>>>>>> [java:org.ofbiz.common.**CommonEvents#** >>>>>>> jsonResponseFromRequestAttribu**tes] from >>>>>>> [request], result is [success] >>>>>>> >>>>>>> The service that is called from ajax is returning 'error' but the >>>>>>> chained >>>>>>> json request is returning 'success'. I guess this is the problem. >>>>>>> >>>>>>> Thanks anyway! >>>>>>> >>>>>>> >>>>>>> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> >>>>>>> wrote: >>>>>>> >>>>>>> [traditional#JF/**setAnonUserLogin] finished in [105] milliseconds >>>>>>>> with >>>>>>>> response [{responseMessage=success}] >>>>>>>> >>>>>>>> it is evaluating a good lognin. this is where to debug. >>>>>>>> >>>>>>>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: >>>>>>>> >>>>>>>>> Hi all, >>>>>>>>> >>>>>>>>> I am customizing the onePageCheckout (the anonymous part) and I >>>>>>>>> found >>>>>>>>> something strange. I've changed the client-side validation in order >>>>>>>>> to allow >>>>>>>>> the customer to only introduce the phone, cell phone or both. But >>>>>>>>> on >>>>>>>>> server-side I didn't change anything in the >>>>>>>>> PartyContactMechMapProcs.xml >>>>>>>>> yet. So, it is throwing an error of course, but the ajax handler >>>>>>>>> does not >>>>>>>>> consider it as an error. It always executes the success ajax >>>>>>>>> handler! >>>>>>>>> >>>>>>>>> This is the stack trace: >>>>>>>>> >>>>>>>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ >>>>>>>>> ControlServlet.java:141:INFO ] [[[**createUpdateShippingAddress] >>>>>>>>> Request >>>>>>>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] >>>>>>>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ >>>>>>>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 >>>>>>>>> requests, >>>>>>>>> 96 views in jndi:/0.0.0.0/ecomm/**traditional/WEB-INF/** >>>>>>>>> controller.xml<http://0.0.0.0/ecomm/traditional/WEB-INF/controller.xml> >>>>>>>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ >>>>>>>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: >>>>>>>>> setAnonUserLogin, triggered by rule on Service: >>>>>>>>> createUpdateCustomerAndShippin**gAddress >>>>>>>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ >>>>>>>>> ServiceDispatcher.java:599:**INFO ] Sync service >>>>>>>>> [traditional#JF/**setAnonUserLogin] finished in [105] milliseconds >>>>>>>>> with >>>>>>>>> response [{responseMessage=success}] >>>>>>>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ >>>>>>>>> TransactionUtil.java:374:WARN ] >>>>>>>>> ---- exception report >>>>>>>>> ------------------------------**---------------------------- >>>>>>>>> [TransactionUtil.**setRollbackOnly] Calling transaction >>>>>>>>> setRollbackOnly; this >>>>>>>>> stack trace shows where this is happening: >>>>>>>>> Exception: java.lang.Exception >>>>>>>>> Message: Error in simple-method [Create/Update Customer, Shipping >>>>>>>>> Address >>>>>>>>> and other contact details. >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>> [file:/home/jsoto/workspace/**ofbizcustom/applications/** >>>> order/script/org/ofbiz/order/**order/CheckoutServices.xml#** >>>> createUpdateCustomerAndShippin**gAddress]]: >>>> >>>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>>>>>>> ---- stack trace >>>>>>>>> ------------------------------**------------------------------** >>>>>>>>> --- >>>>>>>>> java.lang.Exception: Error in simple-method [Create/Update >>>>>>>>> Customer, >>>>>>>>> Shipping Address and other contact details. >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>> [file:/home/jsoto/workspace/**ofbizcustom/applications/** >>>> order/script/org/ofbiz/order/**order/CheckoutServices.xml#** >>>> createUpdateCustomerAndShippin**gAddress]]: >>>> >>>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>> org.ofbiz.entity.transaction.**TransactionUtil.**setRollbackOnly(** >>>> TransactionUtil.java:374) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.ofbiz.entity.transaction.**TransactionUtil.rollback(** >>>> TransactionUtil.java:316) >>>> >>>>> org.ofbiz.minilang.**SimpleMethod.exec(**SimpleMethod.java:870) >>>>>>>>> >>>>>>>>> org.ofbiz.minilang.**SimpleMethod.runSimpleMethod(** >>>> SimpleMethod.java:160) >>>> >>>>> >>>>>>>>> org.ofbiz.minilang.**SimpleMethod.runSimpleService(** >>>>> SimpleMethod.java:142) >>>>> >>>>>> >>>>>>>>> >>>>>>>> >>>>> org.ofbiz.minilang.**SimpleServiceEngine.**serviceInvoker(** >>>> SimpleServiceEngine.java:78) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.ofbiz.minilang.**SimpleServiceEngine.runSync(** >>>> SimpleServiceEngine.java:53) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.ofbiz.service.**ModelServiceReader$**GenericInvokerImpl.runSync(* >>>> *ModelServiceReader.java:761) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> _$gen.file_58$.home.jsoto.**workspace.ofbizcustom.** >>>> applications.order.servicedef.**services_95$checkout_46$xml_**35$** >>>> createUpdateCustomerAndShippin**gAddress.runSync(file:/home/** >>>> jsoto/workspace/ofbizcustom/**applications/order/servicedef/** >>>> services_checkout.xml#**createUpdateCustomerAndShippin**gAddress:24) >>>> >>>>> >>>>>>>>> org.ofbiz.service.**ServiceDispatcher.runSync(** >>>>> ServiceDispatcher.java:399) >>>>> >>>>>> >>>>>>>>> org.ofbiz.service.**ServiceDispatcher.runSync(** >>>>> ServiceDispatcher.java:226) >>>>> >>>>>> >>>>>>>>> org.ofbiz.service.**GenericDispatcher.runSync(** >>>>> GenericDispatcher.java:165) >>>>> >>>>>> >>>>>>>>> >>>>>>>> >>>>> org.ofbiz.webapp.event.**ServiceEventHandler.invoke(** >>>> ServiceEventHandler.java:336) >>>> >>>>> >>>>>>>>> >>>>>>>> org.ofbiz.webapp.control.**RequestHandler.runEvent(** >>>>> RequestHandler.java:638) >>>>> >>>>>> >>>>>>>>> >>>>>>>> >>>>> org.ofbiz.webapp.control.**RequestHandler.doRequest(** >>>> RequestHandler.java:384) >>>> >>>>> >>>>>>>>> org.ofbiz.webapp.control.**ControlServlet.doGet(** >>>> ControlServlet.java:224) >>>> >>>>> >>>>>>>>> org.ofbiz.webapp.control.**ControlServlet.doPost(** >>>> ControlServlet.java:87) >>>> >>>>> javax.servlet.http.**HttpServlet.service(**HttpServlet.java:637) >>>>>>>>> javax.servlet.http.**HttpServlet.service(**HttpServlet.java:717) >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**ApplicationFilterChain.**internalDoFilter( >>>> **ApplicationFilterChain.java:**290) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**ApplicationFilterChain.**doFilter(** >>>> ApplicationFilterChain.java:**206) >>>> >>>>> >>>>>>>>> org.ofbiz.webapp.control.**ContextFilter.doFilter(** >>>>> ContextFilter.java:338) >>>>> >>>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**ApplicationFilterChain.**internalDoFilter( >>>> **ApplicationFilterChain.java:**235) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**ApplicationFilterChain.**doFilter(** >>>> ApplicationFilterChain.java:**206) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**StandardWrapperValve.invoke(** >>>> StandardWrapperValve.java:233) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**StandardContextValve.invoke(** >>>> StandardContextValve.java:191) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**StandardHostValve.invoke(** >>>> StandardHostValve.java:127) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.valves.**ErrorReportValve.invoke(** >>>> ErrorReportValve.java:102) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**StandardEngineValve.invoke(** >>>> StandardEngineValve.java:109) >>>> >>>>> >>>>>>>>> >>>>>>>> org.apache.catalina.valves.**AccessLogValve.invoke(** >>>>> AccessLogValve.java:554) >>>>> >>>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.connector.**CoyoteAdapter.service(** >>>> CoyoteAdapter.java:298) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.coyote.http11.**Http11Processor.process(** >>>> Http11Processor.java:859) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.coyote.http11.**Http11Protocol$**Http11ConnectionHandler.* >>>> *process(Http11Protocol.java:**588) >>>> >>>>> >>>>>>>>> org.apache.tomcat.util.net.**JIoEndpoint$Worker.run(** >>>>> JIoEndpoint.java:489) >>>>> >>>>>> java.lang.Thread.run(Thread.**java:619) >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>> ------------------------------**------------------------------** >>>> -------------------- >>>> >>>>> >>>>>>>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>>>>>>> ServiceDispatcher.java:543:**ERROR] Error in Service >>>>>>>>> [**createUpdateCustomerAndShippin**gAddress]: Area code is >>>>>>>>> missing, Falta >>>>>>>>> Teléfono de Contacto >>>>>>>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>>>>>>> TransactionUtil.java:338:**ERROR] >>>>>>>>> ---- exception report >>>>>>>>> ------------------------------**---------------------------- >>>>>>>>> [TransactionUtil.rollback] >>>>>>>>> Exception: java.lang.Exception >>>>>>>>> Message: Stack Trace >>>>>>>>> ---- stack trace >>>>>>>>> ------------------------------**------------------------------** >>>>>>>>> --- >>>>>>>>> java.lang.Exception: Stack Trace >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>> org.ofbiz.entity.transaction.**TransactionUtil.rollback(** >>>> TransactionUtil.java:337) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.ofbiz.entity.transaction.**TransactionUtil.rollback(** >>>> TransactionUtil.java:314) >>>> >>>>> >>>>>>>>> org.ofbiz.service.**ServiceDispatcher.runSync(** >>>>> ServiceDispatcher.java:547) >>>>> >>>>>> >>>>>>>>> org.ofbiz.service.**ServiceDispatcher.runSync(** >>>>> ServiceDispatcher.java:226) >>>>> >>>>>> >>>>>>>>> org.ofbiz.service.**GenericDispatcher.runSync(** >>>>> GenericDispatcher.java:165) >>>>> >>>>>> >>>>>>>>> >>>>>>>> >>>>> org.ofbiz.webapp.event.**ServiceEventHandler.invoke(** >>>> ServiceEventHandler.java:336) >>>> >>>>> >>>>>>>>> >>>>>>>> org.ofbiz.webapp.control.**RequestHandler.runEvent(** >>>>> RequestHandler.java:638) >>>>> >>>>>> >>>>>>>>> >>>>>>>> >>>>> org.ofbiz.webapp.control.**RequestHandler.doRequest(** >>>> RequestHandler.java:384) >>>> >>>>> >>>>>>>>> org.ofbiz.webapp.control.**ControlServlet.doGet(** >>>> ControlServlet.java:224) >>>> >>>>> >>>>>>>>> org.ofbiz.webapp.control.**ControlServlet.doPost(** >>>> ControlServlet.java:87) >>>> >>>>> javax.servlet.http.**HttpServlet.service(**HttpServlet.java:637) >>>>>>>>> javax.servlet.http.**HttpServlet.service(**HttpServlet.java:717) >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**ApplicationFilterChain.**internalDoFilter( >>>> **ApplicationFilterChain.java:**290) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**ApplicationFilterChain.**doFilter(** >>>> ApplicationFilterChain.java:**206) >>>> >>>>> >>>>>>>>> org.ofbiz.webapp.control.**ContextFilter.doFilter(** >>>>> ContextFilter.java:338) >>>>> >>>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**ApplicationFilterChain.**internalDoFilter( >>>> **ApplicationFilterChain.java:**235) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**ApplicationFilterChain.**doFilter(** >>>> ApplicationFilterChain.java:**206) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**StandardWrapperValve.invoke(** >>>> StandardWrapperValve.java:233) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**StandardContextValve.invoke(** >>>> StandardContextValve.java:191) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**StandardHostValve.invoke(** >>>> StandardHostValve.java:127) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.valves.**ErrorReportValve.invoke(** >>>> ErrorReportValve.java:102) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.core.**StandardEngineValve.invoke(** >>>> StandardEngineValve.java:109) >>>> >>>>> >>>>>>>>> >>>>>>>> org.apache.catalina.valves.**AccessLogValve.invoke(** >>>>> AccessLogValve.java:554) >>>>> >>>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.catalina.connector.**CoyoteAdapter.service(** >>>> CoyoteAdapter.java:298) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.coyote.http11.**Http11Processor.process(** >>>> Http11Processor.java:859) >>>> >>>>> >>>>>>>>> >>>>>>>> >>>>> org.apache.coyote.http11.**Http11Protocol$**Http11ConnectionHandler.* >>>> *process(Http11Protocol.java:**588) >>>> >>>>> >>>>>>>>> org.apache.tomcat.util.net.**JIoEndpoint$Worker.run(** >>>>> JIoEndpoint.java:489) >>>>> >>>>>> java.lang.Thread.run(Thread.**java:619) >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>> ------------------------------**------------------------------** >>>> -------------------- >>>> >>>>> >>>>>>>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ >>>>>>>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] >>>>>>>>> transaction >>>>>>>>> rolled back >>>>>>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>>>>>> ServiceDispatcher.java:599:**INFO ] Sync service >>>>>>>>> [traditional#JF/**createUpdateCustomerAndShippin**gAddress] >>>>>>>>> finished in [112] >>>>>>>>> milliseconds with response [{errorMessageList={Area code is >>>>>>>>> missing, Falta >>>>>>>>> Teléfono de Contacto}, responseMessage=error}] >>>>>>>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>>>>>>> RequestHandler.java:639:INFO ] Ran Event >>>>>>>>> [service:#**createUpdateCustomerAndShippin**gAddress] from >>>>>>>>> [request], result is >>>>>>>>> [error] >>>>>>>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ >>>>>>>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress >>>>>>>>> caused an >>>>>>>>> error with the following message: {Area code is missing, Falta >>>>>>>>> Teléfono de >>>>>>>>> Contacto} >>>>>>>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>>>>>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response >>>>>>>>> is a >>>>>>>>> chained request. sessionId=**4D2FA44B2DA6BCB7E2D9BE245F808E** >>>>>>>>> 22.jvm1 >>>>>>>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>>>>>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: >>>>>>>>> requestUri=json overrideViewUri=null >>>>>>>>> sessionId=**4D2FA44B2DA6BCB7E2D9BE245F808E**22.jvm1 >>>>>>>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>>>>>>>> RequestHandler.java:639:INFO ] Ran Event >>>>>>>>> [java:org.ofbiz.common.**CommonEvents#** >>>>>>>>> jsonResponseFromRequestAttribu**tes] from >>>>>>>>> [request], result is [success] >>>>>>>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ >>>>>>>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, >>>>>>>>> ServerHitBin >>>>>>>>> delegatorName=default#JF >>>>>>>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ >>>>>>>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for >>>>>>>>> [ServerHitBin]; >>>>>>>>> curSeqId=53390, maxSeqId=53400, bankSize=10 >>>>>>>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ >>>>>>>>> ControlServlet.java:324:INFO ] [[[**createUpdateShippingAddress] >>>>>>>>> Request Done- >>>>>>>>> total:0.386,since last([createUpdateShip...):0.**386]] >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>> ------------------------------**------------------------------** >>>> ------------------------------**----- >>>> >>>>> >>>>>>>>> After a bit of investigation I found this: >>>>>>>>> >>>>>>>>> The event '**createUpdateCustomerAndShippin**gAddress' is >>>>>>>>> returning an error as >>>>>>>>> a result but since the request is chained (with a json request) the >>>>>>>>> controller takes the response from the event >>>>>>>>> 'java:org.ofbiz.common.**CommonEvents#** >>>>>>>>> jsonResponseFromRequestAttribu**tes' which >>>>>>>>> is always 'success'. So that's why I figure out the ajax error >>>>>>>>> handler is >>>>>>>>> never invoked. >>>>>>>>> >>>>>>>>> What do you think? >>>>>>>>> >>>>>>>>> For further details, I am using a 3 months old trunk version with >>>>>>>>> MySql. >>>>>>>>> I've checked out the latest version >>>>>>>>> of CommonEvents#**jsonResponseFromRequestAttribu**tes in the SVN, >>>>>>>>> still the same >>>>>>>>> code as I have. >>>>>>>>> >>>>>>>>> Thanks in advance. >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> ----- >>>>>>> >>>>>>> Jonatan Soto >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> ----- >>>>>> >>>>>> Jonatan Soto >>>>>> >>>>> >>>>> >>>>> >>>> >>>> -- >>>> ----- >>>> >>>> Jonatan Soto >>>> >>> -- ----- Jonatan Soto |
In reply to this post by jonatan soto
Jonatan,
IMO, the event you invoked in your request mapping should be fixed to return error response, when they get errors. It will cause the error response to be rendered instead of the success. Then you can use type="request" value="json" for the error response. The responseText recieved by the ajax will be a JSON String. You can then pass this JSON string to the getServerError() function to extract and return error message(s). I don't know if this information will be useful to you or not, as I haven't seen the code, but this is pretty much all one needs to check :) ----- Original Message ----- From: "Jonatan Soto" <[hidden email]> To: [hidden email] Sent: Saturday, August 27, 2011 3:51:58 PM Subject: Re: Issue with ajax and json response Hi Atul, I've didn't got server error messages using what you said. Probably is something wrong in my code, but what I have noticed is that no matters what kind of response I set, the 'success' callback method is called. Anyway, how is handled the server response in this case? I mean, where can I find the code where the getServerError() JS function is called once we return the error response? Many thanks Atul. On Fri, Aug 26, 2011 at 7:32 PM, Atul Vani <[hidden email]>wrote: > Jonatan, > > I think if you use > <response name="error" type="request" value="json"/> > (it is used in several places in ecommerce and other components' > controller.xml) > > and then use the getServerError() function > (used in specialpurpose/ecommerce/webapp/ecommerce/images/profile.js) > to parse the JSON response, > then you should be able to retrieve the error message to display it to the > user. > > I'm not sure if it will be helpful, I didn't got the problem completely > either ;-) > > > ----- Original Message ----- > From: "Jonatan Soto" <[hidden email]> > To: [hidden email] > Sent: Sunday, July 17, 2011 5:56:10 PM > Subject: Re: Issue with ajax and json response > > Done. Patch provided, not fully tested. > https://issues.apache.org/jira/browse/OFBIZ-4342 > > <https://issues.apache.org/jira/browse/OFBIZ-4342>Regards, > > > On Sun, Jul 17, 2011 at 1:34 PM, Scott Gray <[hidden email] > >wrote: > > > Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, would > > be great if you could create a jira issue so this doesn't get lost. > > > > Regards > > Scott > > > > HotWax Media > > http://www.hotwaxmedia.com > > > > On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: > > > > > Well, I did a little read on the jquery ajax documentation ( > > > http://api.jquery.com/jQuery.ajax/) and some of my assertions were > > wrong. > > > It is definitively not related to > > > the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when > I > > > realized that the result the controller returns has nothing to do with > > the > > > ajax callbacks :) > > > > > > According to this doc the error callback is: > > > "A function to be called if the request fails...." > > > > > > In the case I'm exposing, obviously the request is not failing so the > > error > > > I'm getting should be handled in the success callback. Please, tell me > if > > > there is another way to do it. > > > I found a js function in the CheckoutProcess.js called > > getServerError(...) > > > which is never invoked. I think it should be included in the success > > > callback like the following code: > > > > > > (chekoutProcess.js) > > > > > > // Check server side error > > > function getServerError(data) { > > > var serverErrorHash = []; > > > var serverError = ""; > > > if (data._ERROR_MESSAGE_LIST_ != undefined) { > > > serverErrorHash = data._ERROR_MESSAGE_LIST_; > > > jQuery.each(serverErrorHash, function(i, error) { > > > serverError += error.message + '<br/>'; > > > }); > > > } > > > if (data._ERROR_MESSAGE_ != undefined) { > > > serverError = data._ERROR_MESSAGE_; > > > } > > > return serverError; > > > } > > > > > > function createUpdateCustomerAndShippingAddress() { > > > var result = false; > > > jQuery.ajax({ > > > url: 'createUpdateShippingAddress', > > > type: 'POST', > > > dataType: 'json', > > > async: false, > > > data: jQuery('#shippingForm').serialize(), > > > success: function(json) { > > > var serverError = getServerError(json); > > > if (!serverError) { > > > jQuery('#shippingFormServerError').fadeOut('fast'); > > > // Process Shipping data response. > > > jQuery('#shipToPartyId').val(json.partyId); > > > jQuery('#billToPartyId').val(json.partyId); > > > jQuery('#shipToContactMechId').val(json.contactMechId); > > > > > > jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); > > > jQuery('#emailContactMechId').val(json.emailContactMechId); > > > > > > //jQuery('#completedShippingMethod').html(json.shippingDescription); > > > updateShippingSummary(); > > > getShipOptions(); > > > result = true; > > > } else { > > > jQuery('#shippingFormServerError').html(serverError); > > > > jQuery('#shippingFormServerError').css("display","block"); > > > result = false; > > > } > > > }, > > > error: function(error) { > > > if (error != "") { > > > jQuery('#shippingFormServerError').html(error); > > > } > > > result = false; > > > } > > > }); > > > return result; > > > } > > > > > > Now with this modifications I am showing the server side error messages > > > correctly. > > > > > > > > > HTH > > > > > > > > > On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto < > [hidden email] > > >wrote: > > > > > >> Hi BJ, > > >> > > >> The setAnonuserLogin is an ECA triggered before. The problem is after > it > > if > > >> I'm not wrong. > > >> > > >> Look at: > > >> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > > >> ServiceDispatcher.java:599:INFO ] Sync service > > >> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in > > [112] > > >> milliseconds with response [{errorMessageList={Area code is missing, > > Falta > > >> Teléfono de Contacto}, responseMessage=error}] > > >> ... > > >> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > > >> RequestHandler.java:639:INFO ] Ran Event > > >> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] > > from > > >> [request], result is [success] > > >> > > >> The service that is called from ajax is returning 'error' but the > > chained > > >> json request is returning 'success'. I guess this is the problem. > > >> > > >> Thanks anyway! > > >> > > >> > > >> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> > > wrote: > > >> > > >>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with > > >>> response [{responseMessage=success}] > > >>> > > >>> it is evaluating a good lognin. this is where to debug. > > >>> > > >>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: > > >>>> Hi all, > > >>>> > > >>>> I am customizing the onePageCheckout (the anonymous part) and I > found > > >>>> something strange. I've changed the client-side validation in order > to > > >>> allow > > >>>> the customer to only introduce the phone, cell phone or both. But on > > >>>> server-side I didn't change anything in the > > PartyContactMechMapProcs.xml > > >>>> yet. So, it is throwing an error of course, but the ajax handler > does > > >>> not > > >>>> consider it as an error. It always executes the success ajax > handler! > > >>>> > > >>>> This is the stack trace: > > >>>> > > >>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ > > >>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] > Request > > >>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] > > >>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ > > >>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 > > >>> requests, > > >>>> 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml > > >>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ > > >>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: > > >>>> setAnonUserLogin, triggered by rule on Service: > > >>>> createUpdateCustomerAndShippingAddress > > >>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ > > >>>> ServiceDispatcher.java:599:INFO ] Sync service > > >>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds > with > > >>>> response [{responseMessage=success}] > > >>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ > > >>>> TransactionUtil.java:374:WARN ] > > >>>> ---- exception report > > >>>> ---------------------------------------------------------- > > >>>> [TransactionUtil.setRollbackOnly] Calling transaction > setRollbackOnly; > > >>> this > > >>>> stack trace shows where this is happening: > > >>>> Exception: java.lang.Exception > > >>>> Message: Error in simple-method [Create/Update Customer, Shipping > > >>> Address > > >>>> and other contact details. > > >>>> > > >>> > > > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > > >>>> ; {Area code is missing, Falta Teléfono de Contacto} > > >>>> ---- stack trace > > >>>> --------------------------------------------------------------- > > >>>> java.lang.Exception: Error in simple-method [Create/Update Customer, > > >>>> Shipping Address and other contact details. > > >>>> > > >>> > > > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > > >>>> ; {Area code is missing, Falta Teléfono de Contacto} > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) > > >>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) > > >>>> > org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) > > >>>> > > org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) > > >>>> > > >>> > > > org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) > > >>>> > > >>> > > > org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) > > >>>> > > >>> > > > org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) > > >>>> > > >>> > > > _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > > >>>> > > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > > >>>> > > >>> > > > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > > >>>> > > >>> > > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > > >>>> > > >>> > > > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > >>> > > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > > >>>> > > >>> > > > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > > >>>> > > >>> > > > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > > >>>> > > >>> > > > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > > >>>> > > >>> > > > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > > >>>> > > >>> > > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > > >>>> > > >>> > > > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > > >>>> > > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > > >>>> java.lang.Thread.run(Thread.java:619) > > >>>> > > >>> > > > -------------------------------------------------------------------------------- > > >>>> > > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > > >>>> ServiceDispatcher.java:543:ERROR] Error in Service > > >>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, > Falta > > >>>> Teléfono de Contacto > > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > > >>>> TransactionUtil.java:338:ERROR] > > >>>> ---- exception report > > >>>> ---------------------------------------------------------- > > >>>> [TransactionUtil.rollback] > > >>>> Exception: java.lang.Exception > > >>>> Message: Stack Trace > > >>>> ---- stack trace > > >>>> --------------------------------------------------------------- > > >>>> java.lang.Exception: Stack Trace > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > > >>>> > > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > > >>>> > > >>> > > > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > > >>>> > > >>> > > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > > >>>> > > >>> > > > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > >>> > > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > > >>>> > > >>> > > > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > > >>>> > > >>> > > > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > > >>>> > > >>> > > > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > > >>>> > > >>> > > > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > > >>>> > > >>> > > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > > >>>> > > >>> > > > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > > >>>> > > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > > >>>> java.lang.Thread.run(Thread.java:619) > > >>>> > > >>> > > > -------------------------------------------------------------------------------- > > >>>> > > >>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ > > >>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] > transaction > > >>>> rolled back > > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > > >>>> ServiceDispatcher.java:599:INFO ] Sync service > > >>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in > > >>> [112] > > >>>> milliseconds with response [{errorMessageList={Area code is missing, > > >>> Falta > > >>>> Teléfono de Contacto}, responseMessage=error}] > > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:639:INFO ] Ran Event > > >>>> [service:#createUpdateCustomerAndShippingAddress] from [request], > > result > > >>> is > > >>>> [error] > > >>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress > > >>> caused an > > >>>> error with the following message: {Area code is missing, Falta > > Teléfono > > >>> de > > >>>> Contacto} > > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response > is > > a > > >>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: > > >>>> requestUri=json overrideViewUri=null > > >>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > > >>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:639:INFO ] Ran Event > > >>>> > [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] > > >>> from > > >>>> [request], result is [success] > > >>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ > > >>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, > > >>> ServerHitBin > > >>>> delegatorName=default#JF > > >>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ > > >>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for > > >>> [ServerHitBin]; > > >>>> curSeqId=53390, maxSeqId=53400, bankSize=10 > > >>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ > > >>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] > Request > > >>> Done- > > >>>> total:0.386,since last([createUpdateShip...):0.386]] > > >>>> > > >>>> > > >>>> > > >>> > > > ----------------------------------------------------------------------------------------------- > > >>>> > > >>>> After a bit of investigation I found this: > > >>>> > > >>>> The event 'createUpdateCustomerAndShippingAddress' is returning an > > error > > >>> as > > >>>> a result but since the request is chained (with a json request) the > > >>>> controller takes the response from the event > > >>>> > 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' > > >>> which > > >>>> is always 'success'. So that's why I figure out the ajax error > handler > > >>> is > > >>>> never invoked. > > >>>> > > >>>> What do you think? > > >>>> > > >>>> For further details, I am using a 3 months old trunk version with > > MySql. > > >>>> I've checked out the latest version > > >>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still > > the > > >>> same > > >>>> code as I have. > > >>>> > > >>>> Thanks in advance. > > >>>> > > >>> > > >> > > >> > > >> > > >> -- > > >> ----- > > >> > > >> Jonatan Soto > > >> > > > > > > > > > > > > -- > > > ----- > > > > > > Jonatan Soto > > > > > > > -- > ----- > > Jonatan Soto > -- ----- Jonatan Soto |
Ok, hadn't checked the code yet, did it now, my bad :)
What I oberved is that when I enter promo code, it fires an ajax request and don't display me the error message when I entered the wrong code, need to fix that. Well, the interesting part is, it then fires another ajax request to check if the cart is empty, how possibly can a cart get empty by applying a promo code :-/ And then it fires another one to update the cart with the discounted price. Why don't we return the updated cart along with the error message, if any, and replace the existing html with the new one, so that user is displayed with the error message and the updated cart both, will also save us two extra ajax requests. Another thing I noticed is that lot's of elements are being identified using their ids, not so good. ----- Original Message ----- From: "Atul Vani" <[hidden email]> To: [hidden email] Sent: Sunday, August 28, 2011 10:47:07 PM Subject: Re: Issue with ajax and json response Jonatan, IMO, the event you invoked in your request mapping should be fixed to return error response, when they get errors. It will cause the error response to be rendered instead of the success. Then you can use type="request" value="json" for the error response. The responseText recieved by the ajax will be a JSON String. You can then pass this JSON string to the getServerError() function to extract and return error message(s). I don't know if this information will be useful to you or not, as I haven't seen the code, but this is pretty much all one needs to check :) ----- Original Message ----- From: "Jonatan Soto" <[hidden email]> To: [hidden email] Sent: Saturday, August 27, 2011 3:51:58 PM Subject: Re: Issue with ajax and json response Hi Atul, I've didn't got server error messages using what you said. Probably is something wrong in my code, but what I have noticed is that no matters what kind of response I set, the 'success' callback method is called. Anyway, how is handled the server response in this case? I mean, where can I find the code where the getServerError() JS function is called once we return the error response? Many thanks Atul. On Fri, Aug 26, 2011 at 7:32 PM, Atul Vani <[hidden email]>wrote: > Jonatan, > > I think if you use > <response name="error" type="request" value="json"/> > (it is used in several places in ecommerce and other components' > controller.xml) > > and then use the getServerError() function > (used in specialpurpose/ecommerce/webapp/ecommerce/images/profile.js) > to parse the JSON response, > then you should be able to retrieve the error message to display it to the > user. > > I'm not sure if it will be helpful, I didn't got the problem completely > either ;-) > > > ----- Original Message ----- > From: "Jonatan Soto" <[hidden email]> > To: [hidden email] > Sent: Sunday, July 17, 2011 5:56:10 PM > Subject: Re: Issue with ajax and json response > > Done. Patch provided, not fully tested. > https://issues.apache.org/jira/browse/OFBIZ-4342 > > <https://issues.apache.org/jira/browse/OFBIZ-4342>Regards, > > > On Sun, Jul 17, 2011 at 1:34 PM, Scott Gray <[hidden email] > >wrote: > > > Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, would > > be great if you could create a jira issue so this doesn't get lost. > > > > Regards > > Scott > > > > HotWax Media > > http://www.hotwaxmedia.com > > > > On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: > > > > > Well, I did a little read on the jquery ajax documentation ( > > > http://api.jquery.com/jQuery.ajax/) and some of my assertions were > > wrong. > > > It is definitively not related to > > > the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when > I > > > realized that the result the controller returns has nothing to do with > > the > > > ajax callbacks :) > > > > > > According to this doc the error callback is: > > > "A function to be called if the request fails...." > > > > > > In the case I'm exposing, obviously the request is not failing so the > > error > > > I'm getting should be handled in the success callback. Please, tell me > if > > > there is another way to do it. > > > I found a js function in the CheckoutProcess.js called > > getServerError(...) > > > which is never invoked. I think it should be included in the success > > > callback like the following code: > > > > > > (chekoutProcess.js) > > > > > > // Check server side error > > > function getServerError(data) { > > > var serverErrorHash = []; > > > var serverError = ""; > > > if (data._ERROR_MESSAGE_LIST_ != undefined) { > > > serverErrorHash = data._ERROR_MESSAGE_LIST_; > > > jQuery.each(serverErrorHash, function(i, error) { > > > serverError += error.message + '<br/>'; > > > }); > > > } > > > if (data._ERROR_MESSAGE_ != undefined) { > > > serverError = data._ERROR_MESSAGE_; > > > } > > > return serverError; > > > } > > > > > > function createUpdateCustomerAndShippingAddress() { > > > var result = false; > > > jQuery.ajax({ > > > url: 'createUpdateShippingAddress', > > > type: 'POST', > > > dataType: 'json', > > > async: false, > > > data: jQuery('#shippingForm').serialize(), > > > success: function(json) { > > > var serverError = getServerError(json); > > > if (!serverError) { > > > jQuery('#shippingFormServerError').fadeOut('fast'); > > > // Process Shipping data response. > > > jQuery('#shipToPartyId').val(json.partyId); > > > jQuery('#billToPartyId').val(json.partyId); > > > jQuery('#shipToContactMechId').val(json.contactMechId); > > > > > > jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); > > > jQuery('#emailContactMechId').val(json.emailContactMechId); > > > > > > //jQuery('#completedShippingMethod').html(json.shippingDescription); > > > updateShippingSummary(); > > > getShipOptions(); > > > result = true; > > > } else { > > > jQuery('#shippingFormServerError').html(serverError); > > > > jQuery('#shippingFormServerError').css("display","block"); > > > result = false; > > > } > > > }, > > > error: function(error) { > > > if (error != "") { > > > jQuery('#shippingFormServerError').html(error); > > > } > > > result = false; > > > } > > > }); > > > return result; > > > } > > > > > > Now with this modifications I am showing the server side error messages > > > correctly. > > > > > > > > > HTH > > > > > > > > > On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto < > [hidden email] > > >wrote: > > > > > >> Hi BJ, > > >> > > >> The setAnonuserLogin is an ECA triggered before. The problem is after > it > > if > > >> I'm not wrong. > > >> > > >> Look at: > > >> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > > >> ServiceDispatcher.java:599:INFO ] Sync service > > >> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in > > [112] > > >> milliseconds with response [{errorMessageList={Area code is missing, > > Falta > > >> Teléfono de Contacto}, responseMessage=error}] > > >> ... > > >> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > > >> RequestHandler.java:639:INFO ] Ran Event > > >> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] > > from > > >> [request], result is [success] > > >> > > >> The service that is called from ajax is returning 'error' but the > > chained > > >> json request is returning 'success'. I guess this is the problem. > > >> > > >> Thanks anyway! > > >> > > >> > > >> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> > > wrote: > > >> > > >>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with > > >>> response [{responseMessage=success}] > > >>> > > >>> it is evaluating a good lognin. this is where to debug. > > >>> > > >>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: > > >>>> Hi all, > > >>>> > > >>>> I am customizing the onePageCheckout (the anonymous part) and I > found > > >>>> something strange. I've changed the client-side validation in order > to > > >>> allow > > >>>> the customer to only introduce the phone, cell phone or both. But on > > >>>> server-side I didn't change anything in the > > PartyContactMechMapProcs.xml > > >>>> yet. So, it is throwing an error of course, but the ajax handler > does > > >>> not > > >>>> consider it as an error. It always executes the success ajax > handler! > > >>>> > > >>>> This is the stack trace: > > >>>> > > >>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ > > >>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] > Request > > >>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] > > >>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ > > >>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 > > >>> requests, > > >>>> 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml > > >>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ > > >>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: > > >>>> setAnonUserLogin, triggered by rule on Service: > > >>>> createUpdateCustomerAndShippingAddress > > >>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ > > >>>> ServiceDispatcher.java:599:INFO ] Sync service > > >>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds > with > > >>>> response [{responseMessage=success}] > > >>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ > > >>>> TransactionUtil.java:374:WARN ] > > >>>> ---- exception report > > >>>> ---------------------------------------------------------- > > >>>> [TransactionUtil.setRollbackOnly] Calling transaction > setRollbackOnly; > > >>> this > > >>>> stack trace shows where this is happening: > > >>>> Exception: java.lang.Exception > > >>>> Message: Error in simple-method [Create/Update Customer, Shipping > > >>> Address > > >>>> and other contact details. > > >>>> > > >>> > > > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > > >>>> ; {Area code is missing, Falta Teléfono de Contacto} > > >>>> ---- stack trace > > >>>> --------------------------------------------------------------- > > >>>> java.lang.Exception: Error in simple-method [Create/Update Customer, > > >>>> Shipping Address and other contact details. > > >>>> > > >>> > > > [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: > > >>>> ; {Area code is missing, Falta Teléfono de Contacto} > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) > > >>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) > > >>>> > org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) > > >>>> > > org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) > > >>>> > > >>> > > > org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) > > >>>> > > >>> > > > org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) > > >>>> > > >>> > > > org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) > > >>>> > > >>> > > > _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > > >>>> > > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > > >>>> > > >>> > > > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > > >>>> > > >>> > > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > > >>>> > > >>> > > > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > >>> > > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > > >>>> > > >>> > > > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > > >>>> > > >>> > > > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > > >>>> > > >>> > > > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > > >>>> > > >>> > > > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > > >>>> > > >>> > > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > > >>>> > > >>> > > > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > > >>>> > > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > > >>>> java.lang.Thread.run(Thread.java:619) > > >>>> > > >>> > > > -------------------------------------------------------------------------------- > > >>>> > > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > > >>>> ServiceDispatcher.java:543:ERROR] Error in Service > > >>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, > Falta > > >>>> Teléfono de Contacto > > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ > > >>>> TransactionUtil.java:338:ERROR] > > >>>> ---- exception report > > >>>> ---------------------------------------------------------- > > >>>> [TransactionUtil.rollback] > > >>>> Exception: java.lang.Exception > > >>>> Message: Stack Trace > > >>>> ---- stack trace > > >>>> --------------------------------------------------------------- > > >>>> java.lang.Exception: Stack Trace > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) > > >>>> > > >>> > > > org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) > > >>>> > > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) > > >>>> > > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) > > >>>> > > >>> > > > org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) > > >>>> > > >>> > > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) > > >>>> > > >>> > > > org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) > > >>>> > org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > > >>>> > > >>> > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > > >>>> > > >>> > > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > > >>>> > > >>> > > > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > > >>>> > > >>> > > > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > > >>>> > > >>> > > > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > > >>>> > > >>> > > > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > > >>>> > > >>> > > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) > > >>>> > > >>> > > > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > > >>>> > > >>> > > > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) > > >>>> > > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > > >>>> java.lang.Thread.run(Thread.java:619) > > >>>> > > >>> > > > -------------------------------------------------------------------------------- > > >>>> > > >>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ > > >>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] > transaction > > >>>> rolled back > > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > > >>>> ServiceDispatcher.java:599:INFO ] Sync service > > >>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in > > >>> [112] > > >>>> milliseconds with response [{errorMessageList={Area code is missing, > > >>> Falta > > >>>> Teléfono de Contacto}, responseMessage=error}] > > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:639:INFO ] Ran Event > > >>>> [service:#createUpdateCustomerAndShippingAddress] from [request], > > result > > >>> is > > >>>> [error] > > >>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress > > >>> caused an > > >>>> error with the following message: {Area code is missing, Falta > > Teléfono > > >>> de > > >>>> Contacto} > > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response > is > > a > > >>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: > > >>>> requestUri=json overrideViewUri=null > > >>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 > > >>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ > > >>>> RequestHandler.java:639:INFO ] Ran Event > > >>>> > [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] > > >>> from > > >>>> [request], result is [success] > > >>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ > > >>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, > > >>> ServerHitBin > > >>>> delegatorName=default#JF > > >>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ > > >>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for > > >>> [ServerHitBin]; > > >>>> curSeqId=53390, maxSeqId=53400, bankSize=10 > > >>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ > > >>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] > Request > > >>> Done- > > >>>> total:0.386,since last([createUpdateShip...):0.386]] > > >>>> > > >>>> > > >>>> > > >>> > > > ----------------------------------------------------------------------------------------------- > > >>>> > > >>>> After a bit of investigation I found this: > > >>>> > > >>>> The event 'createUpdateCustomerAndShippingAddress' is returning an > > error > > >>> as > > >>>> a result but since the request is chained (with a json request) the > > >>>> controller takes the response from the event > > >>>> > 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' > > >>> which > > >>>> is always 'success'. So that's why I figure out the ajax error > handler > > >>> is > > >>>> never invoked. > > >>>> > > >>>> What do you think? > > >>>> > > >>>> For further details, I am using a 3 months old trunk version with > > MySql. > > >>>> I've checked out the latest version > > >>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still > > the > > >>> same > > >>>> code as I have. > > >>>> > > >>>> Thanks in advance. > > >>>> > > >>> > > >> > > >> > > >> > > >> -- > > >> ----- > > >> > > >> Jonatan Soto > > >> > > > > > > > > > > > > -- > > > ----- > > > > > > Jonatan Soto > > > > > > > -- > ----- > > Jonatan Soto > -- ----- Jonatan Soto |
Administrator
|
Atul,
These interesting comments should be better in the Jira Thanks Jacques From: "Atul Vani" <[hidden email]> > Ok, hadn't checked the code yet, did it now, my bad :) > > What I oberved is that when I enter promo code, it fires an ajax request and don't display me the error message when I entered the > wrong code, need to fix that. Well, the interesting part is, it then fires another ajax request to check if the cart is empty, how > possibly can a cart get empty by applying a promo code :-/ And then it fires another one to update the cart with the discounted > price. Why don't we return the updated cart along with the error message, if any, and replace the existing html with the new one, > so that user is displayed with the error message and the updated cart both, will also save us two extra ajax requests. Another > thing I noticed is that lot's of elements are being identified using their ids, not so good. > > ----- Original Message ----- > From: "Atul Vani" <[hidden email]> > To: [hidden email] > Sent: Sunday, August 28, 2011 10:47:07 PM > Subject: Re: Issue with ajax and json response > > Jonatan, > > IMO, the event you invoked in your request mapping should be fixed to return error response, when they get errors. It will cause > the error response to be rendered instead of the success. Then you can use type="request" value="json" for the error response. The > responseText recieved by the ajax will be a JSON String. You can then pass this JSON string to the getServerError() function to > extract and return error message(s). I don't know if this information will be useful to you or not, as I haven't seen the code, > but this is pretty much all one needs to check :) > > > ----- Original Message ----- > From: "Jonatan Soto" <[hidden email]> > To: [hidden email] > Sent: Saturday, August 27, 2011 3:51:58 PM > Subject: Re: Issue with ajax and json response > > Hi Atul, > > I've didn't got server error messages using what you said. Probably is > something wrong in my code, but what I have noticed is that no matters what > kind of response I set, the 'success' callback method is called. > Anyway, how is handled the server response in this case? I mean, where can I > find the code where the getServerError() JS function is called once we > return the error response? > > Many thanks Atul. > > On Fri, Aug 26, 2011 at 7:32 PM, Atul Vani <[hidden email]>wrote: > >> Jonatan, >> >> I think if you use >> <response name="error" type="request" value="json"/> >> (it is used in several places in ecommerce and other components' >> controller.xml) >> >> and then use the getServerError() function >> (used in specialpurpose/ecommerce/webapp/ecommerce/images/profile.js) >> to parse the JSON response, >> then you should be able to retrieve the error message to display it to the >> user. >> >> I'm not sure if it will be helpful, I didn't got the problem completely >> either ;-) >> >> >> ----- Original Message ----- >> From: "Jonatan Soto" <[hidden email]> >> To: [hidden email] >> Sent: Sunday, July 17, 2011 5:56:10 PM >> Subject: Re: Issue with ajax and json response >> >> Done. Patch provided, not fully tested. >> https://issues.apache.org/jira/browse/OFBIZ-4342 >> >> <https://issues.apache.org/jira/browse/OFBIZ-4342>Regards, >> >> >> On Sun, Jul 17, 2011 at 1:34 PM, Scott Gray <[hidden email] >> >wrote: >> >> > Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, would >> > be great if you could create a jira issue so this doesn't get lost. >> > >> > Regards >> > Scott >> > >> > HotWax Media >> > http://www.hotwaxmedia.com >> > >> > On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: >> > >> > > Well, I did a little read on the jquery ajax documentation ( >> > > http://api.jquery.com/jQuery.ajax/) and some of my assertions were >> > wrong. >> > > It is definitively not related to >> > > the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when >> I >> > > realized that the result the controller returns has nothing to do with >> > the >> > > ajax callbacks :) >> > > >> > > According to this doc the error callback is: >> > > "A function to be called if the request fails...." >> > > >> > > In the case I'm exposing, obviously the request is not failing so the >> > error >> > > I'm getting should be handled in the success callback. Please, tell me >> if >> > > there is another way to do it. >> > > I found a js function in the CheckoutProcess.js called >> > getServerError(...) >> > > which is never invoked. I think it should be included in the success >> > > callback like the following code: >> > > >> > > (chekoutProcess.js) >> > > >> > > // Check server side error >> > > function getServerError(data) { >> > > var serverErrorHash = []; >> > > var serverError = ""; >> > > if (data._ERROR_MESSAGE_LIST_ != undefined) { >> > > serverErrorHash = data._ERROR_MESSAGE_LIST_; >> > > jQuery.each(serverErrorHash, function(i, error) { >> > > serverError += error.message + '<br/>'; >> > > }); >> > > } >> > > if (data._ERROR_MESSAGE_ != undefined) { >> > > serverError = data._ERROR_MESSAGE_; >> > > } >> > > return serverError; >> > > } >> > > >> > > function createUpdateCustomerAndShippingAddress() { >> > > var result = false; >> > > jQuery.ajax({ >> > > url: 'createUpdateShippingAddress', >> > > type: 'POST', >> > > dataType: 'json', >> > > async: false, >> > > data: jQuery('#shippingForm').serialize(), >> > > success: function(json) { >> > > var serverError = getServerError(json); >> > > if (!serverError) { >> > > jQuery('#shippingFormServerError').fadeOut('fast'); >> > > // Process Shipping data response. >> > > jQuery('#shipToPartyId').val(json.partyId); >> > > jQuery('#billToPartyId').val(json.partyId); >> > > jQuery('#shipToContactMechId').val(json.contactMechId); >> > > >> > > jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); >> > > jQuery('#emailContactMechId').val(json.emailContactMechId); >> > > >> > > //jQuery('#completedShippingMethod').html(json.shippingDescription); >> > > updateShippingSummary(); >> > > getShipOptions(); >> > > result = true; >> > > } else { >> > > jQuery('#shippingFormServerError').html(serverError); >> > > >> jQuery('#shippingFormServerError').css("display","block"); >> > > result = false; >> > > } >> > > }, >> > > error: function(error) { >> > > if (error != "") { >> > > jQuery('#shippingFormServerError').html(error); >> > > } >> > > result = false; >> > > } >> > > }); >> > > return result; >> > > } >> > > >> > > Now with this modifications I am showing the server side error messages >> > > correctly. >> > > >> > > >> > > HTH >> > > >> > > >> > > On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto < >> [hidden email] >> > >wrote: >> > > >> > >> Hi BJ, >> > >> >> > >> The setAnonuserLogin is an ECA triggered before. The problem is after >> it >> > if >> > >> I'm not wrong. >> > >> >> > >> Look at: >> > >> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >> > >> ServiceDispatcher.java:599:INFO ] Sync service >> > >> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in >> > [112] >> > >> milliseconds with response [{errorMessageList={Area code is missing, >> > Falta >> > >> Teléfono de Contacto}, responseMessage=error}] >> > >> ... >> > >> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >> > >> RequestHandler.java:639:INFO ] Ran Event >> > >> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] >> > from >> > >> [request], result is [success] >> > >> >> > >> The service that is called from ajax is returning 'error' but the >> > chained >> > >> json request is returning 'success'. I guess this is the problem. >> > >> >> > >> Thanks anyway! >> > >> >> > >> >> > >> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> >> > wrote: >> > >> >> > >>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >> > >>> response [{responseMessage=success}] >> > >>> >> > >>> it is evaluating a good lognin. this is where to debug. >> > >>> >> > >>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: >> > >>>> Hi all, >> > >>>> >> > >>>> I am customizing the onePageCheckout (the anonymous part) and I >> found >> > >>>> something strange. I've changed the client-side validation in order >> to >> > >>> allow >> > >>>> the customer to only introduce the phone, cell phone or both. But on >> > >>>> server-side I didn't change anything in the >> > PartyContactMechMapProcs.xml >> > >>>> yet. So, it is throwing an error of course, but the ajax handler >> does >> > >>> not >> > >>>> consider it as an error. It always executes the success ajax >> handler! >> > >>>> >> > >>>> This is the stack trace: >> > >>>> >> > >>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ >> > >>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] >> Request >> > >>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] >> > >>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ >> > >>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 >> > >>> requests, >> > >>>> 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml >> > >>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ >> > >>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: >> > >>>> setAnonUserLogin, triggered by rule on Service: >> > >>>> createUpdateCustomerAndShippingAddress >> > >>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ >> > >>>> ServiceDispatcher.java:599:INFO ] Sync service >> > >>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds >> with >> > >>>> response [{responseMessage=success}] >> > >>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ >> > >>>> TransactionUtil.java:374:WARN ] >> > >>>> ---- exception report >> > >>>> ---------------------------------------------------------- >> > >>>> [TransactionUtil.setRollbackOnly] Calling transaction >> setRollbackOnly; >> > >>> this >> > >>>> stack trace shows where this is happening: >> > >>>> Exception: java.lang.Exception >> > >>>> Message: Error in simple-method [Create/Update Customer, Shipping >> > >>> Address >> > >>>> and other contact details. >> > >>>> >> > >>> >> > >> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >> > >>>> ; {Area code is missing, Falta Teléfono de Contacto} >> > >>>> ---- stack trace >> > >>>> --------------------------------------------------------------- >> > >>>> java.lang.Exception: Error in simple-method [Create/Update Customer, >> > >>>> Shipping Address and other contact details. >> > >>>> >> > >>> >> > >> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >> > >>>> ; {Area code is missing, Falta Teléfono de Contacto} >> > >>>> >> > >>> >> > >> org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) >> > >>>> >> > >>> >> > >> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) >> > >>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) >> > >>>> >> org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) >> > >>>> >> > org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) >> > >>>> >> > >>> >> > >> org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) >> > >>>> >> > >>> >> > >> org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) >> > >>>> >> > >>> >> > >> org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) >> > >>>> >> > >>> >> > >> _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) >> > >>>> >> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) >> > >>>> >> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >> > >>>> >> > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >> > >>>> >> > >>> >> > >> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >> > >>>> >> > >>> >> > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >> > >>>> >> > >>> >> > >> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >> > >>>> >> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >> > >>>> >> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >> > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >> > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> > >>>> >> > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >> > >>>> >> > >>> >> > >> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >> > >>>> >> > >>> >> > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >> > >>>> >> > >>> >> > >> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >> > >>>> >> > >>> >> > >> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >> > >>>> >> > >>> >> > >> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >> > >>>> >> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >> > >>>> java.lang.Thread.run(Thread.java:619) >> > >>>> >> > >>> >> > >> -------------------------------------------------------------------------------- >> > >>>> >> > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >> > >>>> ServiceDispatcher.java:543:ERROR] Error in Service >> > >>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, >> Falta >> > >>>> Teléfono de Contacto >> > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >> > >>>> TransactionUtil.java:338:ERROR] >> > >>>> ---- exception report >> > >>>> ---------------------------------------------------------- >> > >>>> [TransactionUtil.rollback] >> > >>>> Exception: java.lang.Exception >> > >>>> Message: Stack Trace >> > >>>> ---- stack trace >> > >>>> --------------------------------------------------------------- >> > >>>> java.lang.Exception: Stack Trace >> > >>>> >> > >>> >> > >> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) >> > >>>> >> > >>> >> > >> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) >> > >>>> >> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) >> > >>>> >> > org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >> > >>>> >> > org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >> > >>>> >> > >>> >> > >> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >> > >>>> >> > >>> >> > org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >> > >>>> >> > >>> >> > >> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >> > >>>> >> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >> > >>>> >> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >> > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >> > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> > >>>> >> > org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >> > >>>> >> > >>> >> > >> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >> > >>>> >> > >>> >> > >> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >> > >>>> >> > >>> >> > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >> > >>>> >> > >>> >> > >> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >> > >>>> >> > >>> >> > >> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >> > >>>> >> > >>> >> > >> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >> > >>>> >> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >> > >>>> java.lang.Thread.run(Thread.java:619) >> > >>>> >> > >>> >> > >> -------------------------------------------------------------------------------- >> > >>>> >> > >>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ >> > >>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] >> transaction >> > >>>> rolled back >> > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >> > >>>> ServiceDispatcher.java:599:INFO ] Sync service >> > >>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in >> > >>> [112] >> > >>>> milliseconds with response [{errorMessageList={Area code is missing, >> > >>> Falta >> > >>>> Teléfono de Contacto}, responseMessage=error}] >> > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >> > >>>> RequestHandler.java:639:INFO ] Ran Event >> > >>>> [service:#createUpdateCustomerAndShippingAddress] from [request], >> > result >> > >>> is >> > >>>> [error] >> > >>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ >> > >>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress >> > >>> caused an >> > >>>> error with the following message: {Area code is missing, Falta >> > Teléfono >> > >>> de >> > >>>> Contacto} >> > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >> > >>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response >> is >> > a >> > >>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >> > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >> > >>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: >> > >>>> requestUri=json overrideViewUri=null >> > >>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >> > >>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >> > >>>> RequestHandler.java:639:INFO ] Ran Event >> > >>>> >> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] >> > >>> from >> > >>>> [request], result is [success] >> > >>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ >> > >>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, >> > >>> ServerHitBin >> > >>>> delegatorName=default#JF >> > >>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ >> > >>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for >> > >>> [ServerHitBin]; >> > >>>> curSeqId=53390, maxSeqId=53400, bankSize=10 >> > >>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ >> > >>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] >> Request >> > >>> Done- >> > >>>> total:0.386,since last([createUpdateShip...):0.386]] >> > >>>> >> > >>>> >> > >>>> >> > >>> >> > >> ----------------------------------------------------------------------------------------------- >> > >>>> >> > >>>> After a bit of investigation I found this: >> > >>>> >> > >>>> The event 'createUpdateCustomerAndShippingAddress' is returning an >> > error >> > >>> as >> > >>>> a result but since the request is chained (with a json request) the >> > >>>> controller takes the response from the event >> > >>>> >> 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' >> > >>> which >> > >>>> is always 'success'. So that's why I figure out the ajax error >> handler >> > >>> is >> > >>>> never invoked. >> > >>>> >> > >>>> What do you think? >> > >>>> >> > >>>> For further details, I am using a 3 months old trunk version with >> > MySql. >> > >>>> I've checked out the latest version >> > >>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still >> > the >> > >>> same >> > >>>> code as I have. >> > >>>> >> > >>>> Thanks in advance. >> > >>>> >> > >>> >> > >> >> > >> >> > >> >> > >> -- >> > >> ----- >> > >> >> > >> Jonatan Soto >> > >> >> > > >> > > >> > > >> > > -- >> > > ----- >> > > >> > > Jonatan Soto >> > >> > >> >> >> -- >> ----- >> >> Jonatan Soto >> > > > > -- > ----- > > Jonatan Soto > |
Jacques,
Got it, will do it soon, Thanks :) Thanks& Regards Atul Vani Enterprise Software Developer HotWax Media Pvt. Ltd. http://www.hotwaxmedia.com/ We are the Global Leaders in Apache OFBiz, Google 'ofbiz' and see for yourself. On Monday 29 August 2011 01:05 PM, Jacques Le Roux wrote: > Atul, > > These interesting comments should be better in the Jira > > Thanks > > Jacques > > From: "Atul Vani" <[hidden email]> >> Ok, hadn't checked the code yet, did it now, my bad :) >> >> What I oberved is that when I enter promo code, it fires an ajax >> request and don't display me the error message when I entered the >> wrong code, need to fix that. Well, the interesting part is, it then >> fires another ajax request to check if the cart is empty, how >> possibly can a cart get empty by applying a promo code :-/ And then >> it fires another one to update the cart with the discounted price. >> Why don't we return the updated cart along with the error message, if >> any, and replace the existing html with the new one, so that user is >> displayed with the error message and the updated cart both, will also >> save us two extra ajax requests. Another thing I noticed is that >> lot's of elements are being identified using their ids, not so good. >> >> ----- Original Message ----- >> From: "Atul Vani" <[hidden email]> >> To: [hidden email] >> Sent: Sunday, August 28, 2011 10:47:07 PM >> Subject: Re: Issue with ajax and json response >> >> Jonatan, >> >> IMO, the event you invoked in your request mapping should be fixed to >> return error response, when they get errors. It will cause the error >> response to be rendered instead of the success. Then you can use >> type="request" value="json" for the error response. The responseText >> recieved by the ajax will be a JSON String. You can then pass this >> JSON string to the getServerError() function to extract and return >> error message(s). I don't know if this information will be useful to >> you or not, as I haven't seen the code, but this is pretty much all >> one needs to check :) >> >> >> ----- Original Message ----- >> From: "Jonatan Soto" <[hidden email]> >> To: [hidden email] >> Sent: Saturday, August 27, 2011 3:51:58 PM >> Subject: Re: Issue with ajax and json response >> >> Hi Atul, >> >> I've didn't got server error messages using what you said. Probably is >> something wrong in my code, but what I have noticed is that no >> matters what >> kind of response I set, the 'success' callback method is called. >> Anyway, how is handled the server response in this case? I mean, >> where can I >> find the code where the getServerError() JS function is called once we >> return the error response? >> >> Many thanks Atul. >> >> On Fri, Aug 26, 2011 at 7:32 PM, Atul Vani >> <[hidden email]>wrote: >> >>> Jonatan, >>> >>> I think if you use >>> <response name="error" type="request" value="json"/> >>> (it is used in several places in ecommerce and other components' >>> controller.xml) >>> >>> and then use the getServerError() function >>> (used in specialpurpose/ecommerce/webapp/ecommerce/images/profile.js) >>> to parse the JSON response, >>> then you should be able to retrieve the error message to display it >>> to the >>> user. >>> >>> I'm not sure if it will be helpful, I didn't got the problem completely >>> either ;-) >>> >>> >>> ----- Original Message ----- >>> From: "Jonatan Soto" <[hidden email]> >>> To: [hidden email] >>> Sent: Sunday, July 17, 2011 5:56:10 PM >>> Subject: Re: Issue with ajax and json response >>> >>> Done. Patch provided, not fully tested. >>> https://issues.apache.org/jira/browse/OFBIZ-4342 >>> >>> <https://issues.apache.org/jira/browse/OFBIZ-4342>Regards, >>> >>> >>> On Sun, Jul 17, 2011 at 1:34 PM, Scott Gray <[hidden email] >>> >wrote: >>> >>> > Yeah, checking for the _ERROR_MESSAGE* keys is the right way to >>> go, would >>> > be great if you could create a jira issue so this doesn't get lost. >>> > >>> > Regards >>> > Scott >>> > >>> > HotWax Media >>> > http://www.hotwaxmedia.com >>> > >>> > On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: >>> > >>> > > Well, I did a little read on the jquery ajax documentation ( >>> > > http://api.jquery.com/jQuery.ajax/) and some of my assertions were >>> > wrong. >>> > > It is definitively not related to >>> > > the CommonEvents#jsonResponseFromRequestAttributes. I felt >>> stupid when >>> I >>> > > realized that the result the controller returns has nothing to >>> do with >>> > the >>> > > ajax callbacks :) >>> > > >>> > > According to this doc the error callback is: >>> > > "A function to be called if the request fails...." >>> > > >>> > > In the case I'm exposing, obviously the request is not failing >>> so the >>> > error >>> > > I'm getting should be handled in the success callback. Please, >>> tell me >>> if >>> > > there is another way to do it. >>> > > I found a js function in the CheckoutProcess.js called >>> > getServerError(...) >>> > > which is never invoked. I think it should be included in the >>> success >>> > > callback like the following code: >>> > > >>> > > (chekoutProcess.js) >>> > > >>> > > // Check server side error >>> > > function getServerError(data) { >>> > > var serverErrorHash = []; >>> > > var serverError = ""; >>> > > if (data._ERROR_MESSAGE_LIST_ != undefined) { >>> > > serverErrorHash = data._ERROR_MESSAGE_LIST_; >>> > > jQuery.each(serverErrorHash, function(i, error) { >>> > > serverError += error.message + '<br/>'; >>> > > }); >>> > > } >>> > > if (data._ERROR_MESSAGE_ != undefined) { >>> > > serverError = data._ERROR_MESSAGE_; >>> > > } >>> > > return serverError; >>> > > } >>> > > >>> > > function createUpdateCustomerAndShippingAddress() { >>> > > var result = false; >>> > > jQuery.ajax({ >>> > > url: 'createUpdateShippingAddress', >>> > > type: 'POST', >>> > > dataType: 'json', >>> > > async: false, >>> > > data: jQuery('#shippingForm').serialize(), >>> > > success: function(json) { >>> > > var serverError = getServerError(json); >>> > > if (!serverError) { >>> > > jQuery('#shippingFormServerError').fadeOut('fast'); >>> > > // Process Shipping data response. >>> > > jQuery('#shipToPartyId').val(json.partyId); >>> > > jQuery('#billToPartyId').val(json.partyId); >>> > > jQuery('#shipToContactMechId').val(json.contactMechId); >>> > > >>> > > jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); >>> > > >>> jQuery('#emailContactMechId').val(json.emailContactMechId); >>> > > >>> > > >>> //jQuery('#completedShippingMethod').html(json.shippingDescription); >>> > > updateShippingSummary(); >>> > > getShipOptions(); >>> > > result = true; >>> > > } else { >>> > > >>> jQuery('#shippingFormServerError').html(serverError); >>> > > >>> jQuery('#shippingFormServerError').css("display","block"); >>> > > result = false; >>> > > } >>> > > }, >>> > > error: function(error) { >>> > > if (error != "") { >>> > > jQuery('#shippingFormServerError').html(error); >>> > > } >>> > > result = false; >>> > > } >>> > > }); >>> > > return result; >>> > > } >>> > > >>> > > Now with this modifications I am showing the server side error >>> messages >>> > > correctly. >>> > > >>> > > >>> > > HTH >>> > > >>> > > >>> > > On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto < >>> [hidden email] >>> > >wrote: >>> > > >>> > >> Hi BJ, >>> > >> >>> > >> The setAnonuserLogin is an ECA triggered before. The problem is >>> after >>> it >>> > if >>> > >> I'm not wrong. >>> > >> >>> > >> Look at: >>> > >> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>> > >> ServiceDispatcher.java:599:INFO ] Sync service >>> > >> [traditional#JF/createUpdateCustomerAndShippingAddress] >>> finished in >>> > [112] >>> > >> milliseconds with response [{errorMessageList={Area code is >>> missing, >>> > Falta >>> > >> Teléfono de Contacto}, responseMessage=error}] >>> > >> ... >>> > >> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>> > >> RequestHandler.java:639:INFO ] Ran Event >>> > >> >>> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] >>> > from >>> > >> [request], result is [success] >>> > >> >>> > >> The service that is called from ajax is returning 'error' but the >>> > chained >>> > >> json request is returning 'success'. I guess this is the problem. >>> > >> >>> > >> Thanks anyway! >>> > >> >>> > >> >>> > >> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <[hidden email]> >>> > wrote: >>> > >> >>> > >>> [traditional#JF/setAnonUserLogin] finished in [105] >>> milliseconds with >>> > >>> response [{responseMessage=success}] >>> > >>> >>> > >>> it is evaluating a good lognin. this is where to debug. >>> > >>> >>> > >>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: >>> > >>>> Hi all, >>> > >>>> >>> > >>>> I am customizing the onePageCheckout (the anonymous part) and I >>> found >>> > >>>> something strange. I've changed the client-side validation in >>> order >>> to >>> > >>> allow >>> > >>>> the customer to only introduce the phone, cell phone or both. >>> But on >>> > >>>> server-side I didn't change anything in the >>> > PartyContactMechMapProcs.xml >>> > >>>> yet. So, it is throwing an error of course, but the ajax handler >>> does >>> > >>> not >>> > >>>> consider it as an error. It always executes the success ajax >>> handler! >>> > >>>> >>> > >>>> This is the stack trace: >>> > >>>> >>> > >>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ >>> > >>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] >>> Request >>> > >>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] >>> > >>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ >>> > >>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 >>> > >>> requests, >>> > >>>> 96 views in >>> jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml >>> > >>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ >>> > >>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: >>> > >>>> setAnonUserLogin, triggered by rule on Service: >>> > >>>> createUpdateCustomerAndShippingAddress >>> > >>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ >>> > >>>> ServiceDispatcher.java:599:INFO ] Sync service >>> > >>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds >>> with >>> > >>>> response [{responseMessage=success}] >>> > >>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ >>> > >>>> TransactionUtil.java:374:WARN ] >>> > >>>> ---- exception report >>> > >>>> ---------------------------------------------------------- >>> > >>>> [TransactionUtil.setRollbackOnly] Calling transaction >>> setRollbackOnly; >>> > >>> this >>> > >>>> stack trace shows where this is happening: >>> > >>>> Exception: java.lang.Exception >>> > >>>> Message: Error in simple-method [Create/Update Customer, >>> Shipping >>> > >>> Address >>> > >>>> and other contact details. >>> > >>>> >>> > >>> >>> > >>> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>> >>> > >>>> ; {Area code is missing, Falta Teléfono de Contacto} >>> > >>>> ---- stack trace >>> > >>>> --------------------------------------------------------------- >>> > >>>> java.lang.Exception: Error in simple-method [Create/Update >>> Customer, >>> > >>>> Shipping Address and other contact details. >>> > >>>> >>> > >>> >>> > >>> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>> >>> > >>>> ; {Area code is missing, Falta Teléfono de Contacto} >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) >>> >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) >>> >>> > >>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) >>> > >>>> >>> org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) >>> > >>>> >>> > >>> org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) >>> >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) >>> >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) >>> >>> > >>>> >>> > >>> >>> > >>> _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) >>> >>> > >>>> >>> > >>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) >>> > >>>> >>> > >>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>> > >>>> >>> > >>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>> >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>> >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>> >>> > >>>> >>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>> > >>>> >>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>> > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>> > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>> >>> > >>>> >>> > >>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>> >>> > >>>> >>> > >>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>> > >>>> java.lang.Thread.run(Thread.java:619) >>> > >>>> >>> > >>> >>> > >>> -------------------------------------------------------------------------------- >>> >>> > >>>> >>> > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>> > >>>> ServiceDispatcher.java:543:ERROR] Error in Service >>> > >>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, >>> Falta >>> > >>>> Teléfono de Contacto >>> > >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>> > >>>> TransactionUtil.java:338:ERROR] >>> > >>>> ---- exception report >>> > >>>> ---------------------------------------------------------- >>> > >>>> [TransactionUtil.rollback] >>> > >>>> Exception: java.lang.Exception >>> > >>>> Message: Stack Trace >>> > >>>> ---- stack trace >>> > >>>> --------------------------------------------------------------- >>> > >>>> java.lang.Exception: Stack Trace >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) >>> >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) >>> >>> > >>>> >>> > >>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) >>> > >>>> >>> > >>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>> > >>>> >>> > >>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>> >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>> >>> > >>>> >>> > >>> >>> > >>> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>> >>> > >>>> >>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>> > >>>> >>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>> > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>> > >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>> >>> > >>>> >>> > >>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>> >>> > >>>> >>> > >>> >>> > >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>> >>> > >>>> >>> > >>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>> > >>>> java.lang.Thread.run(Thread.java:619) >>> > >>>> >>> > >>> >>> > >>> -------------------------------------------------------------------------------- >>> >>> > >>>> >>> > >>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ >>> > >>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] >>> transaction >>> > >>>> rolled back >>> > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>> > >>>> ServiceDispatcher.java:599:INFO ] Sync service >>> > >>>> [traditional#JF/createUpdateCustomerAndShippingAddress] >>> finished in >>> > >>> [112] >>> > >>>> milliseconds with response [{errorMessageList={Area code is >>> missing, >>> > >>> Falta >>> > >>>> Teléfono de Contacto}, responseMessage=error}] >>> > >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>> > >>>> RequestHandler.java:639:INFO ] Ran Event >>> > >>>> [service:#createUpdateCustomerAndShippingAddress] from >>> [request], >>> > result >>> > >>> is >>> > >>>> [error] >>> > >>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ >>> > >>>> RequestHandler.java:425:ERROR] Request >>> createUpdateShippingAddress >>> > >>> caused an >>> > >>>> error with the following message: {Area code is missing, Falta >>> > Teléfono >>> > >>> de >>> > >>>> Contacto} >>> > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>> > >>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: >>> Response >>> is >>> > a >>> > >>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>> > >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>> > >>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: >>> > >>>> requestUri=json overrideViewUri=null >>> > >>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>> > >>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>> > >>>> RequestHandler.java:639:INFO ] Ran Event >>> > >>>> >>> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] >>> > >>> from >>> > >>>> [request], result is [success] >>> > >>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ >>> > >>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, >>> > >>> ServerHitBin >>> > >>>> delegatorName=default#JF >>> > >>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ >>> > >>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for >>> > >>> [ServerHitBin]; >>> > >>>> curSeqId=53390, maxSeqId=53400, bankSize=10 >>> > >>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ >>> > >>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] >>> Request >>> > >>> Done- >>> > >>>> total:0.386,since last([createUpdateShip...):0.386]] >>> > >>>> >>> > >>>> >>> > >>>> >>> > >>> >>> > >>> ----------------------------------------------------------------------------------------------- >>> >>> > >>>> >>> > >>>> After a bit of investigation I found this: >>> > >>>> >>> > >>>> The event 'createUpdateCustomerAndShippingAddress' is >>> returning an >>> > error >>> > >>> as >>> > >>>> a result but since the request is chained (with a json >>> request) the >>> > >>>> controller takes the response from the event >>> > >>>> >>> 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' >>> > >>> which >>> > >>>> is always 'success'. So that's why I figure out the ajax error >>> handler >>> > >>> is >>> > >>>> never invoked. >>> > >>>> >>> > >>>> What do you think? >>> > >>>> >>> > >>>> For further details, I am using a 3 months old trunk version >>> with >>> > MySql. >>> > >>>> I've checked out the latest version >>> > >>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, >>> still >>> > the >>> > >>> same >>> > >>>> code as I have. >>> > >>>> >>> > >>>> Thanks in advance. >>> > >>>> >>> > >>> >>> > >> >>> > >> >>> > >> >>> > >> -- >>> > >> ----- >>> > >> >>> > >> Jonatan Soto >>> > >> >>> > > >>> > > >>> > > >>> > > -- >>> > > ----- >>> > > >>> > > Jonatan Soto >>> > >>> > >>> >>> >>> -- >>> ----- >>> >>> Jonatan Soto >>> >> >> >> >> -- >> ----- >> >> Jonatan Soto >> > > |
Free forum by Nabble | Edit this page |