• Welcome to KonaKart Community Forum. Please login or sign up.
 

Error when the order is saved

Started by David, December 14, 2007, 08:12:24 am

Previous topic - Next topic

David

Hi again  ;D

I have a little problem when I insert an order. I modified in CheckoutConfirmationSubmitAction.java a lot of things:

  • in the OrderProducts I save my own FinalPriceExTax, FinalPriceIncTaxPrice and Price

  • in the CheckOutOrder I use the custom1 field, and modify TotalExTax, TotalIncTax and the PaymentMethod field

  • I also modify the OrderTotals array using my own title, text and value



This is the error I've got when the order is saved:

Exception Name = com.konakart.app.KKException
Exception Message = org.apache.torque.TorqueException: java.lang.ArrayIndexOutOfBoundsException
Exception Stack Trace =
at com.konakart.app.KKEng.saveOrder(KKEng.java:1404)
at com.konakart.al.OrderMgr.saveOrder(OrderMgr.java:301)
at com.imatia.elastic.clienteTV.actions.CheckoutConfirmationSubmitAction.execute(CheckoutConfirmationSubmitAction.java:276)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)

Exception Cause = org.apache.torque.TorqueException
at org.apache.torque.util.BasePeer.throwTorqueException(BasePeer.java:106)
at org.apache.torque.util.BasePeer.insertOrUpdateRecord(BasePeer.java:653)
at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:531)
at com.konakart.bl.OrderMgr.saveOrder(OrderMgr.java:358)
at com.konakart.app.KKEng.saveOrder(KKEng.java:1397)
at com.konakart.al.OrderMgr.saveOrder(OrderMgr.java:301)
at com.imatia.elastic.clienteTV.actions.CheckoutConfirmationSubmitAction.execute(CheckoutConfirmationSubmitAction.java:276)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)


the problem is that I don't have these files: com.konakart.app.KKEng.saveOrder com.konakart.al.OrderMgr.saveOrder and I can't see where is the error. If somebody could see where is the problem in the original source or give me some clue...

Thanks in advance

David

ryan

Hi David,

From the exception trace it's not completely obvious. Maybe you can do a toString() on the order and send that to us. Also a toString() on the OrderProducts would be handy.

One thing to bear in mind is that in the current version we increased the size of the model field in the orders_products table to make it match the size in the products table.

ALTER TABLE orders_products MODIFY products_model VARCHAR(64);

Good luck.

David

Hi,

I don't know what I did but now it seems to work ??? maybe I had an old version of the file.

Sorry for taking your time



David

David

Hi,

I've got the same error again >:(

I don't know what could be happening, I modified the database like you said but it didn't work. Here is the order.toString() maybe I fill some data in a wrong way


Quoteid = 0

customerId = 4
customerName = No disponible david 107
customerCompany = asdfrewq
customerStreetAddress = Direccion de david
customerSuburb = s
customerCity = localidad de david
customerPostcode = 36400
customerState = A Coruña
customerCountry = Spain
customerTelephone = 987654321
customerEmail = david107
customerAddrFormatId = 0
customerAddrFormatTemplate = null
customerFormattedAddress = <![CDATA[asdfrewq<br>No disponible david 107<br>Direccion de david<br>s<br>localidad de david, 36400<br>A Coruña, Spain]]>

deliveryName = No disponible david 107
deliveryCompany = asdfrewq
deliveryStreetAddress = Direccion de david
deliverySuburb = s
deliveryCity = localidad de david
deliveryPostcode = 36400
deliveryState = A Coruña
deliveryCountry = Spain
deliveryAddrFormatId = 0
deliveryAddrFormatTemplate = null
deliveryFormattedAddress = <![CDATA[asdfrewq<br>No disponible david 107<br>Direccion de david<br>s<br>localidad de david, 36400<br>A Coruña, Spain]]>

billingName = No disponible david 107
billingCompany = asdfrewq
billingStreetAddress = Direccion de david
billingSuburb = s
billingCity = localidad de david
billingPostcode = 36400
billingState = A Coruña
billingCountry = Spain
billingAddrFormatId = 0
billingAddrFormatTemplate = null
billingFormattedAddress = <![CDATA[asdfrewq<br>No disponible david 107<br>Direccion de david<br>s<br>localidad de david, 36400<br>A Coruña, Spain]]>

paymentMethod = 01
ccType = null
ccOwner = null
ccNumber = null
ccExpires = null
lastModified = null
status = 1
statusText = Pending
dateFinished = null
currencyCode = EUR
currencyValue = 1
totalExTax = 23.10000000000000142108547152020037174224853515625
totalIncTax = 23.10000000000000142108547152020037174224853515625
tax = 0.00
paymentDetails = PaymentDetail:
code = cod
title = Contra Reembolso
description = Contra Reembolso
sortOrder = 0
postOrGet = null
requestUrl = null
orderStatusId = 0
paymentType = 1
ccNumber = null
ccCVV = null
ccExpiryMonth = null
ccExpiryYear = null
ccOwner = null
ccPostcode = null
ccStreetAddress = null
showType = true
showAddr = true
showPostcode = true
showCVV = true
custom1 = null
custom2 = null
custom3 = null
custom4 = null
custom5 = null

