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
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 / Cinghiale Mannaro
Personal: http://cinghialemannaro.splinder.com
TMS project: http://tms.inera.it
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
<%@ 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
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.
out.write(message.getBytes());
E' un errore di programmazione comunque, non e' colpa di Eclipse. Rimuovi
comunque quelle system.exit :)