Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Name: nt126004 Date: 09/04/2002 FULL PRODUCT VERSION : java version "1.4.0_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03) Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode) FULL OPERATING SYSTEM VERSION : Linux 2.4.18-5 glibc-2.2.5-36 red hat 7.3 A DESCRIPTION OF THE PROBLEM : When using java.beans.XMLEncoder in a java web start application, persistence delegates are ignored. The attached code is a short (25 line) program that creates an object, creates an XMLEncoder writing to System.out, adds a persistence delegate, and writes the object. When run as an application, this works perfectly. When run with java web start, the exact same jar file emits an error because the persistence delegate is ignored. I have the application set up as a java web start program at http://www.igoweb.org/~wms/comp/xetest/ to make it easier to see this behavior. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1. Start up java web start; enable logging or enable java console (directions to do this in the web page mentioned below) 2. Visit http://www.igoweb.org/~wms/comp/xetest/ 3. Download the jar file 4. Run jar file locally with "java -jar xetest.jar"; observe output. 5. Run same jar file by java web start from same web page as above 6. Note the output of the java web start program EXPECTED VERSUS ACTUAL BEHAVIOR : Expected: The two should produce exactly the same output. There is no code in the application that should be different under java web start and a normal application. Actual: When run with "java -jar xetest.jar", the object is properly encoded and sent to System.out. When run with java web start, as error is printed and the object is not properly encoded. My tests have shown that the problem is that the reason for the error is that the persistence delegate is ignored. ERROR MESSAGES/STACK TRACES THAT OCCUR : Output of application (correct): <?xml version="1.0" encoding="UTF-8"?> <java version="1.4.0_01" class="java.beans.XMLDecoder"> <object class="XETest"> <int>5</int> </object> Output of java web start (incorrect): Java Web Start Console, started Fri Aug 09 09:33:00 PDT 2002 Java 2 Runtime Environment: Version 1.4.0 by Sun Microsystems Inc. java.lang.Exception: discarding statement XMLEncoder0.writeObject(XETest0); Continuing ... <?xml version="1.0" encoding="UTF-8"?> <java version="1.4.0" class="java.beans.XMLDecoder"> Note that the error appears above, and the object is not emitted. Unfortunately the full exception trace is not given by the XMLEncoder. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.beans.*;wabi333 public class XETest { private int value; public XETest(int value) { this.value = value; } public int getValue() { return(value); } public static void main(String args[]) { Object testObj = new XETest(5); XMLEncoder e = new XMLEncoder(System.out); e.setPersistenceDelegate( XETest.class, new DefaultPersistenceDelegate(new String[] {"value"})); e.writeObject(testObj); e.flush(); } } ---------- END SOURCE ---------- CUSTOMER WORKAROUND : None known. (Review ID: 160587) ======================================================================
|