Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Making an URLConnection

Posted on 1998-05-18
8
Medium Priority
?
601 Views
Last Modified: 2008-02-01
I don't understand why the call to getResponseCode() below gives an UnsatisfiedLinkError.

          URL url = new URL(docName);
          HttpURLConnection checkURL =  (HttpURLConnection)url.openConnection();
          try {
            if (checkURL.getResponseCode() == 404)
            {
              System.err.println("Failed to get doc " + docName);
              return;
            }
          } catch (UnsatisfiedLinkError ule) {
            System.err.println("Unable to resolve docname " + docName);
            return;
          } catch (NullPointerException npe) {
            System.err.println("Can't get doc " + docName);
            return;
          }

If I understand the docs correctly, openConnection() should call connect() for me.
The other weird thing is that this code ran fine under 1.1.2, but fails under 1.1.3 and later.
0
Comment
Question by:wex
  • 4
  • 4
8 Comments
 
LVL 5

Expert Comment

by:msmolyak
ID: 1221165
Is it possible that you have multiple JDK  installations on your machine with environment variables pointing to the more than one at a time. For example your CLASSPATH may point to JDK1.1.2\lib\classes.zip while your PATH may contain JDK1.1.3\bin directory. That may cause the described behaviour. (The DLL on your path does not contain the exact native function the JVM is trying to invoke).
0
 
LVL 1

Author Comment

by:wex
ID: 1221166
Yeah, I think that's the right track, but I'm confused why it's happening.  I'm on a UNIX box
and the only relevant thing on my PATH is /usr/java/bin

My CLASSPATH includes only the directories relevant to my project; I'm depending on
java to add the proper directories for its own .class files.  Is that an error?
0
 
LVL 5

Expert Comment

by:msmolyak
ID: 1221167
It's hard for me to speak about UNIX since I do my development on NT. Each JDK come with set of class files and set of executables and dynamic libraries (shared objects in UNIX). When I install subsequent versions of JDK I install them in different directories which causes my to update CLASSPATH and PATH each time I do that. What you are saying is that your path keeps pointing to /usr/java/bin. Does it mean that each new installation overwrites an older one? Is it the only possible way to install JDK?

Anyway, why don't you find out for sure where the classes.zip and the executables (such as java) for the version you want to use are. You can do it by using "which java" command and renaming directories where class libraries are.

Not putting classes.zip on a classpath is not an error as long as you know that it uses the right version. In your case you don't seem to be sure of that.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:wex
ID: 1221168
There's no classes.zip file in there.  I've checked for it.
I've also checked for the possibility of multiple installations and there's only one on each machine.
The executables are clearly in /usr/java/bin
I checked that and it's the standard approach where everything points to one java_wrapper script which (among a zillion other things) sets the CLASSPATH.

What baffles me is why there's only one file which it can't find.  When I get the stack trace from this error, it looks like this:
java.lang.UnsatisfiedLinkError: getInetFamily
        at java.net.InetAddress.<init>(InetAddress.java:63)
        at
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:201)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:219)
        at sun.net.www.http.HttpClient.New(HttpClient.java:230)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:326)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:407)
        at Footprints.database.convert.ReadPath.parse(ReadPath.java:329)
        at Footprints.database.convert.ReadPath.main(ReadPath.java:896)

So it only fails on finding something in java.net.InetFamily (InetAddress).  If the other .class files are found, why not this particular one?

I'm still baffled.
0
 
LVL 5

Expert Comment

by:msmolyak
ID: 1221169
What OS are you using?
0
 
LVL 1

Author Comment

by:wex
ID: 1221170
I'm using IRIX 6.1 as it happens, but you were essentially correct.
It's a CLASSPATH problem.  I can't figure out how to go back and give you the points.
I guess if you post a new answer I can accept it and you'll get the points that way?
0
 
LVL 5

Accepted Solution

by:
msmolyak earned 300 total points
ID: 1221171
Thess are the commands I found in the .java_wrapper script in /usr/java/bin on an our IRIX machine:

COMM_CLASSPATH="$JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/dev.jar:$JAVA_HOME/lib/i18n.jar:$JAVA_HOME/lib/tiny.jar:$JAVA_HOME/classes"
if [ -z "${CLASSPATH}" ] ; then
    CLASSPATH=$COMM_CLASSPATH
else
    CLASSPATH="$CLASSPATH:$COMM_CLASSPATH"
fi

Thus, CLASSPATH is being set to something very concrete.

Did you fix the problem or you are still looking?
0
 
LVL 1

Author Comment

by:wex
ID: 1221172
OK, the problem was indeed with my $CLASSPATH
36 hours of wild-goose chasing later I've finally gotten it working.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question