Monday, April 16, 2007

DWR problem: InboundVariable error when combined with prototype.js

I'm using DWR at work and it's an excellent tool for AJAX (easily doing RPC from the client browser in JavaScript back to the Java Server). It also has good enough integration with Spring, which is a plus.

But for quite some time, we've had errors popping up in our logs every time we sent a JavaScript object to over DWR. The errors would look something like this:

2007-03-07 03:56:14,783 [ERROR] InboundVariable - Found reference to variable named 'c0-e6', but no variable of that name could be found.

To keep a long story short, if you happen to use the prototype.js library, it adds a function called 'extend' to the prototype of Object, so all objects have it. For some reason, DWR tries to marshal that 'extend' function as a property, but fails (it's a function), the the POST request that DWR sends, the 'extend' property is specified, but doesn't have a corresponding value.

In our case, we didn't acutally use prototype at that point, so we removed the
<script src="prototype-x.y.x.js"> from our JSP pages and the error was gone. If you need to fix this problem, but want to keep using prototype.js, you'll probably have to remove the 'extend' property from objects you send using DWR (or set the property to null).

BTW, if you ask me - it's a bug in DWR, since functions should not be marshaled. I'm using DWR 1.1.3, so this might have been fixed in 1.1.4, but I didn't see too much information about this using the almighty search engine.

How the problem was found
I used the LiveHttpHeaders extension for FireFox, and captured a DWR call. It seems very straightforward:
POST /Console/dwr/exec/XXXSearch.handleAddOrUpdate.dwr HTTP/1.1
Host: localhost:8085
User-Agent: Mozilla/5.0 (...) Gecko/20070216 Firefox/
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9...
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Content-Type: text/plain
Content-Length: 393
Cookie: JSESSIONID={don't tell}; Country=US; Language=en
Pragma: no-cache
Cache-Control: no-cache
c0-param1=Object:{currRow:reference:c0-e1, factory:reference:c0-e2,
orCondition:reference:c0-e3, cond:reference:c0-e4,
values_0:reference:c0-e5, extend:reference:c0-e6}
The request reminded me that DWR calls can be batched (hence the callCount field), and all the c0-{name} arguments describe call number 0, I assume I would have seen c1-{name} if I had more calls in this request.
I've also sent two parameters. The first (co-param0) is a boolean. The second (c0-param1) is complex, so it references other entries in the request, called c0-e{num}.
It's easy to see that 'extend' references 'c0-e6', that doesn't exist in the request.
I didn't know why 'extend' was there - I didn't send it, so I tried a short HTML with a DWR request, and indeed, it didn't send an 'extend' as part of the object I sent. Now, it was obvious this is done by one of the many JS files included in our real application page, and a quick search revealed the offender.


Jerry said...

cheap wedding gowns,
discount bridal gowns,
China wedding dresses,
discount designer wedding dresses,
China wedding online store,
plus size wedding dresses,
cheap informal wedding dresses,
junior bridesmaid dresses,
cheap bridesmaid dresses,
maternity bridesmaid dresses,
discount flower girl gowns,
cheap prom dresses,
party dresses,
evening dresses,
mother of the bride dresses,
special occasion dresses,
cheap quinceanera dresses,
hot red wedding dresses

I love golf and fashion handbags said... is a professional golf clubs and golf drivers store selling the highest quality golf club sets. Buy brand new golf clubs and golf drivers with huge discount, including Callaway golf clubs and Callaway golf drivers, TaylorMade golf clubs and TaylorMade golf drivers, Ping golf clubs and Ping golf drivers, Titleist golf clubs and Titleist golf drivers and more brands!
Welcome to, Callaway Golf Drivers Callaway Golf Iron Sets x22 Callaway Irons, Ping G15, Mizuno MP57 Online Store

I love golf and fashion handbags said... offers remote control toys (RC Toys), remote control helicopter, remote control helicopters, remote control car, remote control cars, remote control airplane, remote control airplanes,popular brands include Art-Tech, Colco, E-Sky, HSP, Nine Eagles, Vantex, Smartech and Walkera. Visit the best remote control toys store today and find your favourite rc airplanes and cars.

I love golf and fashion handbags said...

P90X Fitness DVD

I love golf and fashion handbags said...

I love tv shows and are glad to watch tv shows, espeically tv shows on dvd. With the creation dvd of one the greatest inventions box set in the past few years dvd box set, DVR, we now have the ability tv shows on dvd to record and watch any television show dvd set whenever we want. Besides our buy dvd complete seasons favorite sports buy dvd games, our weekly buy box set shows are where most men invest quality buy dvd box set couch time. We have listed some of the most popular shows buy dvd set that you should check out when you are not watching Desperate Housewives cheap dvd set reruns with your girlfriend.

sports said...

china wholesale
unlocked cell phones
wholesale cell phones
china phone

kids wall stickers
stickers for wall
wall sticker decal
wall stickers
round tablecloth
vinyl tablecloths
linens tablecloths
fashion bedding
bath and bed
bath curtains
kitchen faucet
bathroom faucet
shower faucet
baby bedding
bed in a bag
home bedding
kids bedding

wedding jewelry
wedding accessories
wedding dresses
cheap dress shoes
discount handbags
women's shoes
women's handbags
id lanyard

unlocked cell phones
mp3 players
digital camera
digital picture frames
flat tv
lcd tv
hd tv
portable GPS
GPS navigation
bluetooth gps

travel luggage
camping tents
sleeping bag
car gps
car tires
car seat cover

sexual health
health plan

wholesale lots

Pink Love said...

1ed hardy
ed hardy jeans
ed hardy swimwear
ed hardy hoodies
ed hardy christian audigier
ed hardy women Leggings
ed hardy long sleeve polo

2nba jerseys
nfl jerseys
mlb jerseys

nhl jerseys

Los Angeles Lakers jerseys
New York Jets jerseys

3coach bags
coach handbags
Coach Claire Bags

coach wallets coach sunglasses Coach Luggage Bags Coach HOBO Bags Coach Ergo Bags

Coach Sabrina Bags

cheap Coach Backpacks
Coach Shoulder Bags


ghd purple
ghd dark
ghd pure
ghd pretty in pink
rare ghd
GHD IV Styler
ghd mini styler
ghd mk4 gold styler
ghd pink

hxl said...

baby bedding
bed in a bag
sexual health
health plan
beauty cosmetics
skin care
health fitness sports
mens health
fashion shoes reviews
best air shoes
best women shoes
fashion dress
comfortable man shoes
fashion shoes
sneakers reviews
top ten boots
boots of world
rosetta stone
boots classic
wholesale lots
china wholesaler
china wholesale
wedding dress
lightinthebox reviews
fashion shoes







tn requin said...

sleeping bag
travel luggage
car gps
car parts
GPS navigation
portable GPS
lcd tv
flat tv
digital picture frames
unlocked cell phones
wedding dresses
wedding jewelry
chaussures mode
chaussures Femmes
women's shoes
round tablecloth
discount handbags
chaussures sport
chaussures pas cher
fashion bedding
id lanyard
creative gadgets
gift ideas
kids wall stickers
wall stickers
bath curtains
kitchen faucet
bathroom faucet

dfadf said...

The Tax Return Crack-Up<2>
I was not shocked because this was old news -- practically ancient, in fact. In R. Microsoft Office Emmett Tyrrell, Office 2010 Jr.'s most recent book The Clinton Microsoft Office 2010 Crack-
Up, page fiv Office 2007 e, paragraph two, we learn that in Bill Clinton's "first four years out of the White H Microsoft Office 2007 ouse, he ea Office 2010 key rned over Office 2010 download $43 million Office 2010 Professional after
expenses... Microsoft outlook "
The next Outlook 2010 page directs Windows 7 us to Appendix Microsoft outlook 2010 I, a list of the conniving couple's fees for speeches and book royalties and other income. The first

elizabeth bernot said...

Costa Rica Fishing

Fishing Costa Rica

Mary said...

Hello, How do I get in touch with you? There is no email or contact info listed .. please advise .. thanks .. Mary. Please contact me maryregency at gmail dot com