Jacques Le Roux wrote:
> Adam,
> 
> I thought it was pretty simple to create an order in ecommerce, but
> forgot about the login as when testing I pretty always use
> DemoCustomer.
> 
> 1. Put a product in cart (anyone, I often use Tiny Chrome Widget)
> 2. Checkout, not using the one page checkout (both other methods show
> the error as I indicated before), as DemoCustomer. I prefer to
> use Quick checkout.
> 3. Use default address, any shipping method
> 
> You get an error
> org.ofbiz.webapp.event.EventHandlerException: Problems processing event:
> java.lang.NoSuchFieldError: shipItemInfo (shipItemInfo)
> 
> I thought it was related to USPS because I quickly look in log yesterday
> but I'm not sure now it the intial reason.
> 
> I could have debugged it but I prefer you to have a look at it because
> maybe you could find a more general error related to the changes you did
> between r712911and r712919

Ok, this is a stupid one.

The NoSuchFieldError is because you didn't clean, before compiling.  The
type of that field changed in ShoppingCart.CartShipInfo, from LinkedMap
to LinkedHashMap.

Once you fix that, then the real bug is shown.  Stupid thing.  In
CheckOutHelper.makeTaxContext, it iterates over
CartShipInfo.shipItemInfo, which used to be a LinkedMap, but is now a
LinkedHashMap.  LinkedMap, from commons-collections, has an overridden
get() method, that takes an int.  LinkedHashMap does not have such a
method.  So, it tries to call get(Object); java1.5 happily auto-boxes
the int to an Integer. However, shipItemInfo keys are of
ShoppingCartItem, so null is returned.  Things then go boom.

CheckOutHelper.calcAndAddTax has the same problem, expecting there to be
 a get(int).

This code is rather poorly written; it requires shipItemInfo to be a map
with an implict order.  I'd like to keep the change of shipItemInfo's
type to LinkedHashMap, but things aren't simple.

calcAndAddTax calls makeTaxContext.  This returns a Map, that contains
items that are of type List.  These lists are constructed by looping
over shipItemInfo, using the aforementioned get(int).  This particular
loop can be changed to be a standard Iterator, and just call
List.add(Object), instead of List.add(int, Object).

However, calcAndAddTax then loops over the constructed Lists, using an
int counter, then tries to fetch from the shipItemMap using get(int).

I've fixed it to be more collections friendly in 714082.

Reply via email to