Re: Help with NSXMLOutputStream/NSSMLInputStream
Re: Help with NSXMLOutputStream/NSSMLInputStream
- Subject: Re: Help with NSXMLOutputStream/NSSMLInputStream
- From: Jean-François Veillette <email@hidden>
- Date: Wed, 14 Dec 2005 11:27:07 -0500
hmmm ...
if xmlos is null, would it be that the exception is thrown before the assignation ? so the error would either on :
os = new BufferedOutputStream(new FileOutputStream(fileName));
if there is a problem creating the bufferedOutputStream (bad file output stream).
or if os is valid, it would be on that line :
xmlos = new NSXMLOutputStream(os);
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
xmlos.flush();
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.
public static void serialize() {
String fileName = "/tmp/example.xml";
BufferedOutputStream os = null;
NSXMLOutputStream xmlos = null;
try {
// File output stream
os = new BufferedOutputStream(new FileOutputStream(fileName));
// XML output stream
xmlos = new NSXMLOutputStream(os);
// Write the data
xmlos.writeObject("Hello World!");
xmlos.writeInt(5);
} catch (Exception e) {
NSLog.err.appendln("Exception encountered: " + e.getMessage());
if (NSLog.debugLoggingAllowedForLevel(NSLog.DebugLevelCritical)) {
NSLog.debug.appendln(e);
}
} finally {
try {
// close the streams
xmlos.flush();
xmlos.close();
os.close();
} catch (Exception e) {
NSLog.err.appendln("Exception encountered: " + e.getMessage());
if (NSLog.debugLoggingAllowedForLevel(NSLog.DebugLevelCritical)) {
NSLog.debug.appendln(e);
}
}
}
}
------------------------
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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden