2012-06-29 89 views
1

如何在GWT中使用com端口。與com端口的GWT工作

comm.java它的功能寫入COM端口上的服務器的

package com.hell.server; 

import jssc.SerialPort; 
import jssc.SerialPortException; 

public class comm { 



    public String writeHelloString(String portName) { 
     SerialPort serialPort = new SerialPort("COM5"); 

      try { 

       serialPort.openPort(); 

       serialPort.setParams(SerialPort.BAUDRATE_9600, 
            SerialPort.DATABITS_8, 
            SerialPort.STOPBITS_1, 
            SerialPort.PARITY_NONE); 


       serialPort.writeBytes(portName.getBytes()); 
       @SuppressWarnings("unused") 
       byte[] buffer = serialPort.readBytes(10); 

       serialPort.closePort(); 

      } 

      catch (SerialPortException ex) { 
      // System.out.println(ex); 

     } 

       return "dsada"; 
    } 
} 

FUNC。

public String greetServer(String input) throws IllegalArgumentException { 
     comm A = new comm(); 
     A.writeHelloString("$KE"); 
     return input; 
    } 

接口的GWT客戶端的服務器:

@RemoteServiceRelativePath("greet") 
    public interface GreetingService extends RemoteService { 
     String greetServer(String name) throws IllegalArgumentException; 

    } 

這是正確的???????! 無法從控制檯工作,有許多錯誤...

錯誤:

Jun 29, 2012 10:21:59 AM com.google.appengine.tools.development.ApiProxyLocalImpl log 
SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call 
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String com.hell.client.GreetingService.greetServer(java.lang.String) throws java.lang.IllegalArgumentException' threw an unexpected exception: java.lang.NoClassDefFoundError: jssc/SerialPortException 
...... 

Caused by: java.lang.NoClassDefFoundError: jssc/SerialPortException 
    at com.hell.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:21) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115) 
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569) 
    ... 34 more 
Caused by: java.lang.ClassNotFoundException: jssc.SerialPortException 
    at java.net.URLClassLoader$1.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:176) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    ... 41 more 
+0

請在這裏發佈錯誤列表。目前還不清楚可能是什麼錯誤 –

+0

張貼在頂部! –

回答