Pessoal estou tendo os seguintes problemas com a KVM da IBM.
Fiz um aplicação utilizando HttpConnection que conecta a um servidor Glassfish. Testei no emulador funciona perfeitamente. Testei também em celulares como o meu Nokia N81.
O problema acontece quando vou testar no emulador para Palm OS, mais especificamente o TungstenT3. Instalei a maquina virtual no emulador e a minha aplicação, ela inicia normalmente o problema é quando mando conectar no servidor e me retornado o seguinte erro. Alguém tem alguma ideia do que pode ser.
Parece que ele não esta reconhecendo o host quando utilizo o Palm
Using default security policy instead
java.lang.IllegalArgumentException: Invalid host: 192.168.15.34
at com.ibm.oti.connection.socket.Socket.resolveHost(Unknown Source)
at com.ibm.oti.connection.socket.Connection.setParameters(Unknown Source)
at com.ibm.oti.connection.socket.Connection.setParameters(Unknown Source)
at com.ibm.oti.connection.http.Connection.openSocket(Unknown Source)
at com.ibm.oti.connection.http.Connection.connect(Unknown Source)
at com.ibm.oti.connection.http.Connection.sendRequest(Unknown Source)
at com.ibm.oti.connection.http.Connection$HttpOutputStream.flush(Unknown Source)
at OberonMIDlet.b(Unknown Source)
at OberonMIDlet.startApp(Unknown Source)
at javax.microedition.midlet.MIDletAccessor.startApp(Unknown Source)
at javax.microedition.lcdui.AppManager$1.run(Unknown Source)
Métodos para conexão no meu MIDLet
[code]
private void doPost(){
HttpConnection http = null;
OutputStream oStrm = null;
InputStream iStrm = null;
boolean ret;
String url = "http://192.168.15.34:8081/OberonEnterprise-war/OberonServlet?codigo=132";
try{
http = (HttpConnection)Connector.open(url);
http.setRequestMethod(HttpConnection.POST);
http.setRequestProperty("Content-Language", "pt-BR");
http.setRequestProperty("Content-Type", "octet-stream");
http.setRequestProperty("Connection", "Keep-Alive");
getConnectionInformation(http);
oStrm = http.openOutputStream();
byte data[] = ("codigo=132").getBytes();
oStrm.write(data);
oStrm.flush();
iStrm = http.openInputStream();
this.processResposta(http, iStrm);
if (http.getResponseCode() == HttpConnection.HTTP_OK){
System.out.println("Sucesso");
}
else
System.out.println("Falha: " + http.getResponseMessage() + " Code: " + http.getResponseCode());
} catch (IOException ex) {
Alert m = new Alert("Erro");
m.setString("Erro: " + ex.getMessage());
m.setTimeout(Alert.FOREVER);
m.setType(AlertType.ERROR);
}
finally{
try {
if (iStrm != null)
iStrm.close();
if (oStrm != null)
oStrm.close();
if (http != null)
http.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
//Processa uma reposta do Servlet
public boolean processResposta(HttpConnection hc, InputStream is) throws IOException {
String erroMsg = null;
// se conexão realizada e resposta OK enviada, calcula o tamanho da resposta (resultado)
if(hc.getResponseCode() == HttpConnection.HTTP_OK){
//
int length = (int) hc.getLength();
String str;
System.out.println("Lendo array de bytes");
if(length != -1){
byte servletData[] = new byte[length];
System.out.println("Paulo");
// recebe resposta do servlet e depois guarda em str
is.read(servletData);
str = new String(servletData);
}
else{
System.out.println("Lendo array de bytes");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int ch;
while ( (ch = is.read() ) != -1)
bos.write(ch);
str = new String(bos.toByteArray());
bos.close();
}
// amostra o resultado (resposta do servlet) no display
System.out.println(str);
return true;
}
else{
erroMsg = new String(hc.getResponseMessage());
return false;
}
}[/code]