[plt-scheme] Serializing/deserializing in a servlet

From: Eddie Sullivan (eddieSull at hotmail.com)
Date: Fri Nov 28 14:45:41 EST 2008

Hi.
The following simple code works well normally, but when run in a servlet 
causes a strange error:

#lang scheme

(require scheme/serialize
         web-server/servlet-env)

(define-serializable-struct test-struct
  (a))

(define (test-serialize)
  (let* ([s (make-test-struct
            "Eddie Sullivan")]
         [serialized-s (serialize s)]
         [new-s (deserialize serialized-s)])
    (display (format "test-serialize: Saved a: ~a" (test-struct-a
                                                    new-s)))))


(define (go)
  (serve/servlet start))

(define (start request)
  (test-serialize))


In DrScheme (Windows, vs 4.1.3), if I call (test-serialize), I see the 
expected result:

test-serialize: Saved a: Eddie Sullivan

On the other hand, if I call (go), I see the following error:

Servlet (@ /servlets/standalone.ss) exception:
test-struct-a: expects args of type <struct:test-struct>; given instance of 
a different <struct:test-struct>

Any tips?
Thanks.
-Eddie Sullivan





Posted on the users mailing list.