Applet Hangs when submitting data to servlet

I

ILPTAB

I am currently supporting an interactive web site for a state agency.
Recently we started getting reports from SOME of the users that the
applet hangs when they attempt to submit data to the servlet running
on our web server. We have not made any changes to the java code so
the only thing I can figure is that it must be happening as a result
of an update to the java JRE or Windows. Note that I said it's
occurring with SOME of the users. Other people seem to be having no
problem at all with it.

To help illustrate the problem, I put together a small test server and
applet that demonstrates the problem. I have included the source code
for both parts below. On the applet side, it hangs when it comes to a
line that attempts to instantiate the ObjectInputStream class and
retrieve the input stream from the applet.

ObjectInputStream inobj = new ObjectInputStream(s.getInputStream());

Since the applet locks up, I am unable to give you any error messages
in the java console. In fact the browser gets so locked up that it
requires the user to close the session from the Windows task manager.

On the Servlet side it hangs at the line that attempts to read the
data stream from the socket connection.

sSearchField_ = in.readLine();

The error messages generated at the server are as follows:

Java.lang.NullpointerException at ServerSide.testLookup(ServerSide.54)

at ServerSide.run(ServerSide.java.98)

at jave.lang.thread.run(Unkown Source)


Any help in resolving this problem would be greatly appricated.

Thank you.



Here is the source code for both the Servlet and the applet.


/* Class Name: AppletSide.java

Copyright © 2007 Steve Rulison

Version 1.0.0

Purpose: This java applet will display relevent information
pertaining to
this examplet
*/

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

import java.io.*;
import java.util.*;
import java.net.*;
import java.lang.*;

