I can't really help you on that one, I've never experienced this problem.

But here is some piece of code that works for me :
// Create a stream to the output file.
ByteArrayOutputStream output_stream = new ByteArrayOutputStream();
// Create an XML-output stream.
NSXMLOutputStream xml_stream = new NSXMLOutputStream(output_stream);
// Write the data.
xml_stream.writeObject(d); // d being a NSMutableDictionary
// Close the streams.
xml_stream.flush(); // not really needed, but doesn't hurt
xml_stream.close();
s = output_stream.toString();
output_stream.close();

- jfv

Le 05-12-14, à 11:39, Robert Walker a écrit :

You are correct after inserting the null check the error has moved to line 58:  <x-tad-bigger>xmlos = </x-tad-bigger><x-tad-bigger>new</x-tad-bigger><x-tad-bigger> NSXMLOutputStream(os); <<--- line 58</x-tad-bigger>
New exception:

[2005-12-14 11:35:14 EST] <main> java.lang.ExceptionInInitializerError
at ProcessorService.serialize(ProcessorService.java:58)
at Application.<init>(Application.java:52)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at com.webobjects.appserver.WOApplication.main(WOApplication.java:323)
at Application.main(Application.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.webobjects._bootstrap.WOBootstrap.main(WOBootstrap.java:71)
Caused by: java.lang.IllegalArgumentException: No attributes are implemented
at org.apache.crimson.jaxp.DocumentBuilderFactoryImpl.setAttribute(DocumentBuilderFactoryImpl.java:93)
at com.webobjects.foundation.xml.NSXMLOutputStream.<clinit>(NSXMLOutputStream.java:445)
... 15 more

On Dec 14, 2005, at 11:27 AM, Jean-François Veillette wrote:

hmmm ...
if xmlos is null, would it be that the exception is thrown before the assignation ? so the error would either on :
  <x-tad-smaller>os = </x-tad-smaller>
<x-tad-bigger>new</x-tad-bigger><x-tad-bigger> BufferedOutputStream(</x-tad-bigger><x-tad-bigger>new</x-tad-bigger><x-tad-bigger> FileOutputStream(fileName));</x-tad-bigger>
if there is a problem creating the bufferedOutputStream (bad file output stream).

or if os is valid, it would be on that line :
  <x-tad-smaller>xmlos = </x-tad-smaller>
<x-tad-bigger>new</x-tad-bigger><x-tad-bigger> NSXMLOutputStream(os);</x-tad-bigger>

If there is a problem on one of those lines, then the variables (os, xmlos) won't be initialized, and entering the finally will throw another exception with the actual code.
In the finally clause, wrap the 'flush'/'close' in a null condition 'if(xmlos != null) {...}'

Look at the error logs, there must be something in there that catch(...) reported.

- jfv

Le 05-12-14, à 11:16, Robert Walker a écrit :

Oops sorry again. Ignore last posting....

Line 70 is actually

  <x-tad-bigger>xmlos.flush();</x-tad-bigger>
On Dec 14, 2005, at 11:06 AM, Jean-François Veillette wrote:

  at ProcessorService.serialize(ProcessorService.java:70)

where is line 70 ?

- jfv

Le 05-12-14, à 11:01, Robert Walker a écrit :

I need to serialize some objects for use in web services and am getting the following exception for this example code:

Error occurs on both Xcode 2.0/WO 5.2.4 and Xcode 2.2/WO 5.3.1... Simply calling this static method from Application class as a test. Doesn't seem to matter where it's called: also tried calling it from an action method on Main page.

  <x-tad-smaller>public</x-tad-smaller>
<x-tad-bigger> </x-tad-bigger><x-tad-bigger>static</x-tad-bigger><x-tad-bigger> </x-tad-bigger><x-tad-bigger>void</x-tad-bigger><x-tad-bigger> serialize() {</x-tad-bigger>
  <x-tad-smaller>String fileName = </x-tad-smaller>
<x-tad-bigger>"/tmp/example.xml"</x-tad-bigger><x-tad-bigger>;</x-tad-bigger>
  <x-tad-smaller>BufferedOutputStream os = </x-tad-smaller>
<x-tad-bigger>null</x-tad-bigger><x-tad-bigger>;</x-tad-bigger>
  <x-tad-smaller>NSXMLOutputStream xmlos = </x-tad-smaller>
<x-tad-bigger>null</x-tad-bigger><x-tad-bigger>;</x-tad-bigger>
 
  <x-tad-smaller>try</x-tad-smaller>
<x-tad-bigger> {</x-tad-bigger>
  <x-tad-smaller>// File output stream</x-tad-smaller>
  <x-tad-smaller>os = </x-tad-smaller>
<x-tad-bigger>new</x-tad-bigger><x-tad-bigger> BufferedOutputStream(</x-tad-bigger><x-tad-bigger>new</x-tad-bigger><x-tad-bigger> FileOutputStream(fileName));</x-tad-bigger>
 
  <x-tad-smaller>// XML output stream</x-tad-smaller>
  <x-tad-smaller>xmlos = </x-tad-smaller>
<x-tad-bigger>new</x-tad-bigger><x-tad-bigger> NSXMLOutputStream(os);</x-tad-bigger>
 
  <x-tad-smaller>// Write the data</x-tad-smaller>
  <x-tad-smaller>xmlos.writeObject(</x-tad-smaller>
<x-tad-bigger>"Hello World!"</x-tad-bigger><x-tad-bigger>);</x-tad-bigger>
  <x-tad-smaller>xmlos.writeInt(</x-tad-smaller>
<x-tad-bigger>5</x-tad-bigger><x-tad-bigger>);</x-tad-bigger>
  <x-tad-smaller>} </x-tad-smaller>
<x-tad-bigger>catch</x-tad-bigger><x-tad-bigger> (Exception e) {</x-tad-bigger>
  <x-tad-smaller>NSLog.err.appendln(</x-tad-smaller>
<x-tad-bigger>"Exception encountered: "</x-tad-bigger><x-tad-bigger> + e.getMessage());</x-tad-bigger>
  <x-tad-smaller>if</x-tad-smaller>
<x-tad-bigger> (NSLog.debugLoggingAllowedForLevel(NSLog.DebugLevelCritical)) {</x-tad-bigger>
  <x-tad-smaller>NSLog.debug.appendln(e);</x-tad-smaller>
  <x-tad-smaller>}</x-tad-smaller>
<x-tad-bigger> </x-tad-bigger> <x-tad-smaller>} </x-tad-smaller>
<x-tad-bigger>finally</x-tad-bigger><x-tad-bigger> {</x-tad-bigger>
  <x-tad-smaller>try</x-tad-smaller>
<x-tad-bigger> {</x-tad-bigger>
  <x-tad-smaller>// close the streams</x-tad-smaller>
  <x-tad-smaller>xmlos.flush();</x-tad-smaller>
  <x-tad-smaller>xmlos.close();</x-tad-smaller>
  <x-tad-smaller>os.close();</x-tad-smaller>
  <x-tad-smaller>} </x-tad-smaller>
<x-tad-bigger>catch</x-tad-bigger><x-tad-bigger> (Exception e) {</x-tad-bigger>
  <x-tad-smaller>NSLog.err.appendln(</x-tad-smaller>
<x-tad-bigger>"Exception encountered: "</x-tad-bigger><x-tad-bigger> + e.getMessage());</x-tad-bigger>
  <x-tad-smaller>if</x-tad-smaller>
<x-tad-bigger> (NSLog.debugLoggingAllowedForLevel(NSLog.DebugLevelCritical)) {</x-tad-bigger>
  <x-tad-smaller>NSLog.debug.appendln(e);</x-tad-smaller>
  <x-tad-smaller>}</x-tad-smaller>
  <x-tad-smaller>}</x-tad-smaller>
  <x-tad-smaller>}</x-tad-smaller>
  <x-tad-smaller>}</x-tad-smaller>
------------------------
Exception:

[2005-12-14 10:56:29 EST] <main> java.lang.NullPointerException
  at ProcessorService.serialize(ProcessorService.java:70)
  at Application.<init>(Application.java:52)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
  at java.lang.Class.newInstance0(Class.java:308)
  at java.lang.Class.newInstance(Class.java:261)
  at com.webobjects.appserver.WOApplication.main(WOApplication.java:323)
  at Application.main(Application.java:19)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:324)
  at com.webobjects._bootstrap.WOBootstrap.main(WOBootstrap.java:71)

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/jean_francois_veillette%40yahoo.ca

This email sent to [EMAIL PROTECTED]
http://www.freeiPods.com/?r=21419063

http://www.freeiPods.com/?r=21419063

http://www.freeiPods.com/?r=21419063
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Reply via email to