P
pcouas
Hi,
I have folliwing error on JDK 1.3.1, that's was ok before ?
Where is my Mistake ?
Regards
Philippe
java.lang.VerifyError: (class: util/generic/URLConnectionT$MTimer,
method: <init
at
util.generic.URLConnectionT.connectToHere(URLConnectionT.java(Compile
d Code))
at
util.generic.URLConnectionT.connectToHere(URLConnectionT.java(Compile
d Code))
at
servlet24.TestServlet.setFixPostsBean(TestServlet.java(Compiled Code)
)
package util.generic;
//Sert a tester,
import java.net.*;
import java.io.*;
public class URLConnectionT implements TimeOutListener,
URLResponseListener
{
class MTimer extends Thread
{
private long timeOutInterval = 3000L;
TimeOutListener listener = null;
boolean continueThread = true;
boolean debug = false;
public MTimer(long timeOut, TimeOutListener l)
{
super("Time Out Thread");
System.out.println("Tmier apsuper");
timeOutInterval = timeOut;
listener = l;
}
public void stopTimer()
{
if(debug)System.out.println("Timer stopped");
continueThread = false;
}
public void run()
{
if(debug)System.out.println("Running Timer");
long actualTimeSlept = 0L;
while( (actualTimeSlept < timeOutInterval) &&
continueThread)
{
long l1 = System.currentTimeMillis();
try
{
sleep(timeOutInterval);
}
catch(Exception e) // InterruptedException
{
continueThread = false;
}
long l2 = System.currentTimeMillis();
actualTimeSlept += l2 - l1;
}
if(continueThread)
listener.timedOut(timeOutInterval);
if(debug)System.out.println("Running Compete");
} // fin run
} //fin class Thread MTimer
static boolean responseAvailable = false; //permet de mettre
fin au Thread
public URLRequester uR;
private long timeSleep = 1000L;
MTimer timer;
boolean debug = false;
private boolean isok = false;
public URLConnectionT()
{
super();
}
public URLConnectionT(boolean d)
{
this();
debug=d;
}
public synchronized void error(String s)
{
System.out.println(s);
}
public synchronized void timedOut(long mtimeOutInterval)
{
if(debug)System.out.println("Connection timedOut1");
uR.stopRequest();
timer.stopTimer();
if(debug)System.out.println("Connection timedOut2");
responseAvailable = true;
}
public synchronized void done()
{
isok = true;
timer.stopTimer();
uR.stopRequest();
if(debug)System.out.println("Success");
responseAvailable = true; // met fin du
Thread
// isok = true;
}
// other methods for various HTTP Response Types..
public boolean connectToHere(String sURL)
{
return this.connectToHere(sURL,null);
}
public boolean connectToHere(String sURL,OutputStream mout)
{
isok = false;
if(debug)System.out.println("Starting to connect to : "
+ sURL);
System.out.println("URLConnection AvTimer");
timer = new MTimer(100, this);
try
{
uR = new URLRequester(new URL(sURL),
this,debug,mout); //creation du Thread
/* }
catch (MalformedURLException e)
{}*/
responseAvailable = false;
timer.start(); //demmarrage timeout
uR.start(); //demmarrage thread de test
while(!responseAvailable)
{
try
{
Thread.sleep(timeSleep);
}
catch(InterruptedException e)
{
}
} // fin while
if(debug)System.out.println("Done");
}
catch (Exception e)
{}
return isok;
} // fin methode connectToHere
class URLRequester extends Thread
{
URL urlToOpen;
URLResponseListener listener;
BufferedInputStream dis = null;
OutputStream out=null;
URLRequester(URL urlToRead, URLResponseListener ul,boolean
mdebug, OutputStream mout)
{
urlToOpen = urlToRead;
listener = ul;
debug=mdebug;
out=mout;
}
URLRequester(URL urlToRead, URLResponseListener ul)
{
urlToOpen = urlToRead;
listener = ul;
debug=false;
}
boolean continueThread = true;
public void stopRequest()
{
if(debug)System.out.println("Request Stopped");
continueThread = false;
}
public void run()
{
if(debug)System.out.println("Starting request.");
dis = null;
while( continueThread )
{
try
{
URLConnection uc =
urlToOpen.openConnection(); // no connection yet
uc.setUseCaches(false); //
possibly user specified.
if(debug)System.out.println("Connecting....");
uc.connect(); // request for
connection now!!! throws IOException here ,
if(debug)System.out.println("Opening....");
dis = new
BufferedInputStream(uc.getInputStream()); // throws IOException
here .try again
if(debug)System.out.println("DoneStream.");
// read the data in a loop
if(out!=null)
{
byte buf[] = new byte[2048];
int len;
if(debug)System.out.println("DoneStream out.");
while (true)
{
try
{
len = dis.read(buf);
if(debug)System.out.println("WriteStream01. "+len);
if (len<1)//done?
{
out.flush();
break;
}
}
catch (Exception e)
{
System.out.println("Err run
Stream. ");
break;
}
try
{
if(debug)System.out.println("WriteStream02. "+len);
out.write(buf,0,len);
if(debug)System.out.println("WriteStream03. "+len);
}
catch (Exception e)
{
System.out.println("Err run
Stream02. "+e.getMessage());
}
}//while
if(debug)System.out.println("WriteStream End. ");
}
dis.close(); // throws an exception
continueThread = false; // because we
are done.
listener.done();
}
catch(IOException e) // catch errors while
connecting and reading from the input stream.
{
// notify the user that the HTTP Reqest
failed using the HTTPResponseListener
listener.error(e.toString());
continueThread = false;
return;
}
}
if(dis!=null)
{
try { dis.close(); }
catch (IOException e) {}
dis = null;
}
if(debug)System.out.println("Request Complete.");
}
}
}
package util.generic;
public interface TimeOutListener
{
public void timedOut(long l);
}
I have folliwing error on JDK 1.3.1, that's was ok before ?
Where is my Mistake ?
Regards
Philippe
java.lang.VerifyError: (class: util/generic/URLConnectionT$MTimer,
method: <init
signature: (Lutil/generic/URLConnectionT;JLutil/generic/TimeOutListenerV) Expecting to find object/array on stack
at
util.generic.URLConnectionT.connectToHere(URLConnectionT.java(Compile
d Code))
at
util.generic.URLConnectionT.connectToHere(URLConnectionT.java(Compile
d Code))
at
servlet24.TestServlet.setFixPostsBean(TestServlet.java(Compiled Code)
)
package util.generic;
//Sert a tester,
import java.net.*;
import java.io.*;
public class URLConnectionT implements TimeOutListener,
URLResponseListener
{
class MTimer extends Thread
{
private long timeOutInterval = 3000L;
TimeOutListener listener = null;
boolean continueThread = true;
boolean debug = false;
public MTimer(long timeOut, TimeOutListener l)
{
super("Time Out Thread");
System.out.println("Tmier apsuper");
timeOutInterval = timeOut;
listener = l;
}
public void stopTimer()
{
if(debug)System.out.println("Timer stopped");
continueThread = false;
}
public void run()
{
if(debug)System.out.println("Running Timer");
long actualTimeSlept = 0L;
while( (actualTimeSlept < timeOutInterval) &&
continueThread)
{
long l1 = System.currentTimeMillis();
try
{
sleep(timeOutInterval);
}
catch(Exception e) // InterruptedException
{
continueThread = false;
}
long l2 = System.currentTimeMillis();
actualTimeSlept += l2 - l1;
}
if(continueThread)
listener.timedOut(timeOutInterval);
if(debug)System.out.println("Running Compete");
} // fin run
} //fin class Thread MTimer
static boolean responseAvailable = false; //permet de mettre
fin au Thread
public URLRequester uR;
private long timeSleep = 1000L;
MTimer timer;
boolean debug = false;
private boolean isok = false;
public URLConnectionT()
{
super();
}
public URLConnectionT(boolean d)
{
this();
debug=d;
}
public synchronized void error(String s)
{
System.out.println(s);
}
public synchronized void timedOut(long mtimeOutInterval)
{
if(debug)System.out.println("Connection timedOut1");
uR.stopRequest();
timer.stopTimer();
if(debug)System.out.println("Connection timedOut2");
responseAvailable = true;
}
public synchronized void done()
{
isok = true;
timer.stopTimer();
uR.stopRequest();
if(debug)System.out.println("Success");
responseAvailable = true; // met fin du
Thread
// isok = true;
}
// other methods for various HTTP Response Types..
public boolean connectToHere(String sURL)
{
return this.connectToHere(sURL,null);
}
public boolean connectToHere(String sURL,OutputStream mout)
{
isok = false;
if(debug)System.out.println("Starting to connect to : "
+ sURL);
System.out.println("URLConnection AvTimer");
timer = new MTimer(100, this);
try
{
uR = new URLRequester(new URL(sURL),
this,debug,mout); //creation du Thread
/* }
catch (MalformedURLException e)
{}*/
responseAvailable = false;
timer.start(); //demmarrage timeout
uR.start(); //demmarrage thread de test
while(!responseAvailable)
{
try
{
Thread.sleep(timeSleep);
}
catch(InterruptedException e)
{
}
} // fin while
if(debug)System.out.println("Done");
}
catch (Exception e)
{}
return isok;
} // fin methode connectToHere
class URLRequester extends Thread
{
URL urlToOpen;
URLResponseListener listener;
BufferedInputStream dis = null;
OutputStream out=null;
URLRequester(URL urlToRead, URLResponseListener ul,boolean
mdebug, OutputStream mout)
{
urlToOpen = urlToRead;
listener = ul;
debug=mdebug;
out=mout;
}
URLRequester(URL urlToRead, URLResponseListener ul)
{
urlToOpen = urlToRead;
listener = ul;
debug=false;
}
boolean continueThread = true;
public void stopRequest()
{
if(debug)System.out.println("Request Stopped");
continueThread = false;
}
public void run()
{
if(debug)System.out.println("Starting request.");
dis = null;
while( continueThread )
{
try
{
URLConnection uc =
urlToOpen.openConnection(); // no connection yet
uc.setUseCaches(false); //
possibly user specified.
if(debug)System.out.println("Connecting....");
uc.connect(); // request for
connection now!!! throws IOException here ,
if(debug)System.out.println("Opening....");
dis = new
BufferedInputStream(uc.getInputStream()); // throws IOException
here .try again
if(debug)System.out.println("DoneStream.");
// read the data in a loop
if(out!=null)
{
byte buf[] = new byte[2048];
int len;
if(debug)System.out.println("DoneStream out.");
while (true)
{
try
{
len = dis.read(buf);
if(debug)System.out.println("WriteStream01. "+len);
if (len<1)//done?
{
out.flush();
break;
}
}
catch (Exception e)
{
System.out.println("Err run
Stream. ");
break;
}
try
{
if(debug)System.out.println("WriteStream02. "+len);
out.write(buf,0,len);
if(debug)System.out.println("WriteStream03. "+len);
}
catch (Exception e)
{
System.out.println("Err run
Stream02. "+e.getMessage());
}
}//while
if(debug)System.out.println("WriteStream End. ");
}
dis.close(); // throws an exception
continueThread = false; // because we
are done.
listener.done();
}
catch(IOException e) // catch errors while
connecting and reading from the input stream.
{
// notify the user that the HTTP Reqest
failed using the HTTPResponseListener
listener.error(e.toString());
continueThread = false;
return;
}
}
if(dis!=null)
{
try { dis.close(); }
catch (IOException e) {}
dis = null;
}
if(debug)System.out.println("Request Complete.");
}
}
}
package util.generic;
public interface TimeOutListener
{
public void timedOut(long l);
}