Hi.

I'm using spinrdf-1.0.2.jar, and I'd like to be able to run it without
any connection to the Internet.  Currently that's not possible because
of a typo in the SP.java and SPIN.java source files.  These two files
have the following code snippets:

SP.java
======
237         public static Model getModel() {
238                 if(model == null) {
239                         model = ModelFactory.createDefaultModel
(ReificationStyle.Minimal);
240                         InputStream is = SP.class.getClassLoader
().getResourceAsStream("/etc/sp.owl");

SPIN.java
========
102     public static Model getModel() {
103             if(model == null) {
104                     model = ModelFactory.createDefaultModel
(ReificationStyle.Minimal);
105                     InputStream is = 
SPIN.class.getClassLoader().getResourceAsStream
("/etc/spin.owl");

It's the same bug, which appears on line 240 of SP and line 105 of
SPIN.  When you call the ClassLoader.getResourceAsStream, you mustn't
use a leading slash, otherwise typical URL handlers such as exist in
Java 1.6 fail to resolve the resource and return null.  Some
specialized URL handlers such as the
weblogic.utils.zip.ZipURLConnection class in WebLogic are able to
resolve such a reference, but the standard machinery in Java cannot do
it.  The specification of this method is horrendously vague in the
ClassLoader Javadoc, but the bottom line is that it won't work in most
Java environments.

To fix these bugs, I recommend using the different coding pattern that
appears in the SPL.java file, which uses the Class.getResourceAsStream
method instead.  That method is far better specified in its Javadoc,
and it succeeds in resolving a resource with a leading slash.  Here
are the proper replacement lines for SP.java:240 and SPIN.java:105,
respectively:

240                     InputStream is = 
SP.class.getResourceAsStream("/etc/sp.owl");
105                     InputStream is = SPIN.class.getResourceAsStream("/etc/
spin.owl");

The impact of this bug is that I cannot invoke the SPIN APIs if my
machine has no connection to the Internet.  Here's what happens:

======================= BEGIN STACK TRACE OF EXCEPTION
========================
Exception in thread "main" com.hp.hpl.jena.shared.JenaException:
java.net.UnknownHostException: spinrdf.org
        at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:91)
        at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:178)
        at org.topbraid.spin.vocabulary.SPIN.getModel(SPIN.java:107)
        at org.topbraid.spin.system.SPINModuleRegistry.init
(SPINModuleRegistry.java:113)
        at test.Main.main(Main.java:70)
Caused by: java.net.UnknownHostException: spinrdf.org
        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:513)
        at sun.net.www.protocol.http.HttpURLConnection$6.run
(HttpURLConnection.java:1368)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.net.www.protocol.http.HttpURLConnection.getChainedException
(HttpURLConnection.java:1362)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream
(HttpURLConnection.java:1016)
        at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:84)
        ... 4 more
Caused by: java.net.UnknownHostException: spinrdf.org
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:525)
        at java.net.Socket.connect(Socket.java:475)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
        at sun.net.www.http.HttpClient.New(HttpClient.java:306)
        at sun.net.www.http.HttpClient.New(HttpClient.java:323)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient
(HttpURLConnection.java:860)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect
(HttpURLConnection.java:801)
        at sun.net.www.protocol.http.HttpURLConnection.connect
(HttpURLConnection.java:726)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream
(HttpURLConnection.java:1049)
        at sun.net.www.protocol.http.HttpURLConnection.getHeaderField
(HttpURLConnection.java:2173)
        at java.net.URLConnection.getContentEncoding(URLConnection.java:496)
        at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:82)
        ... 4 more
========================= END STACK TRACE OF EXCEPTION
=========================

I reach this line of code after SPIN.java:105 returns null, so it
resorts to reading the model from the Internet URI (which fails since
I am behind a firewall).

Obviously I have fixed this bug in my local copy of SPIN, so I'm just
asking that you roll the fix into the next official release.

   -Dave

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TopBraid Composer Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/topbraid-composer-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to