首先,我创建了一个Java App来测试我的代码,以便使用蓝牙联系NXT Brick。一旦这个工作,我创建了一个Webservice,它应该通过蓝牙连接到NXT Brick。
这就是问题的起点。我的Web服务工作正常,我可以看到服务,我可以调用它们。 一项服务使用NXTComm,它位于Lejos PC库(lejos.pc.comm.NXTComm)中。我已将这些库添加到项目中,并添加了“import lejos.pc.comm。*;”在课程的顶部,但我仍然得到以下错误。
[ERROR] lejos/pc/comm/NXTComm
java.lang.reflect.InvocationTargetException
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 org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: lejos/pc/comm/NXTComm
at mindstorms.Connector.getBots(Connector.java:111)
at mindstorms.MindstormService.getBots(MindstormService.java:30)
... 29 more
Caused by: java.lang.ClassNotFoundException: lejos.pc.comm.NXTComm
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
... 31 more
为什么服务不能到达这些库,我该怎么做才能解决这个问题?
答案 0 :(得分:0)
那么为了将leJOS库添加到Web应用程序,您做了什么?你为什么期望他们在课堂上?
如果您将leJOS中的文件夹lib / pc中的JAR文件分发到Web应用程序的WEB-INF / lib文件夹中,它可能会有效。或者,有一个所有Web应用程序都可以访问的库目录。它必须位于Tomcat所在的位置。
BTW:系统属性java.class.path并不真正返回搜索类的路径。如果一个人正在使用类加载器(tomcat会这样做),那么他们搜索的路径不会出现在java.class.path中。