Guest User

Untitled

a guest
Sep 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. GWT work with com port
  2. package com.hell.server;
  3.  
  4. import jssc.SerialPort;
  5. import jssc.SerialPortException;
  6.  
  7. public class comm {
  8.  
  9.  
  10.  
  11. public String writeHelloString(String portName) {
  12. SerialPort serialPort = new SerialPort("COM5");
  13.  
  14. try {
  15.  
  16. serialPort.openPort();
  17.  
  18. serialPort.setParams(SerialPort.BAUDRATE_9600,
  19. SerialPort.DATABITS_8,
  20. SerialPort.STOPBITS_1,
  21. SerialPort.PARITY_NONE);
  22.  
  23.  
  24. serialPort.writeBytes(portName.getBytes());
  25. @SuppressWarnings("unused")
  26. byte[] buffer = serialPort.readBytes(10);
  27.  
  28. serialPort.closePort();
  29.  
  30. }
  31.  
  32. catch (SerialPortException ex) {
  33. // System.out.println(ex);
  34.  
  35. }
  36.  
  37. return "dsada";
  38. }
  39. }
  40.  
  41. public String greetServer(String input) throws IllegalArgumentException {
  42. comm A = new comm();
  43. A.writeHelloString("$KE");
  44. return input;
  45. }
  46.  
  47. @RemoteServiceRelativePath("greet")
  48. public interface GreetingService extends RemoteService {
  49. String greetServer(String name) throws IllegalArgumentException;
  50.  
  51. }
  52.  
  53. Jun 29, 2012 10:21:59 AM com.google.appengine.tools.development.ApiProxyLocalImpl log
  54. SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
  55. 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
  56. ......
  57.  
  58. Caused by: java.lang.NoClassDefFoundError: jssc/SerialPortException
  59. at com.hell.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:21)
  60. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  61. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  62. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  63. at java.lang.reflect.Method.invoke(Unknown Source)
  64. at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
  65. at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
  66. ... 34 more
  67. Caused by: java.lang.ClassNotFoundException: jssc.SerialPortException
  68. at java.net.URLClassLoader$1.run(Unknown Source)
  69. at java.security.AccessController.doPrivileged(Native Method)
  70. at java.net.URLClassLoader.findClass(Unknown Source)
  71. at java.lang.ClassLoader.loadClass(Unknown Source)
  72. at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:176)
  73. at java.lang.ClassLoader.loadClass(Unknown Source)
  74. ... 41 more
Add Comment
Please, Sign In to add comment