custom1 = T. General
custom2 = null
custom3 = null
custom4 = null
custom5 = null
promotionIds = null
couponIds = null
OrderTotal = OrderTotal:
id = 0
orderId = 0
title = Subtotal:
text = 23.1 €
value = 23.10000000000000142108547152020037174224853515625
sortOrder = 1
className = ot_subtotal

OrderTotal = OrderTotal:
id = 0
orderId = 0
title = Total:
text = <b>23.1 €</b>
value = 23.10000000000000142108547152020037174224853515625
sortOrder = 4
className = ot_total

OrderStatusHistory = Order Status History:
id       = 0
orderId = 0
orderStatusId     = 0
orderStatus     = null
dateAded     = null
customerNotified     = false
comments     =



Regards

David

pete

Hi,

Can you do a .toString() on the OrderProducts as well ?

Thanks,

Pete

David

Hi,

I still don't understand this error, in other computer (with a different configuration, but the same sources) I don't have any error, I'm trying now with SQL Server, maybe this can be the problem ¿?

I tried to do a .toString() of the OrderProducts, and I've got similar information in both PCs, but I'm thinking that I'm doing something wrong.

I do this in CheckoutConfirmationSubmit.java:

QuotecheckoutOrder.getNumProducts() -> 0 returned ¿?
checkoutOrder.getOrderProducts().toString() -> [Lcom.konakart.app.OrderProduct;@4e37fb


I also have this error in the console:
QuoteERROR (Transaction.java:rollback:193) An attempt was made to rollback a transaction but the database did not allow the operation to be rolled back.
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The DBMS returned an unspecified error.
   at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
   at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
   at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
   at com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.processReplyToken(Unknown Source)
   at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
   at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.rollbackTransaction(Unknown Source)
   at com.microsoft.jdbc.base.BaseConnection.rollback(Unknown Source)
   at org.apache.commons.dbcp.cpdsadapter.ConnectionImpl.rollback(ConnectionImpl.java:315)
   at org.apache.torque.util.Transaction.rollback(Transaction.java:187)
   at org.apache.torque.util.Transaction.safeRollback(Transaction.java:223)
   at com.konakart.bl.OrderMgr.saveOrder(OrderMgr.java:399)
   at com.konakart.app.KKEng.saveOrder(KKEng.java:1397)
   at com.konakart.al.OrderMgr.saveOrder(OrderMgr.java:301)
   at com.imatia.elastic.clienteTV.actions.CheckoutConfirmationSubmitAction.execute(CheckoutConfirmationSubmitAction.java:307)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
   at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)


any idea??


pete

Hi David,

For the OrderProducts you need to loop through them and then do a toString() on each one.

For the database it looks like you are using a combination of driver /  database that doesn't allow rollbacks. The saving of an order consists of writing data to a few database tables and the writes are performed in a transaction.

-Pete

David

Ok, this is the OrderProduct:

id = 0
productId = 13
model = 28099
name = Toner para Epson FX300 cambiada descripcion
price = 23.87
finalPriceExTax = 23.87
finalPriceIncTax = 23.87
taxRate = 0
tax = 0.00
quantity = 1
type = 0

maybe the taxRate is needed??

pete

Hi David,

Could you just check the OrderId attribute of the OrderProduct to make sure that an order exists in the database with that id. Unfortunately it doesn't get printed out in the toString method. Another thing that you could do is to edit konakart-logging.properties in the classes directory and set :

log4j.logger.org.apache.torque.util.BasePeer  = DEBUG  instead of WARN

Then reboot Tomcat and see whether you get any more detailed info in the log.

-Pete

David

Hi again,

I'm thinking that this problem could be with the database because i'm still getting this error when I do the order:

QuoteERROR (Transaction.java:rollback:193) An attempt was made to rollback a transaction but the database did not allow the operation to be rolled back.
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The DBMS returned an unspecified error.


I`m using SQLServer 2000 with this driver: SQL Server 2000 Driver for JDBC Service Pack 3, is this configuration compatible with KonaKart?

I also checked what you said,

op.getOrderId() returns 0

and also attach a piece of the the log with the error in the database

I don't know what happens, maybe I'll try to run it with MySQL, I'm running out of ideas  ;D

pete

Hi David,

From your log it looks like it fails when writing into the orders_total record (look at your log just before the exception). Unfortunately the actual exception from SQLServer is lost because it throws another exception during the rollback since it doesn't support rollbacks (I recommend you use a database / driver combination that does support rollbacks). What you could try doing is to insert the same data using hand written SQL to see why SQLServer is complaining.

Pete

David

Ok, I`ll try to insert the data using SQL, anyway I'm sure my database supports rollbacks because another application is using it and it uses rollbacks to do a lot of operations.

Thanks for all your support

David

kate

Hi David,

But the other application may not be using the driver/db in the same way and you may be running into a bug with the driver/db combination?  There have been rollback errors with SQL Server drivers in the past.  One thing you could try relatively easily is to try the jTDS driver which we include for SQL Server support in our latest (2.2.1.0) kits. 

Kate

David

Eureka!!

I found the problem. The SQL Server doesn't admit numbers with more precision than 38, finally I only had to do a .setScale(35, RoundingMode.HALF_UP) to the BigDecimal before saving it. It's like a job, I spent a lot of days with this thing but now it works  ;D

A lot of thanks for your help

David