Re: Issue with JxtaSocket example
Bruce Rosenthal <[email protected]>
| Newsgroups | gmane.comp.java.jxta.user |
|---|---|
| Message-ID | <[email protected]> |
So I have set the full canonical name as suggested, but it still throws
the NullPointerException because &is is still returning null.
public static void createConfig(File home, String name, boolean
server) {
try {
String fname = null;
if (server) {
fname = "ServerPlatformConfig.master";
} else {
fname = "C:\\jxtaApps\\PipeService\\PlatformConfig.master";
}
System.out.println("Config file is: " + fname);
InputStream is = getResourceInputStream(fname);
home.mkdirs();
PlatformConfig platformConfig = (PlatformConfig)
AdvertisementFactory.newAdvertisement(MimeMediaType.XMLUTF8, is);
is.close();
platformConfig.setName(name);
File newConfig = new File(home, "PlatformConfig");
OutputStream op = new FileOutputStream(newConfig);
StructuredDocument doc = (StructuredDocument)
platformConfig.getDocument(MimeMediaType.XMLUTF8);
doc.sendToStream(op);
op.close();
Bruce Rosenthal wrote:
> Yes, that can sometimes happen, though it shouldn't. It would be nice
> to figure out why the current coding approach is not working though,
> even though the focus is on the socket mechanism and not
> InputStreamReaders working as they should.
>
> FYI I have added a watch for the resource variable and a break on
> ClassLoader cl = JxtaSocketExample.class.getClassLoader();
>
> in the getResourceInputStream(String resource) {} method
>
> resource gets value = "PlatformConfig.master" //so that is likely the
> problem because there is no path.
>
> Mohamed Abdelaziz wrote:
>
>> I suggest you specify the full canonical path of the file instead.
>> IDE's usually alter the $CWD, which would result in the behavior
>> you're seeing.
>>
>> Mohamed
>>
>> Bruce Rosenthal wrote:
>>
>>> Unfortuneatly, I have it in $CWD, $CWD/.jxta, $CWD/client (just to
>>> cover my bases).
>>>
>>> I also tried forcing the issue by invoking InputStream is as follows:
>>>
>>> InputStream is =
>>> getResourceInputStream(System.getProperty("user.dir") + "\\" + fname);
>>>
>>> and that also doesn't work.
>>>
>>> I can show you vai a WebEx if you want.
>>>
>>> Mohamed Abdelaziz wrote:
>>>
>>>> sounds like "PlatformConfig.master" does not exist in $CWD
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [email protected]
>For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]