openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Cornia" <>
Subject Re: XMLEncoder not working?
Date Mon, 17 Dec 2007 14:43:34 GMT
The code is simply:

try {            Gene g = new GeneDAO().findById("BRCA1");
XMLEncoder e = new XMLEncoder(                new BufferedOutputStream(
new FileOutputStream("Test.xml")));            e.writeObject(g);
e.close();        } catch (Exception e) {            System.out.println(e);
e.printStackTrace();        }

The exception doesn┬╣t give much info:

java.lang.ClassNotFoundException:$myriad$common$Gene$pcsubclass Continuing ...
java.lang.Exception: XMLEncoder: discarding statement
XMLEncoder.writeObject(com$myriad$common$Gene$pcsubclass); Continuing ...

For Junit testing, I want to feed in objects that are pre-loaded, but not
from the database. My thought was to use XMLEncoder to generate a set of XML
files for the objects I want to feed into my database, then use XMLDecoder
to populate those objects in the unit tests separate from the database. This
way my test objects in Junit will always be consistent, and not depend on a

Maybe there is a better way for accomplishing what I am trying to do?


On 12/16/07 6:00 AM, "Patrick Linskey" <> wrote:

> Hi,
> That's actually a generated subclass of your POJO type.
> Can you provide a bit more information about what you're trying to do?
> A code snippet and the full stack trace would be helpful.
> I expect that doing deploy-time or compile-time enhancement would
> resolve the issue. Without more information about the use case, I'm
> not sure whether or not your behavior should be expected to work with
> runtime enhancement (what you're doing now; the implicit default
> outside a container), but I would guess that it should.
> -Patrick
> On Dec 14, 2007 2:22 AM, Ryan Cornia <> wrote:
>> I am trying to call XMLEncoder on a JPA annotated object. It fails with:
>> java.lang.ClassNotFoundException:
>> It seems to be trying to use reflection on the openjpa class, instead of my
>> POJO.
>> Anyone using XMLEnocder successfully? I would like to use it to create base
>> xml files I can re-load for testing. (Instead of doing testing against an
>> actual database, I want to load the objects from xml.)
>> Thanks,
>> Ryan

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message