public class AppletSide extends JApplet
implements ActionListener, KeyListener, MouseListener, Serializable
{
private static final long serialVersionUID = 1;

private JButton theSubmitButton_, theClearButton_;
private Socket s;
private String host, ServerName_;
private TestData td;
private JPanel appletPanel, resultPanel, buttonPanel,
socketPanel, headingPanel;
private Font f1 = new Font("Sansserf", Font.BOLD, 28);

private JLabel socketConnectionLabel = new JLabel("");
private JTextField resultField1, resultField2, resultField3,
resultField4, resultField5;

private java.awt.List inquirylist;

//Constructor
public AppletSide()
{
headingPanel = new JPanel();
headingPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

//Initialize String variables for output.
searchSetup();
}//Constructor

public void init()
{
// Note: The getCodeBase().getHost() methods must be invoked from
the
// init() method.
ServerName_ = getCodeBase().getHost();
System.out.println(ServerName_);

System.out.println("Test Applet Version");
}//End of init.

//Establish a socket connection with the server.
private boolean createSocket(String pServerName)
{
boolean SocketConnectSuccessful = false;
try
{
int iPort = 554;
s = new Socket(pServerName, iPort);
SocketConnectSuccessful = true;
socketConnectionLabel.setText("Socket connection successfully
established with host " + pServerName + " on port " + iPort);
socketPanel.validate();
}
catch(Exception e)
{
e.printStackTrace(System.err);
System.out.println(e);
SocketConnectSuccessful = false;
socketConnectionRefused();
}//End of catch block.
return SocketConnectSuccessful;
}//End of method createSocket.

//This method is called when a socket connection could not be
established.
private void socketConnectionRefused()
{
socketConnectionLabel.setText("Unable to establish a connection with
host. Please contact you network administrator.");
socketPanel.validate();
}//End of method socketConnectionRefused.

//Setup search Inquiry labels.
private void searchSetup()
{
setLayout(new BorderLayout());

appletPanel = new JPanel();
appletPanel.setLayout(new GridLayout(0,1));


JLabel titleLabel = new JLabel("Test Page");
titleLabel.setFont(f1);
titleLabel.setForeground(Color.black);

headingPanel.add(titleLabel);
appletPanel.add(headingPanel);

JPanel inquiryPanel = new JPanel();
inquiryPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

JLabel inquiryLabel = new JLabel("Make Selection: ");
inquiryPanel.add(inquiryLabel);

inquirylist = new java.awt.List();
inquirylist.add("Test 1");
inquirylist.add("Test 2");
inquirylist.add("Test 3");
inquirylist.select(0);

inquiryPanel.add(inquirylist);

appletPanel.add(inquiryPanel);

resultSetup();

socketPanel = new JPanel();
socketPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
socketPanel.add(socketConnectionLabel);
appletPanel.add(socketPanel);


buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

theSubmitButton_ = new JButton("Submit");
theSubmitButton_.addActionListener(this);
theSubmitButton_.addKeyListener(this);

buttonPanel.add(theSubmitButton_);
theClearButton_ = new JButton("Clear");
theClearButton_.addActionListener(this);
theClearButton_.addKeyListener(this);
buttonPanel.add(theClearButton_);
appletPanel.add(buttonPanel);

add(BorderLayout.CENTER, appletPanel);

}//End of method searchLabelSetup.

//Setup result labels.
private void resultSetup()
{
resultPanel = new JPanel();
resultPanel.setLayout(new GridLayout(5,2));

JLabel resultLabel1 = new JLabel("Field 1: ", JLabel.RIGHT);
JLabel resultLabel2 = new JLabel("Field 2: ", JLabel.RIGHT);
JLabel resultLabel3 = new JLabel("Field 3: ", JLabel.RIGHT);
JLabel resultLabel4 = new JLabel("Field 4: ", JLabel.RIGHT);
JLabel resultLabel5 = new JLabel("Field 5: ", JLabel.RIGHT);

resultField1 = new JTextField("Default value 1", 5);
resultField1.setEditable(false);
resultField2 = new JTextField("Default value 2 ",5);
resultField2.setEditable(false);
resultField3 = new JTextField("Default value 3",5);
resultField3.setEditable(false);
resultField4 = new JTextField("Default value 4",5);
resultField4.setEditable(false);
resultField5 = new JTextField("Default value 5",5);
resultField5.setEditable(false);

resultPanel.add(resultLabel1);
resultPanel.add(resultField1);
resultPanel.add(resultLabel2);
resultPanel.add(resultField2);
resultPanel.add(resultLabel3);
resultPanel.add(resultField3);
resultPanel.add(resultLabel4);
resultPanel.add(resultField4);
resultPanel.add(resultLabel5);
resultPanel.add(resultField5);

appletPanel.add(resultPanel);

}//End of method resultLabelSetup.

// Display the fields that have been populated with data received
from the
// server application.
private void displayResults()
{
resultField1.setText(td.sField_1);
resultField2.setText(td.sField_2);
resultField3.setText(td.sField_3);
resultField4.setText(td.sField_4);
resultField5.setText(td.sField_5);
resultPanel.validate();
}//End of method displayResults.

//Clears fields of data
private void clearFields()
{
resultField1.setText("Default value 1");
resultField2.setText("Default value 2");
resultField3.setText("Default value 3");
resultField4.setText("Default value 4");
resultField5.setText("Default value 5");
resultPanel.validate();
inquirylist.select(0);
}//End of method clearFields.

//Reset the applet to allow the user to perform a new search.
private void resetSearch()
{
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
clearFields();
createSocket(ServerName_);
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//End of method resetSearch.

//Perform Input/Output operations with the server.
private void serverIO()
{
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

try
{
PrintWriter out =
new PrintWriter(
new BufferedWriter(
new OutputStreamWriter(
s.getOutputStream())),true);


System.out.println("Check point 1 @ serverIO method.");
out.println(inquirylist.getItem(inquirylist.getSelectedIndex()));
// Thread.currentThread().sleep(5000);
System.out.println("Check point 2 @ serverIO method.");
//Read data back from server - Inputstream
ObjectInputStream inObj = new
ObjectInputStream(s.getInputStream());
System.out.println("Check point 3 @ serverIO method.");
out.flush();
System.out.println("Check point 4 @ serverIO method.");

td = (TestData) inObj.readObject();

s.close();
if(td.bRecFound)
displayResults();
else
resetSearch();
}
catch(Exception e)
{
System.out.println("Check point 1 - Exception: " + e);

}//End of try/catch block

this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//End of method ServerIO


//Event handling method.
public void actionPerformed(ActionEvent evt)
{
if(evt.getSource() == theClearButton_)
{
clearFields();
repaint();
}
else if(evt.getSource() == theSubmitButton_)
{
if(createSocket(ServerName_))
{
System.getSecurityManager();

// searchLabelSetup();
validate();
System.out.println(s.getInetAddress());
serverIO();
repaint();
}
else
socketConnectionRefused();
}
}//End of method actionPerformed


//Methodsfor handling for keyboard events
public void keyPressed(KeyEvent evt){}
public void keyReleased(KeyEvent evt){}
public void keyTyped(KeyEvent evt)
{
// System.out.println(" " + (int)evt.getKeyChar() );

if(evt.getSource() == theClearButton_)
{
clearFields();
repaint();
}
else if(evt.getSource() == theSubmitButton_)
{
serverIO();
repaint();
}
}//End of method keyTyped.

public void mouseClicked(MouseEvent evt)
{
if(evt.getClickCount() == 2)
{
}
}
public void mouseExited(MouseEvent event){}
public void mouseEntered(MouseEvent event){}
public void mouseReleased(MouseEvent event){}
public void mousePressed(MouseEvent event){}

}//End of class ApplSide.

class TestData implements Serializable
{
private static final long serialVersionUID = 1;

/* Test Data */
public String sField_1, sField_2, sField_3, sField_4, sField_5;
public boolean bRecFound;

//Constructor
TestData()
{}
}//End of class ServerTestData.

- - - - - - - - - - - - - - - - -
- - - -

/* Class name: ServerSide

Author: Steven Rulison

Purpose: Demonstrate the servlet side
*/

import java.io.*;
import java.util.*;
import java.net.*;

public class ServerSide extends Thread
{
private TestData td;
private Socket s;
private String sSearchField_;

public static void main(String[] Args)
{
try
{
ServerSocket ss = new ServerSocket(554);

int spawnCnt = 0;
while(true)
{
Socket s = ss.accept();

++spawnCnt;
System.out.println("Spawning " + spawnCnt);


Thread servSide = new Thread(new ServerSide(s), "serverside");
servSide.start();
}
}catch(IOException e)
{
e.printStackTrace(System.err);
}
}//End of main.


//Constructor.
public ServerSide(Socket s_)
{
s = s_;
}//End of Constructor.


private void testLookup(String sSearch)
{
td = new TestData();
td.bRecFound = true;
if(sSearch.trim().equals("Test 1"))
{
td.sField_1 = "Alpha";
td.sField_2 = "Beta";
td.sField_3 = "Gamma";
td.sField_4 = "Delta";
td.sField_5 = "Epsilon";
}
else if(sSearch.trim().equals("Test 2"))
{
td.sField_1 = "AAA";
td.sField_2 = "BBB";
td.sField_3 = "CCC";
td.sField_4 = "DDDD";
td.sField_5 = "EEEE";
}
else if(sSearch.trim().equals("Test 3"))
{
td.sField_1 = "111";
td.sField_2 = "222";
td.sField_3 = "333";
td.sField_4 = "444";
td.sField_5 = "555";
}
}// End of method testLookup.

public void run()
{
try
{
//Setup Input Stream.
BufferedReader in =
new BufferedReader( new InputStreamReader(s.getInputStream()));

// Setup output Stream.
ObjectOutputStream ObjOut = new
ObjectOutputStream(s.getOutputStream());

//Perform intial read...
sSearchField_ = in.readLine();

Thread.currentThread().sleep(5000);

System.out.println("The sSearchField_ variable = " + sSearchField_);

testLookup(sSearchField_);

ObjOut.writeObject(td);
ObjOut.flush();
ObjOut.close();

s.close();
}
catch(Exception e)
{
e.printStackTrace(System.err);
}
}//End of run method
}//End of ServerSide class...


/*
This is the class template that will be used to create the object
that will
be passed through to the ObjectInput/Output - stream to the lookup
applet.
*/
class TestData implements Serializable
{
private static final long serialVersionUID = 1;

/* Test Data */
public String sField_1, sField_2, sField_3, sField_4, sField_5;
public boolean bRecFound;

//Constructor
TestData()
{}

}//End of class ServerTestData.
 
K

Knute Johnson

ILPTAB said:
I am currently supporting an interactive web site for a state agency.
Recently we started getting reports from SOME of the users that the
applet hangs when they attempt to submit data to the servlet running
on our web server. We have not made any changes to the java code so
the only thing I can figure is that it must be happening as a result
of an update to the java JRE or Windows. Note that I said it's
occurring with SOME of the users. Other people seem to be having no
problem at all with it.

To help illustrate the problem, I put together a small test server and
applet that demonstrates the problem. I have included the source code
for both parts below. On the applet side, it hangs when it comes to a
line that attempts to instantiate the ObjectInputStream class and
retrieve the input stream from the applet.

ObjectInputStream inobj = new ObjectInputStream(s.getInputStream());

Since the applet locks up, I am unable to give you any error messages
in the java console. In fact the browser gets so locked up that it
requires the user to close the session from the Windows task manager.

On the Servlet side it hangs at the line that attempts to read the
data stream from the socket connection.

sSearchField_ = in.readLine();

The error messages generated at the server are as follows:

Java.lang.NullpointerException at ServerSide.testLookup(ServerSide.54)

at ServerSide.run(ServerSide.java.98)

at jave.lang.thread.run(Unkown Source)


Any help in resolving this problem would be greatly appricated.

Thank you.



Here is the source code for both the Servlet and the applet.


/* Class Name: AppletSide.java

Copyright © 2007 Steve Rulison

Version 1.0.0

Purpose: This java applet will display relevent information
pertaining to
this examplet
*/

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

import java.io.*;
import java.util.*;
import java.net.*;
import java.lang.*;

public class AppletSide extends JApplet
implements ActionListener, KeyListener, MouseListener, Serializable
{
private static final long serialVersionUID = 1;

private JButton theSubmitButton_, theClearButton_;
private Socket s;
private String host, ServerName_;
private TestData td;
private JPanel appletPanel, resultPanel, buttonPanel,
socketPanel, headingPanel;
private Font f1 = new Font("Sansserf", Font.BOLD, 28);

private JLabel socketConnectionLabel = new JLabel("");
private JTextField resultField1, resultField2, resultField3,
resultField4, resultField5;

private java.awt.List inquirylist;

//Constructor
public AppletSide()
{
headingPanel = new JPanel();
headingPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

//Initialize String variables for output.
searchSetup();
}//Constructor

public void init()
{
// Note: The getCodeBase().getHost() methods must be invoked from
the
// init() method.
ServerName_ = getCodeBase().getHost();
System.out.println(ServerName_);

System.out.println("Test Applet Version");
}//End of init.

//Establish a socket connection with the server.
private boolean createSocket(String pServerName)
{
boolean SocketConnectSuccessful = false;
try
{
int iPort = 554;
s = new Socket(pServerName, iPort);
SocketConnectSuccessful = true;
socketConnectionLabel.setText("Socket connection successfully
established with host " + pServerName + " on port " + iPort);
socketPanel.validate();
}
catch(Exception e)
{
e.printStackTrace(System.err);
System.out.println(e);
SocketConnectSuccessful = false;
socketConnectionRefused();
}//End of catch block.
return SocketConnectSuccessful;
}//End of method createSocket.

//This method is called when a socket connection could not be
established.
private void socketConnectionRefused()
{
socketConnectionLabel.setText("Unable to establish a connection with
host. Please contact you network administrator.");
socketPanel.validate();
}//End of method socketConnectionRefused.

//Setup search Inquiry labels.
private void searchSetup()
{
setLayout(new BorderLayout());

appletPanel = new JPanel();
appletPanel.setLayout(new GridLayout(0,1));


JLabel titleLabel = new JLabel("Test Page");
titleLabel.setFont(f1);
titleLabel.setForeground(Color.black);

headingPanel.add(titleLabel);
appletPanel.add(headingPanel);

JPanel inquiryPanel = new JPanel();
inquiryPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

JLabel inquiryLabel = new JLabel("Make Selection: ");
inquiryPanel.add(inquiryLabel);

inquirylist = new java.awt.List();
inquirylist.add("Test 1");
inquirylist.add("Test 2");
inquirylist.add("Test 3");
inquirylist.select(0);

inquiryPanel.add(inquirylist);

appletPanel.add(inquiryPanel);

resultSetup();

socketPanel = new JPanel();
socketPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
socketPanel.add(socketConnectionLabel);
appletPanel.add(socketPanel);


buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

theSubmitButton_ = new JButton("Submit");
theSubmitButton_.addActionListener(this);
theSubmitButton_.addKeyListener(this);

buttonPanel.add(theSubmitButton_);
theClearButton_ = new JButton("Clear");
theClearButton_.addActionListener(this);
theClearButton_.addKeyListener(this);
buttonPanel.add(theClearButton_);
appletPanel.add(buttonPanel);

add(BorderLayout.CENTER, appletPanel);

}//End of method searchLabelSetup.

//Setup result labels.
private void resultSetup()
{
resultPanel = new JPanel();
resultPanel.setLayout(new GridLayout(5,2));

JLabel resultLabel1 = new JLabel("Field 1: ", JLabel.RIGHT);
JLabel resultLabel2 = new JLabel("Field 2: ", JLabel.RIGHT);
JLabel resultLabel3 = new JLabel("Field 3: ", JLabel.RIGHT);
JLabel resultLabel4 = new JLabel("Field 4: ", JLabel.RIGHT);
JLabel resultLabel5 = new JLabel("Field 5: ", JLabel.RIGHT);

resultField1 = new JTextField("Default value 1", 5);
resultField1.setEditable(false);
resultField2 = new JTextField("Default value 2 ",5);
resultField2.setEditable(false);
resultField3 = new JTextField("Default value 3",5);
resultField3.setEditable(false);
resultField4 = new JTextField("Default value 4",5);
resultField4.setEditable(false);
resultField5 = new JTextField("Default value 5",5);
resultField5.setEditable(false);

resultPanel.add(resultLabel1);
resultPanel.add(resultField1);
resultPanel.add(resultLabel2);
resultPanel.add(resultField2);
resultPanel.add(resultLabel3);
resultPanel.add(resultField3);
resultPanel.add(resultLabel4);
resultPanel.add(resultField4);
resultPanel.add(resultLabel5);
resultPanel.add(resultField5);

appletPanel.add(resultPanel);

}//End of method resultLabelSetup.

// Display the fields that have been populated with data received
from the
// server application.
private void displayResults()
{
resultField1.setText(td.sField_1);
resultField2.setText(td.sField_2);
resultField3.setText(td.sField_3);
resultField4.setText(td.sField_4);
resultField5.setText(td.sField_5);
resultPanel.validate();
}//End of method displayResults.

//Clears fields of data
private void clearFields()
{
resultField1.setText("Default value 1");
resultField2.setText("Default value 2");
resultField3.setText("Default value 3");
resultField4.setText("Default value 4");
resultField5.setText("Default value 5");
resultPanel.validate();
inquirylist.select(0);
}//End of method clearFields.

//Reset the applet to allow the user to perform a new search.
private void resetSearch()
{
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
clearFields();
createSocket(ServerName_);
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//End of method resetSearch.

//Perform Input/Output operations with the server.
private void serverIO()
{
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

try
{
PrintWriter out =
new PrintWriter(
new BufferedWriter(
new OutputStreamWriter(
s.getOutputStream())),true);


System.out.println("Check point 1 @ serverIO method.");
out.println(inquirylist.getItem(inquirylist.getSelectedIndex()));
// Thread.currentThread().sleep(5000);
System.out.println("Check point 2 @ serverIO method.");
//Read data back from server - Inputstream
ObjectInputStream inObj = new
ObjectInputStream(s.getInputStream());
System.out.println("Check point 3 @ serverIO method.");
out.flush();
System.out.println("Check point 4 @ serverIO method.");

td = (TestData) inObj.readObject();

s.close();
if(td.bRecFound)
displayResults();
else
resetSearch();
}
catch(Exception e)
{
System.out.println("Check point 1 - Exception: " + e);

}//End of try/catch block

this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//End of method ServerIO


//Event handling method.
public void actionPerformed(ActionEvent evt)
{
if(evt.getSource() == theClearButton_)
{
clearFields();
repaint();
}
else if(evt.getSource() == theSubmitButton_)
{
if(createSocket(ServerName_))
{
System.getSecurityManager();

// searchLabelSetup();
validate();
System.out.println(s.getInetAddress());
serverIO();
repaint();
}
else
socketConnectionRefused();
}
}//End of method actionPerformed


//Methodsfor handling for keyboard events
public void keyPressed(KeyEvent evt){}
public void keyReleased(KeyEvent evt){}
public void keyTyped(KeyEvent evt)
{
// System.out.println(" " + (int)evt.getKeyChar() );

if(evt.getSource() == theClearButton_)
{
clearFields();
repaint();
}
else if(evt.getSource() == theSubmitButton_)
{
serverIO();
repaint();
}
}//End of method keyTyped.

public void mouseClicked(MouseEvent evt)
{
if(evt.getClickCount() == 2)
{
}
}
public void mouseExited(MouseEvent event){}
public void mouseEntered(MouseEvent event){}
public void mouseReleased(MouseEvent event){}
public void mousePressed(MouseEvent event){}

}//End of class ApplSide.

class TestData implements Serializable
{
private static final long serialVersionUID = 1;

/* Test Data */
public String sField_1, sField_2, sField_3, sField_4, sField_5;
public boolean bRecFound;

//Constructor
TestData()
{}
}//End of class ServerTestData.

- - - - - - - - - - - - - - - - -
- - - -

/* Class name: ServerSide

Author: Steven Rulison

Purpose: Demonstrate the servlet side
*/

import java.io.*;
import java.util.*;
import java.net.*;

public class ServerSide extends Thread
{
private TestData td;
private Socket s;
private String sSearchField_;

public static void main(String[] Args)
{
try
{
ServerSocket ss = new ServerSocket(554);

int spawnCnt = 0;
while(true)
{
Socket s = ss.accept();

++spawnCnt;
System.out.println("Spawning " + spawnCnt);


Thread servSide = new Thread(new ServerSide(s), "serverside");
servSide.start();
}
}catch(IOException e)
{
e.printStackTrace(System.err);
}
}//End of main.


//Constructor.
public ServerSide(Socket s_)
{
s = s_;
}//End of Constructor.


private void testLookup(String sSearch)
{
td = new TestData();
td.bRecFound = true;
if(sSearch.trim().equals("Test 1"))
{
td.sField_1 = "Alpha";
td.sField_2 = "Beta";
td.sField_3 = "Gamma";
td.sField_4 = "Delta";
td.sField_5 = "Epsilon";
}
else if(sSearch.trim().equals("Test 2"))
{
td.sField_1 = "AAA";
td.sField_2 = "BBB";
td.sField_3 = "CCC";
td.sField_4 = "DDDD";
td.sField_5 = "EEEE";
}
else if(sSearch.trim().equals("Test 3"))
{
td.sField_1 = "111";
td.sField_2 = "222";
td.sField_3 = "333";
td.sField_4 = "444";
td.sField_5 = "555";
}
}// End of method testLookup.

public void run()
{
try
{
//Setup Input Stream.
BufferedReader in =
new BufferedReader( new InputStreamReader(s.getInputStream()));

// Setup output Stream.
ObjectOutputStream ObjOut = new
ObjectOutputStream(s.getOutputStream());

//Perform intial read...
sSearchField_ = in.readLine();

Thread.currentThread().sleep(5000);

System.out.println("The sSearchField_ variable = " + sSearchField_);

testLookup(sSearchField_);

ObjOut.writeObject(td);
ObjOut.flush();
ObjOut.close();

s.close();
}
catch(Exception e)
{
e.printStackTrace(System.err);
}
}//End of run method
}//End of ServerSide class...


/*
This is the class template that will be used to create the object
that will
be passed through to the ObjectInput/Output - stream to the lookup
applet.
*/
class TestData implements Serializable
{
private static final long serialVersionUID = 1;

/* Test Data */
public String sField_1, sField_2, sField_3, sField_4, sField_5;
public boolean bRecFound;

//Constructor
TestData()
{}

}//End of class ServerTestData.

I have seen similar problems with applications. I cannot duplicate the
problem and it only happens once in a while. I'm getting socket I/O
hangs not just with ObjectOutputStream/InputStreams but with binary I/O
too. It started for me in May or June on an application that had been
running for over a year with no problems. It lasted several weeks and I
hadn't seen it again until about a week ago. That could be just
coincidence though. The computers I'm using are not being updated so I
don't think that is the problem.

The socket did not time out and I created another timer that closed the
socket if it was still open and that didn't work. I'm at a loss as to
what is happening and don't really know where to look. My client is not
very happy with me at the moment.
 
R

Richard Maher

Hi,

I don't know what is causing the hang but FWIW I use the following Timeouts
to put a time limit on my socket connections and socket reads. At least then
you be able to identify which read isn't being satisfied and track down what
happened to the writer.

t3Sock.connect(new InetSocketAddress(host,port), CONTIMOUT);

: : :

public void setTimeout(int msecs) throws UnknownHostException, IOException
{
t3Sock.setSoTimeout(msecs);
}

Cheers Richard Maher

I am currently supporting an interactive web site for a state agency.
Recently we started getting reports from SOME of the users that the
applet hangs when they attempt to submit data to the servlet running
on our web server. We have not made any changes to the java code so
the only thing I can figure is that it must be happening as a result
of an update to the java JRE or Windows. Note that I said it's
occurring with SOME of the users. Other people seem to be having no
problem at all with it.

To help illustrate the problem, I put together a small test server and
applet that demonstrates the problem. I have included the source code
for both parts below. On the applet side, it hangs when it comes to a
line that attempts to instantiate the ObjectInputStream class and
retrieve the input stream from the applet.

ObjectInputStream inobj = new ObjectInputStream(s.getInputStream());

Since the applet locks up, I am unable to give you any error messages
in the java console. In fact the browser gets so locked up that it
requires the user to close the session from the Windows task manager.

On the Servlet side it hangs at the line that attempts to read the
data stream from the socket connection.

sSearchField_ = in.readLine();

The error messages generated at the server are as follows:

Java.lang.NullpointerException at ServerSide.testLookup(ServerSide.54)

at ServerSide.run(ServerSide.java.98)

at jave.lang.thread.run(Unkown Source)


Any help in resolving this problem would be greatly appricated.

Thank you.



Here is the source code for both the Servlet and the applet.


/* Class Name: AppletSide.java

Copyright © 2007 Steve Rulison

Version 1.0.0

Purpose: This java applet will display relevent information
pertaining to
this examplet
*/

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

import java.io.*;
import java.util.*;
import java.net.*;
import java.lang.*;

public class AppletSide extends JApplet
implements ActionListener, KeyListener, MouseListener, Serializable
{
private static final long serialVersionUID = 1;

private JButton theSubmitButton_, theClearButton_;
private Socket s;
private String host, ServerName_;
private TestData td;
private JPanel appletPanel, resultPanel, buttonPanel,
socketPanel, headingPanel;
private Font f1 = new Font("Sansserf", Font.BOLD, 28);

private JLabel socketConnectionLabel = new JLabel("");
private JTextField resultField1, resultField2, resultField3,
resultField4, resultField5;

private java.awt.List inquirylist;

//Constructor
public AppletSide()
{
headingPanel = new JPanel();
headingPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

//Initialize String variables for output.
searchSetup();
}//Constructor

public void init()
{
// Note: The getCodeBase().getHost() methods must be invoked from
the
// init() method.
ServerName_ = getCodeBase().getHost();
System.out.println(ServerName_);

System.out.println("Test Applet Version");
}//End of init.

//Establish a socket connection with the server.
private boolean createSocket(String pServerName)
{
boolean SocketConnectSuccessful = false;
try
{
int iPort = 554;
s = new Socket(pServerName, iPort);
SocketConnectSuccessful = true;
socketConnectionLabel.setText("Socket connection successfully
established with host " + pServerName + " on port " + iPort);
socketPanel.validate();
}
catch(Exception e)
{
e.printStackTrace(System.err);
System.out.println(e);
SocketConnectSuccessful = false;
socketConnectionRefused();
}//End of catch block.
return SocketConnectSuccessful;
}//End of method createSocket.

//This method is called when a socket connection could not be
established.
private void socketConnectionRefused()
{
socketConnectionLabel.setText("Unable to establish a connection with
host. Please contact you network administrator.");
socketPanel.validate();
}//End of method socketConnectionRefused.

//Setup search Inquiry labels.
private void searchSetup()
{
setLayout(new BorderLayout());

appletPanel = new JPanel();
appletPanel.setLayout(new GridLayout(0,1));


JLabel titleLabel = new JLabel("Test Page");
titleLabel.setFont(f1);
titleLabel.setForeground(Color.black);

headingPanel.add(titleLabel);
appletPanel.add(headingPanel);

JPanel inquiryPanel = new JPanel();
inquiryPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

JLabel inquiryLabel = new JLabel("Make Selection: ");
inquiryPanel.add(inquiryLabel);

inquirylist = new java.awt.List();
inquirylist.add("Test 1");
inquirylist.add("Test 2");
inquirylist.add("Test 3");
inquirylist.select(0);

inquiryPanel.add(inquirylist);

appletPanel.add(inquiryPanel);

resultSetup();

socketPanel = new JPanel();
socketPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
socketPanel.add(socketConnectionLabel);
appletPanel.add(socketPanel);


buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

theSubmitButton_ = new JButton("Submit");
theSubmitButton_.addActionListener(this);
theSubmitButton_.addKeyListener(this);

buttonPanel.add(theSubmitButton_);
theClearButton_ = new JButton("Clear");
theClearButton_.addActionListener(this);
theClearButton_.addKeyListener(this);
buttonPanel.add(theClearButton_);
appletPanel.add(buttonPanel);

add(BorderLayout.CENTER, appletPanel);

}//End of method searchLabelSetup.

//Setup result labels.
private void resultSetup()
{
resultPanel = new JPanel();
resultPanel.setLayout(new GridLayout(5,2));

JLabel resultLabel1 = new JLabel("Field 1: ", JLabel.RIGHT);
JLabel resultLabel2 = new JLabel("Field 2: ", JLabel.RIGHT);
JLabel resultLabel3 = new JLabel("Field 3: ", JLabel.RIGHT);
JLabel resultLabel4 = new JLabel("Field 4: ", JLabel.RIGHT);
JLabel resultLabel5 = new JLabel("Field 5: ", JLabel.RIGHT);

resultField1 = new JTextField("Default value 1", 5);
resultField1.setEditable(false);
resultField2 = new JTextField("Default value 2 ",5);
resultField2.setEditable(false);
resultField3 = new JTextField("Default value 3",5);
resultField3.setEditable(false);
resultField4 = new JTextField("Default value 4",5);
resultField4.setEditable(false);
resultField5 = new JTextField("Default value 5",5);
resultField5.setEditable(false);

resultPanel.add(resultLabel1);
resultPanel.add(resultField1);
resultPanel.add(resultLabel2);
resultPanel.add(resultField2);
resultPanel.add(resultLabel3);
resultPanel.add(resultField3);
resultPanel.add(resultLabel4);
resultPanel.add(resultField4);
resultPanel.add(resultLabel5);
resultPanel.add(resultField5);

appletPanel.add(resultPanel);

}//End of method resultLabelSetup.

// Display the fields that have been populated with data received
from the
// server application.
private void displayResults()
{
resultField1.setText(td.sField_1);
resultField2.setText(td.sField_2);
resultField3.setText(td.sField_3);
resultField4.setText(td.sField_4);
resultField5.setText(td.sField_5);
resultPanel.validate();
}//End of method displayResults.

//Clears fields of data
private void clearFields()
{
resultField1.setText("Default value 1");
resultField2.setText("Default value 2");
resultField3.setText("Default value 3");
resultField4.setText("Default value 4");
resultField5.setText("Default value 5");
resultPanel.validate();
inquirylist.select(0);
}//End of method clearFields.

//Reset the applet to allow the user to perform a new search.
private void resetSearch()
{
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
clearFields();
createSocket(ServerName_);
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//End of method resetSearch.

//Perform Input/Output operations with the server.
private void serverIO()
{
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

try
{
PrintWriter out =
new PrintWriter(
new BufferedWriter(
new OutputStreamWriter(
s.getOutputStream())),true);


System.out.println("Check point 1 @ serverIO method.");
out.println(inquirylist.getItem(inquirylist.getSelectedIndex()));
// Thread.currentThread().sleep(5000);
System.out.println("Check point 2 @ serverIO method.");
//Read data back from server - Inputstream
ObjectInputStream inObj = new
ObjectInputStream(s.getInputStream());
System.out.println("Check point 3 @ serverIO method.");
out.flush();
System.out.println("Check point 4 @ serverIO method.");

td = (TestData) inObj.readObject();

s.close();
if(td.bRecFound)
displayResults();
else
resetSearch();
}
catch(Exception e)
{
System.out.println("Check point 1 - Exception: " + e);

}//End of try/catch block

this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//End of method ServerIO


//Event handling method.
public void actionPerformed(ActionEvent evt)
{
if(evt.getSource() == theClearButton_)
{
clearFields();
repaint();
}
else if(evt.getSource() == theSubmitButton_)
{
if(createSocket(ServerName_))
{
System.getSecurityManager();

// searchLabelSetup();
validate();
System.out.println(s.getInetAddress());
serverIO();
repaint();
}
else
socketConnectionRefused();
}
}//End of method actionPerformed


//Methodsfor handling for keyboard events
public void keyPressed(KeyEvent evt){}
public void keyReleased(KeyEvent evt){}
public void keyTyped(KeyEvent evt)
{
// System.out.println(" " + (int)evt.getKeyChar() );

if(evt.getSource() == theClearButton_)
{
clearFields();
repaint();
}
else if(evt.getSource() == theSubmitButton_)
{
serverIO();
repaint();
}
}//End of method keyTyped.

public void mouseClicked(MouseEvent evt)
{
if(evt.getClickCount() == 2)
{
}
}
public void mouseExited(MouseEvent event){}
public void mouseEntered(MouseEvent event){}
public void mouseReleased(MouseEvent event){}
public void mousePressed(MouseEvent event){}

}//End of class ApplSide.

class TestData implements Serializable
{
private static final long serialVersionUID = 1;

/* Test Data */
public String sField_1, sField_2, sField_3, sField_4, sField_5;
public boolean bRecFound;

//Constructor
TestData()
{}
}//End of class ServerTestData.

- - - - - - - - - - - - - - - - -
- - - -

/* Class name: ServerSide

Author: Steven Rulison

Purpose: Demonstrate the servlet side
*/

import java.io.*;
import java.util.*;
import java.net.*;

public class ServerSide extends Thread
{
private TestData td;
private Socket s;
private String sSearchField_;

public static void main(String[] Args)
{
try
{
ServerSocket ss = new ServerSocket(554);

int spawnCnt = 0;
while(true)
{
Socket s = ss.accept();

++spawnCnt;
System.out.println("Spawning " + spawnCnt);


Thread servSide = new Thread(new ServerSide(s), "serverside");
servSide.start();
}
}catch(IOException e)
{
e.printStackTrace(System.err);
}
}//End of main.


//Constructor.
public ServerSide(Socket s_)
{
s = s_;
}//End of Constructor.


private void testLookup(String sSearch)
{
td = new TestData();
td.bRecFound = true;
if(sSearch.trim().equals("Test 1"))
{
td.sField_1 = "Alpha";
td.sField_2 = "Beta";
td.sField_3 = "Gamma";
td.sField_4 = "Delta";
td.sField_5 = "Epsilon";
}
else if(sSearch.trim().equals("Test 2"))
{
td.sField_1 = "AAA";
td.sField_2 = "BBB";
td.sField_3 = "CCC";
td.sField_4 = "DDDD";
td.sField_5 = "EEEE";
}
else if(sSearch.trim().equals("Test 3"))
{
td.sField_1 = "111";
td.sField_2 = "222";
td.sField_3 = "333";
td.sField_4 = "444";
td.sField_5 = "555";
}
}// End of method testLookup.

public void run()
{
try
{
//Setup Input Stream.
BufferedReader in =
new BufferedReader( new InputStreamReader(s.getInputStream()));

// Setup output Stream.
ObjectOutputStream ObjOut = new
ObjectOutputStream(s.getOutputStream());

//Perform intial read...
sSearchField_ = in.readLine();

Thread.currentThread().sleep(5000);

System.out.println("The sSearchField_ variable = " + sSearchField_);

testLookup(sSearchField_);

ObjOut.writeObject(td);
ObjOut.flush();
ObjOut.close();

s.close();
}
catch(Exception e)
{
e.printStackTrace(System.err);
}
}//End of run method
}//End of ServerSide class...


/*
This is the class template that will be used to create the object
that will
be passed through to the ObjectInput/Output - stream to the lookup
applet.
*/
class TestData implements Serializable
{
private static final long serialVersionUID = 1;

/* Test Data */
public String sField_1, sField_2, sField_3, sField_4, sField_5;
public boolean bRecFound;

//Constructor
TestData()
{}

}//End of class ServerTestData.
 
K

Knute Johnson

Richard said:
Hi,

I don't know what is causing the hang but FWIW I use the following Timeouts
to put a time limit on my socket connections and socket reads. At least then
you be able to identify which read isn't being satisfied and track down what
happened to the writer.

t3Sock.connect(new InetSocketAddress(host,port), CONTIMOUT);

: : :

public void setTimeout(int msecs) throws UnknownHostException, IOException
{
t3Sock.setSoTimeout(msecs);
}

Cheers Richard Maher

At least in my case, socket timeout did not work when the hang occurred.
 
I

ILPTAB

At least in my case, socket timeout did not work when the hang occurred.

--

Knute Johnson
email s/nospam/knute/- Hide quoted text -

- Show quoted text -

It's all back at the office so I haven't really had a chance to test
it. I wonder if there is a place to post this message on Sun
MicroSysten's site. I really need to get this fixed.

Steve Rulison
 
K

Knute Johnson

ILPTAB said:
It's all back at the office so I haven't really had a chance to test
it. I wonder if there is a place to post this message on Sun
MicroSysten's site. I really need to get this fixed.

Steve Rulison

File a bug at bugs.sun.com. I'll vote for it if you post it.
 
K

Knute Johnson

ILPTAB said:
I am currently supporting an interactive web site for a state agency.
Recently we started getting reports from SOME of the users that the
applet hangs when they attempt to submit data to the servlet running
on our web server. We have not made any changes to the java code so
the only thing I can figure is that it must be happening as a result
of an update to the java JRE or Windows. Note that I said it's
occurring with SOME of the users. Other people seem to be having no
problem at all with it.

To help illustrate the problem, I put together a small test server and
applet that demonstrates the problem. I have included the source code
for both parts below. On the applet side, it hangs when it comes to a
line that attempts to instantiate the ObjectInputStream class and
retrieve the input stream from the applet.

ObjectInputStream inobj = new ObjectInputStream(s.getInputStream());

Since the applet locks up, I am unable to give you any error messages
in the java console. In fact the browser gets so locked up that it
requires the user to close the session from the Windows task manager.

On the Servlet side it hangs at the line that attempts to read the
data stream from the socket connection.

sSearchField_ = in.readLine();

The error messages generated at the server are as follows:

Java.lang.NullpointerException at ServerSide.testLookup(ServerSide.54)

at ServerSide.run(ServerSide.java.98)

at jave.lang.thread.run(Unkown Source)


Any help in resolving this problem would be greatly appricated.

Thank you.



Here is the source code for both the Servlet and the applet.


/* Class Name: AppletSide.java

Copyright © 2007 Steve Rulison

Version 1.0.0

Purpose: This java applet will display relevent information
pertaining to
this examplet
*/

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

import java.io.*;
import java.util.*;
import java.net.*;
import java.lang.*;

public class AppletSide extends JApplet
implements ActionListener, KeyListener, MouseListener, Serializable
{
private static final long serialVersionUID = 1;

private JButton theSubmitButton_, theClearButton_;
private Socket s;
private String host, ServerName_;
private TestData td;
private JPanel appletPanel, resultPanel, buttonPanel,
socketPanel, headingPanel;
private Font f1 = new Font("Sansserf", Font.BOLD, 28);

private JLabel socketConnectionLabel = new JLabel("");
private JTextField resultField1, resultField2, resultField3,
resultField4, resultField5;

private java.awt.List inquirylist;

//Constructor
public AppletSide()
{
headingPanel = new JPanel();
headingPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

//Initialize String variables for output.
searchSetup();
}//Constructor

public void init()
{
// Note: The getCodeBase().getHost() methods must be invoked from
the
// init() method.
ServerName_ = getCodeBase().getHost();
System.out.println(ServerName_);

System.out.println("Test Applet Version");
}//End of init.

//Establish a socket connection with the server.
private boolean createSocket(String pServerName)
{
boolean SocketConnectSuccessful = false;
try
{
int iPort = 554;
s = new Socket(pServerName, iPort);
SocketConnectSuccessful = true;
socketConnectionLabel.setText("Socket connection successfully
established with host " + pServerName + " on port " + iPort);
socketPanel.validate();
}
catch(Exception e)
{
e.printStackTrace(System.err);
System.out.println(e);
SocketConnectSuccessful = false;
socketConnectionRefused();
}//End of catch block.
return SocketConnectSuccessful;
}//End of method createSocket.

//This method is called when a socket connection could not be
established.
private void socketConnectionRefused()
{
socketConnectionLabel.setText("Unable to establish a connection with
host. Please contact you network administrator.");
socketPanel.validate();
}//End of method socketConnectionRefused.

//Setup search Inquiry labels.
private void searchSetup()
{
setLayout(new BorderLayout());

appletPanel = new JPanel();
appletPanel.setLayout(new GridLayout(0,1));


JLabel titleLabel = new JLabel("Test Page");
titleLabel.setFont(f1);
titleLabel.setForeground(Color.black);

headingPanel.add(titleLabel);
appletPanel.add(headingPanel);

JPanel inquiryPanel = new JPanel();
inquiryPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

JLabel inquiryLabel = new JLabel("Make Selection: ");
inquiryPanel.add(inquiryLabel);

inquirylist = new java.awt.List();
inquirylist.add("Test 1");
inquirylist.add("Test 2");
inquirylist.add("Test 3");
inquirylist.select(0);

inquiryPanel.add(inquirylist);

appletPanel.add(inquiryPanel);

resultSetup();

socketPanel = new JPanel();
socketPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
socketPanel.add(socketConnectionLabel);
appletPanel.add(socketPanel);


buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

theSubmitButton_ = new JButton("Submit");
theSubmitButton_.addActionListener(this);
theSubmitButton_.addKeyListener(this);

buttonPanel.add(theSubmitButton_);
theClearButton_ = new JButton("Clear");
theClearButton_.addActionListener(this);
theClearButton_.addKeyListener(this);
buttonPanel.add(theClearButton_);
appletPanel.add(buttonPanel);

add(BorderLayout.CENTER, appletPanel);

}//End of method searchLabelSetup.

//Setup result labels.
private void resultSetup()
{
resultPanel = new JPanel();
resultPanel.setLayout(new GridLayout(5,2));

JLabel resultLabel1 = new JLabel("Field 1: ", JLabel.RIGHT);
JLabel resultLabel2 = new JLabel("Field 2: ", JLabel.RIGHT);
JLabel resultLabel3 = new JLabel("Field 3: ", JLabel.RIGHT);
JLabel resultLabel4 = new JLabel("Field 4: ", JLabel.RIGHT);
JLabel resultLabel5 = new JLabel("Field 5: ", JLabel.RIGHT);

resultField1 = new JTextField("Default value 1", 5);
resultField1.setEditable(false);
resultField2 = new JTextField("Default value 2 ",5);
resultField2.setEditable(false);
resultField3 = new JTextField("Default value 3",5);
resultField3.setEditable(false);
resultField4 = new JTextField("Default value 4",5);
resultField4.setEditable(false);
resultField5 = new JTextField("Default value 5",5);
resultField5.setEditable(false);

resultPanel.add(resultLabel1);
resultPanel.add(resultField1);
resultPanel.add(resultLabel2);
resultPanel.add(resultField2);
resultPanel.add(resultLabel3);
resultPanel.add(resultField3);
resultPanel.add(resultLabel4);
resultPanel.add(resultField4);
resultPanel.add(resultLabel5);
resultPanel.add(resultField5);

appletPanel.add(resultPanel);

}//End of method resultLabelSetup.

// Display the fields that have been populated with data received
from the
// server application.
private void displayResults()
{
resultField1.setText(td.sField_1);
resultField2.setText(td.sField_2);
resultField3.setText(td.sField_3);
resultField4.setText(td.sField_4);
resultField5.setText(td.sField_5);
resultPanel.validate();
}//End of method displayResults.

//Clears fields of data
private void clearFields()
{
resultField1.setText("Default value 1");
resultField2.setText("Default value 2");
resultField3.setText("Default value 3");
resultField4.setText("Default value 4");
resultField5.setText("Default value 5");
resultPanel.validate();
inquirylist.select(0);
}//End of method clearFields.

//Reset the applet to allow the user to perform a new search.
private void resetSearch()
{
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
clearFields();
createSocket(ServerName_);
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//End of method resetSearch.

//Perform Input/Output operations with the server.
private void serverIO()
{
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

try
{
PrintWriter out =
new PrintWriter(
new BufferedWriter(
new OutputStreamWriter(
s.getOutputStream())),true);


System.out.println("Check point 1 @ serverIO method.");
out.println(inquirylist.getItem(inquirylist.getSelectedIndex()));
// Thread.currentThread().sleep(5000);
System.out.println("Check point 2 @ serverIO method.");
//Read data back from server - Inputstream
ObjectInputStream inObj = new
ObjectInputStream(s.getInputStream());
System.out.println("Check point 3 @ serverIO method.");
out.flush();
System.out.println("Check point 4 @ serverIO method.");

td = (TestData) inObj.readObject();

s.close();
if(td.bRecFound)
displayResults();
else
resetSearch();
}
catch(Exception e)
{
System.out.println("Check point 1 - Exception: " + e);

}//End of try/catch block

this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//End of method ServerIO


//Event handling method.
public void actionPerformed(ActionEvent evt)
{
if(evt.getSource() == theClearButton_)
{
clearFields();
repaint();
}
else if(evt.getSource() == theSubmitButton_)
{
if(createSocket(ServerName_))
{
System.getSecurityManager();

// searchLabelSetup();
validate();
System.out.println(s.getInetAddress());
serverIO();
repaint();
}
else
socketConnectionRefused();
}
}//End of method actionPerformed


//Methodsfor handling for keyboard events
public void keyPressed(KeyEvent evt){}
public void keyReleased(KeyEvent evt){}
public void keyTyped(KeyEvent evt)
{
// System.out.println(" " + (int)evt.getKeyChar() );

if(evt.getSource() == theClearButton_)
{
clearFields();
repaint();
}
else if(evt.getSource() == theSubmitButton_)
{
serverIO();
repaint();
}
}//End of method keyTyped.

public void mouseClicked(MouseEvent evt)
{
if(evt.getClickCount() == 2)
{
}
}
public void mouseExited(MouseEvent event){}
public void mouseEntered(MouseEvent event){}
public void mouseReleased(MouseEvent event){}
public void mousePressed(MouseEvent event){}

}//End of class ApplSide.

class TestData implements Serializable
{
private static final long serialVersionUID = 1;

/* Test Data */
public String sField_1, sField_2, sField_3, sField_4, sField_5;
public boolean bRecFound;

//Constructor
TestData()
{}
}//End of class ServerTestData.

- - - - - - - - - - - - - - - - -
- - - -

/* Class name: ServerSide

Author: Steven Rulison

Purpose: Demonstrate the servlet side
*/

import java.io.*;
import java.util.*;
import java.net.*;

public class ServerSide extends Thread
{
private TestData td;
private Socket s;
private String sSearchField_;

public static void main(String[] Args)
{
try
{
ServerSocket ss = new ServerSocket(554);

int spawnCnt = 0;
while(true)
{
Socket s = ss.accept();

++spawnCnt;
System.out.println("Spawning " + spawnCnt);


Thread servSide = new Thread(new ServerSide(s), "serverside");
servSide.start();
}
}catch(IOException e)
{
e.printStackTrace(System.err);
}
}//End of main.


//Constructor.
public ServerSide(Socket s_)
{
s = s_;
}//End of Constructor.


private void testLookup(String sSearch)
{
td = new TestData();
td.bRecFound = true;
if(sSearch.trim().equals("Test 1"))
{
td.sField_1 = "Alpha";
td.sField_2 = "Beta";
td.sField_3 = "Gamma";
td.sField_4 = "Delta";
td.sField_5 = "Epsilon";
}
else if(sSearch.trim().equals("Test 2"))
{
td.sField_1 = "AAA";
td.sField_2 = "BBB";
td.sField_3 = "CCC";
td.sField_4 = "DDDD";
td.sField_5 = "EEEE";
}
else if(sSearch.trim().equals("Test 3"))
{
td.sField_1 = "111";
td.sField_2 = "222";
td.sField_3 = "333";
td.sField_4 = "444";
td.sField_5 = "555";
}
}// End of method testLookup.

public void run()
{
try
{
//Setup Input Stream.
BufferedReader in =
new BufferedReader( new InputStreamReader(s.getInputStream()));

// Setup output Stream.
ObjectOutputStream ObjOut = new
ObjectOutputStream(s.get());

//Perform intial read...
sSearchField_ = in.readLine();

Thread.currentThread().sleep(5000);

System.out.println("The sSearchField_ variable = " + sSearchField_);

testLookup(sSearchField_);

ObjOut.writeObject(td);
ObjOut.flush();
ObjOut.close();

s.close();
}
catch(Exception e)
{
e.printStackTrace(System.err);
}
}//End of run method
}//End of ServerSide class...


/*
This is the class template that will be used to create the object
that will
be passed through to the ObjectInput/Output - stream to the lookup
applet.
*/
class TestData implements Serializable
{
private static final long serialVersionUID = 1;

/* Test Data */
public String sField_1, sField_2, sField_3, sField_4, sField_5;
public boolean bRecFound;

//Constructor
TestData()
{}

}//End of class ServerTestData.

I may have done you a bad turn here. I think your problem is because
you aren't creating an ObjectOutputStream on the socket before you
create your ObjectInputStream. I think they have to be matched (at
least if you are going to do input) on the socket and the
ObjectOutputStream has to be created first. This is a known source of
hangs. I was too hasty reading your post the first time.
 
I

ILPTAB

ILPTAB said:
I am currently supporting an interactive web site for a state agency.
Recently we started getting reports from SOME of the users that the
applet hangs when they attempt to submit data to the servlet running
on our web server. We have not made any changes to the java code so
the only thing I can figure is that it must be happening as a result
of an update to the java JRE or Windows. Note that I said it's
occurring with SOME of the users. Other people seem to be having no
problem at all with it.
To help illustrate the problem, I put together a small test server and
applet that demonstrates the problem. I have included the source code
for both parts below. On the applet side, it hangs when it comes to a
line that attempts to instantiate the ObjectInputStream class and
retrieve the input stream from the applet.
ObjectInputStream inobj = new ObjectInputStream(s.getInputStream());
Since the applet locks up, I am unable to give you any error messages
in the java console. In fact the browser gets so locked up that it
requires the user to close the session from the Windows task manager.
On the Servlet side it hangs at the line that attempts to read the
data stream from the socket connection.
sSearchField_ = in.readLine();
The error messages generated at the server are as follows:
Java.lang.NullpointerException at ServerSide.testLookup(ServerSide.54)
at ServerSide.run(ServerSide.java.98)
at jave.lang.thread.run(Unkown Source)
Any help in resolving this problem would be greatly appricated.
Thank you.
Here is the source code for both the Servlet and the applet.
/* Class Name: AppletSide.java
Copyright © 2007 Steve Rulison
Version 1.0.0
Purpose: This java applet will display relevent information
pertaining to
this examplet
*/
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.*;
import java.util.*;
import java.net.*;
import java.lang.*;
public class AppletSide extends JApplet
implements ActionListener, KeyListener, MouseListener, Serializable
{
private static final long serialVersionUID = 1;
private JButton theSubmitButton_, theClearButton_;
private Socket s;
private String host, ServerName_;
private TestData td;
private JPanel appletPanel, resultPanel, buttonPanel,
socketPanel, headingPanel;
private Font f1 = new Font("Sansserf", Font.BOLD, 28);
private JLabel socketConnectionLabel = new JLabel("");
private JTextField resultField1, resultField2, resultField3,
resultField4, resultField5;
private java.awt.List inquirylist;
//Constructor
public AppletSide()
{
headingPanel = new JPanel();
headingPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
//Initialize String variables for output.
searchSetup();
}//Constructor
public void init()
{
// Note: The getCodeBase().getHost() methods must be invoked from
the
// init() method.
ServerName_ = getCodeBase().getHost();
System.out.println(ServerName_);
System.out.println("Test Applet Version");
}//End of init.
//Establish a socket connection with the server.
private boolean createSocket(String pServerName)
{
boolean SocketConnectSuccessful = false;
try
{
int iPort = 554;
s = new Socket(pServerName, iPort);
SocketConnectSuccessful = true;
socketConnectionLabel.setText("Socket connection successfully
established with host " + pServerName + " on port " + iPort);
socketPanel.validate();
}
catch(Exception e)
{
e.printStackTrace(System.err);
System.out.println(e);
SocketConnectSuccessful = false;
socketConnectionRefused();
}//End of catch block.
return SocketConnectSuccessful;
}//End of method createSocket.
//This method is called when a socket connection could not be
established.
private void socketConnectionRefused()
{
socketConnectionLabel.setText("Unable to establish a connection with
host. Please contact you network administrator.");
socketPanel.validate();
}//End of method socketConnectionRefused.
//Setup search Inquiry labels.
private void searchSetup()
{
setLayout(new BorderLayout());
appletPanel = new JPanel();
appletPanel.setLayout(new GridLayout(0,1));
JLabel titleLabel = new JLabel("Test Page");
titleLabel.setFont(f1);
titleLabel.setForeground(Color.black);

JPanel inquiryPanel = new JPanel();
inquiryPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
JLabel inquiryLabel = new JLabel("Make Selection: ");
inquiryPanel.add(inquiryLabel);
inquirylist = new java.awt.List();
inquirylist.add("Test 1");
inquirylist.add("Test 2");
inquirylist.add("Test 3");
inquirylist.select(0);



socketPanel = new JPanel();
socketPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
socketPanel.add(socketConnectionLabel);
appletPanel.add(socketPanel);
buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
theSubmitButton_ = new JButton("Submit");
theSubmitButton_.addActionListener(this);
theSubmitButton_.addKeyListener(this);
buttonPanel.add(theSubmitButton_);
theClearButton_ = new JButton("Clear");
theClearButton_.addActionListener(this);
theClearButton_.addKeyListener(this);
buttonPanel.add(theClearButton_);
appletPanel.add(buttonPanel);
add(BorderLayout.CENTER, appletPanel);
}//End of method searchLabelSetup.
//Setup result labels.
private void resultSetup()
{
resultPanel = new JPanel();
resultPanel.setLayout(new GridLayout(5,2));
JLabel resultLabel1 = new JLabel("Field 1: ", JLabel.RIGHT);
JLabel resultLabel2 = new JLabel("Field 2: ", JLabel.RIGHT);
JLabel resultLabel3 = new JLabel("Field 3: ", JLabel.RIGHT);
JLabel resultLabel4 = new JLabel("Field 4: ", JLabel.RIGHT);
JLabel resultLabel5 = new JLabel("Field 5: ", JLabel.RIGHT);
resultField1 = new JTextField("Default value 1", 5);
resultField1.setEditable(false);
resultField2 = new JTextField("Default value 2 ",5);
resultField2.setEditable(false);
resultField3 = new JTextField("Default value 3",5);
resultField3.setEditable(false);
resultField4 = new JTextField("Default value 4",5);
resultField4.setEditable(false);
resultField5 = new JTextField("Default value 5",5);
resultField5.setEditable(false);


}//End of method resultLabelSetup.
// Display the fields that have been populated with data received
from the
// server application.
private void displayResults()
{
resultField1.setText(td.sField_1);
resultField2.setText(td.sField_2);
resultField3.setText(td.sField_3);
resultField4.setText(td.sField_4);
resultField5.setText(td.sField_5);
resultPanel.validate();
}//End of method displayResults.
//Clears fields of data
private void clearFields()
{
resultField1.setText("Default value 1");
resultField2.setText("Default value 2");
resultField3.setText("Default value 3");
resultField4.setText("Default value 4");
resultField5.setText("Default value 5");
resultPanel.validate();
inquirylist.select(0);
}//End of method clearFields.
//Reset the applet to allow the user to perform a new search.
private void resetSearch()
{
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
clearFields();
createSocket(ServerName_);
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//End of method resetSearch.
//Perform Input/Output operations with the server.
private void serverIO()
{
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
try
{
PrintWriter out =
new PrintWriter(
new BufferedWriter(
new OutputStreamWriter(
s.getOutputStream())),true);
System.out.println("Check point 1 @ serverIO method.");
out.println(inquirylist.getItem(inquirylist.getSelectedIndex()));
// Thread.currentThread().sleep(5000);
System.out.println("Check point 2 @ serverIO method.");
//Read data back from server - Inputstream
ObjectInputStream inObj = new
ObjectInputStream(s.getInputStream());
System.out.println("Check point 3 @ serverIO method.");
out.flush();
System.out.println("Check point 4 @ serverIO method.");
td = (TestData) inObj.readObject();
s.close();
if(td.bRecFound)
displayResults();
else
resetSearch();
}
catch(Exception e)
{
System.out.println("Check point 1 - Exception: " + e);
}//End of try/catch block
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//End of method ServerIO
//Event handling method.
public void actionPerformed(ActionEvent evt)
{
if(evt.getSource() == theClearButton_)
{
clearFields();
repaint();
}
else if(evt.getSource() == theSubmitButton_)
{
if(createSocket(ServerName_))
{
System.getSecurityManager();
// searchLabelSetup();
validate();
System.out.println(s.getInetAddress());
serverIO();
repaint();
}
else
socketConnectionRefused();
}
}//End of method actionPerformed
//Methodsfor handling for keyboard events
public void keyPressed(KeyEvent evt){}
public void keyReleased(KeyEvent evt){}
public void keyTyped(KeyEvent evt)
{
// System.out.println(" " + (int)evt.getKeyChar() );
if(evt.getSource() == theClearButton_)
{
clearFields();
repaint();
}
else if(evt.getSource() == theSubmitButton_)
{
serverIO();
repaint();
}
}//End of method keyTyped.
public void mouseClicked(MouseEvent evt)
{
if(evt.getClickCount() == 2)
{
}
}
public void mouseExited(MouseEvent event){}
public void mouseEntered(MouseEvent event){}
public void mouseReleased(MouseEvent event){}
public void mousePressed(MouseEvent event){}
}//End of class ApplSide.
class TestData implements Serializable
{
private static final long serialVersionUID = 1;
/* Test Data */
public String sField_1, sField_2, sField_3, sField_4, sField_5;
public boolean bRecFound;
//Constructor
TestData()
{}
}//End of class ServerTestData.
- - - - - - - - - - - - - - - - -
- - - -
/* Class name: ServerSide
Author: Steven Rulison
Purpose: Demonstrate the servlet side
*/
import java.io.*;
import java.util.*;
import java.net.*;
public class ServerSide extends Thread
{
private TestData td;
private Socket s;
private String sSearchField_;
public static void main(String[] Args)
{
try
{
ServerSocket ss = new ServerSocket(554);
int spawnCnt = 0;
while(true)
{
Socket s = ss.accept();
++spawnCnt;
System.out.println("Spawning " + spawnCnt);
Thread servSide = new Thread(new ServerSide(s), "serverside");
servSide.start();
}
}catch(IOException e)
{
e.printStackTrace(System.err);
}
}//End of main.
//Constructor.
public ServerSide(Socket s_)
{
s = s_;
}//End of Constructor.
private void testLookup(String sSearch)
{
td = new TestData();
td.bRecFound = true;
if(sSearch.trim().equals("Test 1"))
{
td.sField_1 = "Alpha";
td.sField_2 = "Beta";
td.sField_3 = "Gamma";
td.sField_4 = "Delta";
td.sField_5 = "Epsilon";
}
else if(sSearch.trim().equals("Test 2"))
{
td.sField_1 = "AAA";
td.sField_2 = "BBB";
td.sField_3 = "CCC";
td.sField_4 = "DDDD";
td.sField_5 = "EEEE";
}
else if(sSearch.trim().equals("Test 3"))
{
td.sField_1 = "111";
td.sField_2 = "222";
td.sField_3 = "333";
td.sField_4 = "444";
td.sField_5 = "555";
}
}// End of method testLookup.
public void run()
{
try
{
//Setup Input Stream.
BufferedReader in =
new BufferedReader( new InputStreamReader(s.getInputStream()));
// Setup output Stream.
ObjectOutputStream ObjOut = new
ObjectOutputStream(s.get());
//Perform intial read...
sSearchField_ = in.readLine();

System.out.println("The sSearchField_ variable = " + sSearchField_);


s.close();
}
catch(Exception e)
{
e.printStackTrace(System.err);
}
}//End of run method
}//End of ServerSide class...
/*
This is the class template that will be used to create the object
that will
be passed through to the ObjectInput/Output - stream to the lookup
applet.
*/
class TestData implements Serializable
{
private static final long serialVersionUID = 1;
/* Test Data */
public String sField_1, sField_2, sField_3, sField_4, sField_5;
public boolean bRecFound;

}//End of class ServerTestData.

I may have done you a bad turn here. I think your problem is because
you aren't creating an ObjectOutputStream on the socket before you
create your ObjectInputStream. I think they have to be matched (at
least if you are going to do input) on the socket and the
ObjectOutputStream has to be created first. This is a known source of
hangs. I was too hasty reading your post the first time.

Interesting. I will look into it. The only thing is, it dosen't do
it consistanntly. The applet hangs for some people amd not on
others. Never the less, I will make the changes you suggested and see
how that works. Thanks for you imput.

Steve R.
 
K

Knute Johnson

ILPTAB said:
Interesting. I will look into it. The only thing is, it dosen't do
it consistanntly. The applet hangs for some people amd not on
others. Never the less, I will make the changes you suggested and see
how that works. Thanks for you imput.

Steve R.

Steve:

Sorry I didn't look at it more closely when you first posted. It
sounded just like the problem I'm having. Please post here if you get
it to work.
 
R

Roedy Green

Any help in resolving this problem would be greatly appricated.

I would put a version number in the Applet and SerialVersionUIDs on
all transported classes. Have the applet display its version number
first thing so you can be sure you are getting a fresh copy, not
something in cache.

Further I would put a Long as the first item in the stream; it is a
stream version number. It might just be a serialVersionUID of an
important class. Read and compare and if it does not match, bitch up
front rather than getting into some corner that hangs you.
 
N

Nigel Wade

ILPTAB said:
I am currently supporting an interactive web site for a state agency.
Recently we started getting reports from SOME of the users that the
applet hangs when they attempt to submit data to the servlet running
on our web server. We have not made any changes to the java code so
the only thing I can figure is that it must be happening as a result
of an update to the java JRE or Windows. Note that I said it's
occurring with SOME of the users. Other people seem to be having no
problem at all with it.

To help illustrate the problem, I put together a small test server and
applet that demonstrates the problem. I have included the source code
for both parts below. On the applet side, it hangs when it comes to a
line that attempts to instantiate the ObjectInputStream class and
retrieve the input stream from the applet.

ObjectInputStream inobj = new ObjectInputStream(s.getInputStream());

Since the applet locks up, I am unable to give you any error messages
in the java console. In fact the browser gets so locked up that it
requires the user to close the session from the Windows task manager.

On the Servlet side it hangs at the line that attempts to read the
data stream from the socket connection.

sSearchField_ = in.readLine();

The error messages generated at the server are as follows:

Java.lang.NullpointerException at ServerSide.testLookup(ServerSide.54)

at ServerSide.run(ServerSide.java.98)

at jave.lang.thread.run(Unkown Source)


Any help in resolving this problem would be greatly appricated.

Thank you.

There may be a potential for a dead-lock situation in your input/output streams,
with the establishment of the ObjectOutputStream/ObjectInputStream.

Creating an ObjectOutputStream writes the stream header, and if this isn't
flushed the client may block in its ObjectInputStream constructor. Try adding a
flush() to the server ObjectOutputStream immediately after it's opened, before
reading the request from the client. The client ObjectInputStream constructor
might block reading the stream header which the server hasn't flushed.

Also, flushing the client PrintWriter *before* attempting to create the
ObjectInputStream might release the dead-lock. The server could be blocked
reading the request, so it hasn't got around to sending the response. If the
client request is flushed the server could complete reading the request and
send the response, thus effectively flushing the server ObjectOutputStream
stream header and releasing the client ObjectInputStream constructor.
 
R

Richard Maher

Hi Knute,

Sorry I never saw your reply until Steve quoted it in his subsequent reply.

I do recall your thread, but it did go on for some time and I can't remember
the outcome; I'd genuinely like to know so if you'd care to post the
reader's digest version here that'd be great!

I use the timeout a lot with quasi-polling and dickie-server detection and
(to date) have not had a problem. Was yours server-death or unresponsiveness
that led to the timeout not occuring? I've used it with IP stacks that
do/don't support full_duplex_close and still haven't had a problem.

Cheers Richard Maher
 
I

ILPTAB

There may be a potential for a dead-lock situation in your input/output streams,
with the establishment of the ObjectOutputStream/ObjectInputStream.

Creating an ObjectOutputStream writes the stream header, and if this isn't
flushed the client may block in its ObjectInputStream constructor. Try adding a
flush() to the server ObjectOutputStream immediately after it's opened, before
reading the request from the client. The client ObjectInputStream constructor
might block reading the stream header which the server hasn't flushed.

Also, flushing the client PrintWriter *before* attempting to create the
ObjectInputStream might release the dead-lock. The server could be blocked
reading the request, so it hasn't got around to sending the response. If the
client request is flushed the server could complete reading the request and
send the response, thus effectively flushing the server ObjectOutputStream
stream header and releasing the client ObjectInputStream constructor.

--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : (e-mail address removed)
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555- Hide quoted text -

- Show quoted text -

To everybody that has responded to my post, I want to thank you for
your input. I'm really getting some great suggestions here but
unfortunatly, I am in class all this week and will probably not be
able to get back to this problem until early next week. At that time
I am looking forward to trying these suggestions. I just didn't want
anybody to think that I had lost interest in this.

Thank you all again.

Steve.
 
K

Knute Johnson

My problem is a true hang in socket stream I/O. It won't timeout and I
can't close the socket and get it to throw an exception. It's just
hung. The most annoying part about it is I can't duplicate it.

That's it in a nutshell.
 
I

ILPTAB

Update:
Well I finally got around to trying Nigel's suggestion of calling the
flush() method after the ObjectOutputStream is opened. Unfortunately
this did not resolve the problem.

Can anybody think of a reason why this problem would occur on some
computers and not on others? I know that Roedy suggested that there
may be an issue with the version of a class that has been cached into
the windows browser but the code I posted above was compiled and
published to our web server exactly one time. How could there be a
version conflict with that? That being said I will start adding the
version info to code just in case.

I just find it so darn perplexing that the site works for some people
and not for others.

Could this be a FIREWALL issue?

Steve Rulison.
 
R

Roedy Green

Could this be a FIREWALL issue?

Get a sniffer, e.g. Wireshark, http://mindprod.com/jgloss/sniffer.html
and watch the traffic to see what is happening.

Use my HTTP class to do the GET/POST. Dump every byte (not char) as
you get it to futher help figure what is happening.

You may want some sort of timeout like I have in HTTP.

See http://mindprod.com/products1.html#HTTP

You can also instrument your server app to log every byte it receives
and sends to that Applet.
 
N

Nigel Wade

ILPTAB said:
Update:
Well I finally got around to trying Nigel's suggestion of calling the
flush() method after the ObjectOutputStream is opened. Unfortunately
this did not resolve the problem.

Can anybody think of a reason why this problem would occur on some
computers and not on others? I know that Roedy suggested that there
may be an issue with the version of a class that has been cached into
the windows browser but the code I posted above was compiled and
published to our web server exactly one time. How could there be a
version conflict with that? That being said I will start adding the
version info to code just in case.

I just find it so darn perplexing that the site works for some people
and not for others.

Is there anything in common with the clients which fail? Windows patch level,
JRE version, browser etc. I'd go with Roedy's suggestion and use Wireshark to
look at the packets on the wire to see what's being sent between the applet and
the server.
Could this be a FIREWALL issue?

I doubt it, unless it's a badly broken firewall. I don't see how a properly
functioning firewall could result in that scenario.
 
I

ILPTAB

Is there anything in common with the clients which fail? Windows patch level,
JRE version, browser etc. I'd go with Roedy's suggestion and use Wireshark to
look at the packets on the wire to see what's being sent between the applet and
the server.




I doubt it, unless it's a badly broken firewall. I don't see how a properly
functioning firewall could result in that scenario.

--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : (e-mail address removed)
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555- Hide quoted text -

- Show quoted text -

I have been trying to find that commonality but have not been able to
put my finger on it yet. Here is something that we did find however"

After conferring with a technician in the field, we have some
additional information that we think may help resolve this issue.
Apparently there is a message line in the Java console that reads
"Network: Connecting socket://www.ptab.illinois.gov:554 with
proxy=DIRECT." This is significant because it indicates that the
Servlet and or applet is forcing a direct connection and is trying to
circumvent their firewall. The technician tells me that this is why
the applet is hanging and he believes that it's occurring as a result
of the way the java application is coded. Unfortunately, I do not
know how to code this so that it doesn't try to do a direct connect
instead of going through the proxy. Do you have any idea why this is
occuring? You can refer to the code I provided above to see how I am
setting up the socket connection on both sides.

Thank you.
 
I

ILPTAB

Is there anything in common with the clients which fail? Windows patch level,
JRE version, browser etc. I'd go with Roedy's suggestion and use Wireshark to
look at the packets on the wire to see what's being sent between the applet and
the server.




I doubt it, unless it's a badly broken firewall. I don't see how a properly
functioning firewall could result in that scenario.

--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : (e-mail address removed)
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555- Hide quoted text -

- Show quoted text -

One more thing:
I have the output from the JAVA console. Maybe this can be of some
help. Here it is:


Java Plug-in 1.5.0_05
Using JRE version 1.5.0_05 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\sruliso
network: Loading user-defined proxy configuration ...
network: Done.
network: Loading proxy configuration from Internet Explorer ...
network: Auto config URL: http://webt1resv.ilptab.il.us:8080/array.dll?Get.Routing.Script
network: Done.
network: Loading auto proxy configuration ...
network: Downloading auto proxy file from
http://webt1resv.ilptab.il.us:8080/array.dll?Get.Routing.Script
network: Done.
network: Proxy Configuration: Automatic Proxy Configuration
URL: http://webt1resv.ilptab.il.us:8080/array.dll?Get.Routing.Script

basic: Cache is enabled
basic: Location: C:\Documents and Settings\sruliso\Application Data\Sun
\Java\Deployment\cache\javapi\v1.0
basic: Maximum size: unlimited
basic: Compression level: 0

----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

basic: Registered modality listener
liveconnect: Invoking JS method: document
liveconnect: Invoking JS method: URL
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@199f91c,
refcount=1
basic: Registered modality listener
liveconnect: Invoking JS method: document
basic: Unregistered modality listener
basic: Unable to obtain Document object
basic: Unregistered modality listener
basic: Registered modality listener
liveconnect: Invoking JS method: document
liveconnect: Invoking JS method: URL
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@199f91c,
refcount=2
basic: Added progress listener: sun.plugin.util.GrayBoxPainter@860d49
basic: Loading applet ...
basic: Initializing applet ...
basic: Starting applet ...
basic: Added progress listener: sun.plugin.util.GrayBoxPainter@910040
basic: Loading applet ...
basic: Initializing applet ...
basic: Starting applet ...
liveconnect: Invoking JS method: execScript
liveconnect: Invoking JS method: evalIntermediateValueToReturn
network: Connecting http://www.ptab.illinois.gov/Applet/PTABLookup.jar
with proxy=HTTP @ webt1resv.ilptab.il.us/10.44.1.217:8080
network: Connecting http://www.ptab.illinois.gov/Applet/PTABLookup.jar
with proxy=HTTP @ webt1resv.ilptab.il.us/10.44.1.217:8080
basic: Loading http://www.ptab.illinois.gov/Applet/PTABLookup.jar from
cache
basic: No certificate info, this is unsigned JAR file.
www.ptab.illinois.gov
Development Version
liveconnect: Invoking JS method: execScript
liveconnect: Invoking JS method: evalIntermediateValueToReturn
network: Connecting socket://www.ptab.illinois.gov:554 with
proxy=DIRECT
www.ptab.illinois.gov
Development Version
network: Connecting socket://www.ptab.illinois.gov:554 with
proxy=DIRECT
www.ptab.illinois.gov/163.191.147.10
www.ptab.illinois.gov/163.191.147.10
Checkpoint 1 @ Server IO Method.
Checkpoint 2 @ Server IO Method.
 
I

ILPTAB

Is there anything in common with the clients which fail? Windows patch level,
JRE version, browser etc. I'd go with Roedy's suggestion and use Wireshark to
look at the packets on the wire to see what's being sent between the applet and
the server.




I doubt it, unless it's a badly broken firewall. I don't see how a properly
functioning firewall could result in that scenario.

--
Nigel Wade, System Administrator, Space Plasma Physics Group,
            University of Leicester, Leicester, LE1 7RH, UK
E-mail :    (e-mail address removed)
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555- Hide quoted text -

- Show quoted text -

One more piece of info and then I promiss I'll stop. Here is a copy
the routing script that my web browser calls: I don't pretend to
understand it but I couldn't help but notice that it has the word
DIRECT in it all over the place.

//Copyright (c) 1997 Microsoft Corporation
BackupRoute="DIRECT";
UseDirectForLocal=true;
function MakeIPs(){
this[0]="10.0.0.0";
this[1]="255.0.0.0";
}
DirectIPs=new MakeIPs();
cDirectIPs=2;
function MakeNames(){
this[0]="*.ilptab.il.us";
}
DirectNames=new MakeNames();
cDirectNames=1;
cNodes=1;
function MakeProxies(){
this[0]=new Node("webT1Resv.ilptab.il.us:8080",0,1.000000);
}
Proxies = new MakeProxies();
function Node(name, hash, load){
this.name = name;
this.hash = hash;
this.load = load;
this.score = 0;
return this;
}
function FindProxyForURL(url, host){
var urlhash, ibest, bestscore, list, i, j;
if (UseDirectForLocal && isPlainHostName(host))
return "DIRECT";
if (cDirectNames > 0)
for (i = 0; i < cDirectNames; i++)
if (shExpMatch(host, DirectNames))
return "DIRECT";
if (cDirectIPs > 0)
for (i = 0; i < cDirectIPs; i += 2)
if (isInNet(host, DirectIPs, DirectIPs[i+1]))
return "DIRECT";
urlhash = HashString(url);
for (i = 0; i < cNodes; i++)
Proxies.score = Proxies.load * Scramble(MakeInt(urlhash ^
Proxies.hash));
list = "";
for (j = 0; j < cNodes; j++) {
for (bestscore = -1, i = 0; i < cNodes; i++) {
if (Proxies.score > bestscore) {
bestscore = Proxies.score;
ibest = i;
}
}
Proxies[ibest].score = -1;
list = list + "PROXY " + Proxies[ibest].name + "; ";
}
list = list + BackupRoute;
return list;
}
function HashString(url){
var h = 0;
var slashes = 0;
for (var i = 0; i < url.length; i++) {
var c = url.charAt(i);
if (c == '/')
slashes++;
if (slashes < 3)
c = c.toLowerCase();
h += (((h & 0x1fff) << 19) | ((h >> 13) & 0x7ffff)) +
CharToAscii(c);
h = MakeInt(h);
}
return h;
}
function Scramble(h){
h += ((h & 0xffff) * 0x1965) + ((((h >> 16) & 0xffff) * 0x1965) <<
16) + (((h & 0xffff) * 0x6253) << 16);
h = MakeInt(h);
h += (((h & 0x7ff) << 21) | ((h >> 11) & 0x1fffff));
return MakeInt(h);
}
var Chars =" !\"#$%&\'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~
€Â???????????ÂŽÂÂ????????????ž? ¡¢£¤¥¦§¨©ª«¬­®¯°±²³
´µ¶·¸¹º»¼½¾¿ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖ×ØÙÚÛÜÃÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ
";
function CharToAscii(c){
return Chars.indexOf(c) + 32;
}
function MakeInt(x){
if (x < 0) {
return x + 4294967296;
} else if (x >= 4294967296) {
return x - 4294967296;
}
return x;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top