Home     |     Java    |     Php General    |     Oracle Database    |     Oracle Server  

MS Dynamics CRM 3.0

  •  Setting up and Configuring Microsoft Dynamics CRM 3.0
  •  Managing Security and Information Access
  •  Entity Customization: Concepts and Attributes
  •  Entity Customization: Forms and Views
  •  Entity Customization: Relationships, Custom Entities, and Site Map
  •  Reporting and Analysis
  •  Workflow
  •  Server-Side SDK
  •  Client-Side SDK
  •  Integration with External Applications
  • Cervo Technologies
    The Right Source to Outsource

    Sharepoint Portal Server KB

    Microsoft CRM Info

    WPF Interview Questions

    SilverLight Interview Qs

    Asp.Net 2.0 Interview Qs

    Asp.NET 1.1 FAQs

    Oracle Interview Questions

    SAP Interview Questions

    Java Programming

    simple app breaks when opening second stream with openStream


    I have written a simple java app using the two classes at the end of
    this post. This app works fine on several machines, but not on the Red
    Hat linux server that I really need it to run on. On the Red Hat
    machine, I get the following program output and stack traces.

    //BEGIN PROGRAM OUTPUT
    Starting TestURL
    Starting the threads...
    Thread 1: Starting
    Thread 1: URL is http://www.visnat.com/entry/vnimages/workplace1.jpg
    End of TestURL after starting threads...
    Thread 2: Starting
    Thread 2: URL is http://www.visnat.com/entry/vnimages/justthetv.gif
    Thread 2: the url openstream call
    failed:java.lang.NullPointerException
    java.lang.NullPointerException
       at
    gnu.java.net.LineInputStream.LineInputStream(java.io.InputStream,
    java.lang.String) (/usr/lib/libgcj.so.6.0.0)
       at
    gnu.java.net.LineInputStream.LineInputStream(java.io.InputStream) (/
    usr/lib/libgcj.so.6.0.0)
       at gnu.java.net.protocol.http.Request.dispatch() (/usr/lib/
    libgcj.so.6.0.0)
       at gnu.java.net.protocol.http.HTTPURLConnection.connect() (/usr/lib/
    libgcj.so.6.0.0)
       at gnu.java.net.protocol.http.HTTPURLConnection.getInputStream() (/
    usr/lib/libgcj.so.6.0.0)
       at java.net.URL.openStream() (/usr/lib/libgcj.so.6.0.0)
       at ImageDownloader.run() (Unknown Source)
       at .GC_start_routine (/usr/lib/libgcj.so.6.0.0)
       at .__clone (/lib/libc-2.3.6.so)
    Thread 2: Ending
    Thread 2: the input stream close call
    failed:java.lang.NullPointerException
    java.lang.NullPointerException
       at ImageDownloader.run() (Unknown Source)
       at .GC_start_routine (/usr/lib/libgcj.so.6.0.0)
       at .__clone (/lib/libc-2.3.6.so)
    Thread 1: Ending
    //END PROGRAM OUTPUT

    If I just run one thread/stream, then even the Red Hat machine is
    happy. The threads seem to start and end ok and behave correctly. I
    just can't get a second call to openStream to work.

    Is there some configuration of linux/java that doesn't permit two
    streams to be opened at the same time?  At first, I thought it might
    be a complete lack of ephemeral ports above 1024, but that doesn't
    appear to be the problem after all. I haven't been able to find anyone
    else that has ever experienced this problem.

    gdhurst

    // BEGIN TESTURL CLASS
    import java.io.*;

    public class TestURL {
     static boolean listening = true;

     public static void main(String[] args) throws IOException {
      System.out.println("Starting TestURL");
      ImageDownloader id1 = null;
      ImageDownloader id2 = null;

      id1 = new ImageDownloader("http://www.visnat.com/entry/vnimages/
    workplace1.jpg","1");
      id2 = new ImageDownloader("http://www.visnat.com/entry/vnimages/
    justthetv.gif","2");
      System.out.println("Starting the threads...");
      id1.start();
      id2.start();
      System.out.println("End of TestURL after starting threads...");
     }

    }

    // END TESTURL CLASS

    // BEGIN IMAGEDOWNLOADER CLASS
    import java.io.*;
    import java.net.*;

    public class ImageDownloader extends Thread {
     private String strUrl;
     private String TID;

     public ImageDownloader(String theurl,String threadID) {
      strUrl = theurl;
      TID = threadID;
     }

     public void run() {
      URL   url;
      InputStream is = null;
            System.out.println("Thread " + TID + ": Starting");
      System.out.println("Thread " + TID + ": URL is " + strUrl);

      try {
        url = new URL(strUrl);
        is = url.openStream();  //throws an IOException
      } catch (Exception e) {
        System.out.println("Thread " + TID + ": the url openstream call
    failed:" + e);
        e.printStackTrace();
      }

      System.out.println("Thread " + TID + ": Ending");
      try {
        is.close();
      } catch (Exception e) {
        System.out.println("Thread " + TID + ": the input stream close
    call failed:" + e);
        e.printStackTrace();
      }

     } //END RUN()

    }

    // END IMAGEDOWNLOADER CLASS
    On 14 May 2007 12:29:23 -0700, j@hursttechnical.com wrote:

    > I have written a simple java app using the two classes at the end of
    > this post. This app works fine on several machines, but not on the
    > Red Hat linux server that I really need it to run on. On the Red Hat
    > machine, I get the following program output and stack traces.

    You appear to be using gcj. Do you have the same problem if you use
    the JDK from Sun instead?

    /gordon

    --

    Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc