Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problema con tomcat

5 views
Skip to first unread message

riccardo

unread,
Jun 6, 2005, 10:44:24 AM6/6/05
to
quando faccio partire tomcat dopo pochi secondi esce come se facesse lo
shutdown da solo scrivendo questo stack di errore :

Catalina.stop: java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at java.net.Socket.<init>(Socket.java:309)
at java.net.Socket.<init>(Socket.java:124)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:410)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:336)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:427)


che SUCCEDE secondo voi? la cosa strana è che prima facevo girare le
stesse applicazioni e non si lamentava di nulla ,grazie ciao

riccardo

unread,
Jun 6, 2005, 10:54:49 AM6/6/05
to
dimenticavo che prima risponde così:

INFO: Server startup in 4922 ms
No such port: null

dopo che io ho riempito un form in cui metto anche il nome della porta
seriale con cui voglio comunicare

Francesco Galli

unread,
Jun 6, 2005, 10:56:20 AM6/6/05
to
C'e' un'altra istanza gia' attiva? hai fatto uno shutdown? riavviato la
macchina? vedrai sparisce :)

--
---
Francesco Galli / Cinghiale Mannaro
Personal: http://cinghialemannaro.splinder.com
TMS project: http://tms.inera.it


riccardo

unread,
Jun 6, 2005, 11:44:20 AM6/6/05
to
purtroppo rimane lo stesso effetto ma solo se faccio girare una
determinata web application che fa quello che deve fare ma non dovrebbe
assolutamente fare lo shutdown di tomcat rispondendo nella cartella
logs così:

