Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

java - Gwt doesn't work with com port rxtx

com2 - it's class which work with com port ( rxtx library ). When I run my site on gwt and press on button run this function and errors:

public String greetServer(String input)  {


    try {
        comm2 COM = new comm2("COM3", "$KE,WR,6,1
");
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return input;



}


  Caused by: java.lang.NoClassDefFoundError: Could not initialize class gnu.io.CommPortIdentifier
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:69)
        at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
        at com.aaa.server.comm2.<init>(comm2.java:17)
        at com.aaa.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:18)
        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

on first run i see in error's

Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission loadLibrary.rxtxSerial)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

GWT is primarily a cross compiler that translates Java code to Javascript which runs completely inside the browser. That means you cannot do anything that cannot be done inside a browser like any kind of IO or accessing COM ports

Update 1:


Actually after reviewing your question, it looks like your code is run on the server not the client. Your question confused me. You question should have been about executing the library through gwt rpc on the embedded jetty or whatever.

I can see that your stacktrace lists google app engine, do you intend to run the app on app engine? If yes, then how do you intend to access the hardware? if not, you should remove the app engine dependency and run on the webserver directly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...