[plt-scheme] Serializing/deserializing in a servlet

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

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

#lang scheme

(require scheme/serialize

(define-serializable-struct test-struct

(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

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

(define (start request)

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?
-Eddie Sullivan

Posted on the users mailing list.