2005-06-06 17:28:48
StandardContext[/balancer]org.apache.webapp.balancer.BalancerFilter:
init(): ruleChain: [org.apache.webapp.balancer.RuleChain:
[org.apache.webapp.balancer.rules.URLStringMatchRule: Target string:
News / Redirect URL: http://www.cnn.com],
[org.apache.webapp.balancer.rules.RequestParameterRule: Target param
name: paramName / Target param value: paramValue / Redirect URL:
http://www.yahoo.com],
[org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL:
http://jakarta.apache.org]]
2005-06-06 17:28:48 StandardContext[/jsp-examples]ContextListener:
contextInitialized()
2005-06-06 17:28:48 StandardContext[/jsp-examples]SessionListener:
contextInitialized()
2005-06-06 17:28:48 StandardContext[/servlets-examples]ContextListener:
contextInitialized()
2005-06-06 17:28:48 StandardContext[/servlets-examples]SessionListener:
contextInitialized()
2005-06-06 17:28:59 StandardContext[/jsp-examples]ContextListener:
attributeReplaced('org.apache.catalina.WELCOME_FILES',
'[Ljava.lang.String;@9abc69')
2005-06-06 17:28:59 StandardContext[/jsp-examples]ContextListener:
attributeReplaced('org.apache.catalina.WELCOME_FILES',
'[Ljava.lang.String;@c792d4')
2005-06-06 17:28:59 StandardContext[/jsp-examples]ContextListener:
attributeReplaced('org.apache.catalina.WELCOME_FILES',
'[Ljava.lang.String;@78dc4c')
2005-06-06 17:28:59 StandardContext[/jsp-examples]SessionListener:
contextDestroyed()
2005-06-06 17:28:59 StandardContext[/jsp-examples]ContextListener:
contextDestroyed()
2005-06-06 17:29:00 StandardContext[/servlets-examples]ContextListener:
attributeReplaced('org.apache.catalina.WELCOME_FILES',
'[Ljava.lang.String;@d12eea')
2005-06-06 17:29:00 StandardContext[/servlets-examples]ContextListener:
attributeReplaced('org.apache.catalina.WELCOME_FILES',
'[Ljava.lang.String;@15f157b')
2005-06-06 17:29:00 StandardContext[/servlets-examples]ContextListener:
attributeReplaced('org.apache.catalina.WELCOME_FILES',
'[Ljava.lang.String;@17b40fe')
2005-06-06 17:29:00 StandardContext[/servlets-examples]SessionListener:
contextDestroyed()
2005-06-06 17:29:00 StandardContext[/servlets-examples]ContextListener:
contextDestroyed()

poteri oscuri o che altro? ciao

riccardo

unread,
Jun 6, 2005, 12:41:57 PM6/6/05
to
credo omeglio sono convinto che il problema sta nel fatto che forzo il
thread nella mia classe che lancio dalla pag jsp a fermarsi e quindi
chiude anche tomcat: mi spiego chiamo la pag. jsp di nome Prova.jsp
eccola:

<%@ page language="java" import="riccardo.*,javax.comm.*,java.io.*" %>
<%! String portname ="COM4";

%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>My JSP 'Prova.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>

<body>
<% try {
CommPortIdentifier portId =

CommPortIdentifier.getPortIdentifier(portname);
if (portId.getPortType() ==
CommPortIdentifier.PORT_SERIAL) {
SimpleReadWrite1 srw = new SimpleReadWrite1(portId);
}
else {
System.err.println(portname + " is not a serial port");
System.exit(1);
}
}
catch (NoSuchPortException e) { //Port nicht vorhanden
System.err.println("No such port: " + portname);
System.exit(1);
}
catch (PortInUseException e) { //Port ist
gesperrt/inGebrauch
System.err.println("Port in use: " + portname);
System.exit(1);}

out.println("risposta andata a buon fine");
out.println("se vuoi vedere il risultato clicca :");
%>
<a href="http://localhost:8080/finito/Risposta.jsp">qui</a>
</body>
</html>

che gli passo il nome della porta crea l'oggetto porta portId e lo
manda in pasto alla classe SimpleReadWrite1 eccola:


package riccardo;

import java.io.FileWriter;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.TooManyListenersException;

import javax.comm.*;


/**
* Simple program to read characters from the command-line, send
* them to the specified serial port, and echo any characters
returned.
* Modeled after the SimpleRead and SimpleWrite sample programs
included
* with the Java Communications API distribution.
*/
public class SimpleReadWrite1 implements Runnable,
SerialPortEventListener
{
String c;
private String portname;

InputStream in;
OutputStream out;
private String message ;
boolean t = true;
Thread readerThread;
SerialPort serialPort;


public void writeToCommPort(String message) {
this.message = message;
}


/**
* Main method.
*/

/**
* Constructor.
*/
public SimpleReadWrite1(CommPortIdentifier portId) throws
PortInUseException {
try {
SerialPort serialPort = (SerialPort)
portId.open("SimpleReadWrite",
2000);
//Port mit
in = serialPort.getInputStream();
out = serialPort.getOutputStream();
serialPort.addEventListener(this);
serialPort.notifyOnDataAvailable(true);
serialPort.setSerialPortParams(9600,
//Schnittstelleneinstellungen initialisieren
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
Thread readerThread = new Thread(this);
//readerThread.setDaemon(true);
readerThread.start();


} //Exception-Handling
catch (IOException e) {
System.err.println("Problem opening streams");
System.exit(1);
}
catch (TooManyListenersException e) {
System.err.println("Too Many Listeners");
System.exit(1);
}
catch (UnsupportedCommOperationException e) {
System.err.println("Problem setting port parameters");
System.exit(1);
}
}

/**
* @param b
*/

/**
* This method loops forever, reading data from the
* command line and writing it directly to the serial port.
* No buffering is performed.
* @throws InterruptedException
*/
public void run() {

try {
while(true){


out.write(message.getBytes());
}

}
catch (IOException e) {

// Terminate thread
}}


/* public boolean stopThread() throws IOException{out.close();
in.close();return t=false;}*/

/**
* Process serial port events. This method is required
* when implementing SerialPortEventListener
*
* @param event SerialPortEvent object to process
*/
public void serialEvent(SerialPortEvent event) {
String a;
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
// If there is data available on serial port,
// read it in in chunks <=20 bytes
//

byte[] readBuffer = new byte[1];
try {
while (in.available() > 0) {
int numBytes = in.read(readBuffer);

}
PrintWriter out = new PrintWriter(
new
FileWriter("C:/Jakarta/jakarta-tomcat-5.0.28/webapps/finito/nome.txt",true));

out.print(new String(readBuffer));
out.close();

// String c=toString(new String(readBuffer));


//System.out.print(new String(readBuffer));
// run() after 2000 milliseconds

}
catch (IOException e) {
// Terminate handling this event on read error
}

break;

default:
System.out.print("Unknown SerialPortEvent type = " +
event.getEventType());
break;
}

}


/**
*
*/


/**
* @param string
*/
public String toString(String string) {System.out.print(string);
return string;
// TODO Stub di metodo generato automaticamente

}
}

e dopo dato che ho messo un link nella pagina Prova.jsp vado a finire
nella pag Risultato.jsp che visualizza il contenuto del file nome.txt
dove ho riversato il risultato dell'interrogazione della porta eccola:

<%@ page language="java" import="java.util.*,java.io.*" %>
<%!

private String p;
private int next;
private char nextc;

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>My JSP 'Risposta.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>

<body>
<%

String p=getServletContext().getRealPath("/");

String p1=p.concat("nome.txt");

try{
FileReader filein = new FileReader(p1);

do{
next = filein.read(); // legge il prossimo carattere
if (next != -1) // se non e' finito il file

out.println((char) next);
else
out.println("<br>");

}

while (next !=-1);
filein.close();
}
//chiude il file

catch(IOException e){}

out.println("se vuoi inserire tale risultato nel database clicca:");

%>
<a href="http://localhost:8080/finito/Archivia.jsp">qui</a>
</body>
</html>

tutto qua come sistemarlo sto lavoro so che è tutta colpa della mia
classe che faccio terminare brutalmente ma altrimenti che dovrei fare
?(ho testato il tutto collegando un modem alla porta seriale)

CIAO e GRAZIE

Francesco Galli

unread,
Jun 7, 2005, 3:18:29 AM6/7/05
to
>tutto qua come sistemarlo sto lavoro so che è tutta colpa della mia
>classe che faccio terminare brutalmente ma altrimenti che dovrei fare
>?(ho testato il tutto collegando un modem alla porta seriale)

AAaARGH :-) la system.exit in una jsp no! :-) non ci va! TI butta giu'
tomcat!!!

Prova a riscrivere il programma utilizzando un flusso diverso. e' solo una
questione di mettere mano al codice.

riccardo

unread,
Jun 7, 2005, 5:56:48 AM6/7/05
to
grazie ma eclipse lo butta giù perchè lancia una
java.lang.NullPoinyerException e mi indica la riga nel run che fa:

out.write(message.getBytes());

Francesco Galli

unread,
Jun 7, 2005, 6:13:00 AM6/7/05
to
Hai verificato che non esista alcun flusso che ti porti a chiamare il metodo
getBytes dell'istanza message e che non comporti una previa costruzione
dell'istanza?

E' un errore di programmazione comunque, non e' colpa di Eclipse. Rimuovi
comunque quelle system.exit :)

riccardo

unread,
Jun 7, 2005, 7:14:00 AM6/7/05
to
grazie lo stesso forse un giorno riusciro a capire questo errore ora ne
dubito

0 new messages