我有个问题:
我有一个 Web 服务,它运行在具有 Ubuntu 12.04 操作系统的远程服务器上的虚拟机上。
现在,我想测试这个 Web 服务,我正在使用我在我的 Web 服务客户端中开发的这段代码:
public class Client3 {
public static void main(String[] args) {
byte[] inputFile;
String nomeFile;
String jdbcURL = "jdbc:mysql://xxx.xxx.xxx.xxx:3306/mydb";
String username = "root";
String password = "xxx";
String driver = "com.mysql.jdbc.Driver";
String result = wsmethod(jdbcURL, username, password, driver);
private static String wsmethod(java.lang.String jdbcURL, java.lang.String username, java.lang.String password, java.lang.String driver) {
ws.myWs_Service service = new ws.myWs_Service();
ws.myWs port = service.getmyWsPort();
return port.wsmethod(jdbcURL, username, password, driver);
}
}
此代码希望选择与数据库的连接信息并将其提供给我的 Web 服务。然后,我的 Web 服务将使用 D2RQ 库将数据库中的信息转换为 RDF。My Web Service Client 是使用虚拟机的 IP 地址创建的。
当我运行此代码时,我收到此错误:
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Database connection to jdbc:mysql://xxx.xxx.xxx.xxx:3306/mydb failed (user: root): Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. (E54)
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:125)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:135)
at com.sun.proxy.$Proxy31.wsmethod(Unknown Source)
at client3.Client3.wsmethod(Client3.java:77)
at client3.Client3.main(Client3.java:70)
Caused by: de.fuberlin.wiwiss.d2rq.D2RQException: Database connection to jdbc:mysql://xxx.xxx.xxx.xxx:3306/mydb failed (user: root): Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. (E54)
at de.fuberlin.wiwiss.d2rq.sql.ConnectedDB.connect(ConnectedDB.java:201)
at de.fuberlin.wiwiss.d2rq.sql.ConnectedDB.connection(ConnectedDB.java:170)
at de.fuberlin.wiwiss.d2rq.dbschema.DatabaseSchemaInspector.<init>(DatabaseSchemaInspector.java:45)
at de.fuberlin.wiwiss.d2rq.sql.ConnectedDB.schemaInspector(ConnectedDB.java:243)
at de.fuberlin.wiwiss.d2rq.mapgen.MappingGenerator.<init>(MappingGenerator.java:77)
at de.fuberlin.wiwiss.d2rq.SystemLoader.openMappingGenerator(SystemLoader.java:224)
at Prova.classprova.methodprova(classprova.java:70)
at WS.SmartHealth_ws.wsmethod(myWs.java:249)
at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:246)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:95)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:629)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:588)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:573)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:470)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:295)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:515)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:285)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:143)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:155)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:189)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Java Result: 1
如果我在本地运行此代码,我不会收到此错误。事实上,如果我在本地机器上使用 Web 服务的 IP 地址创建我的 Web 服务客户端,我不会收到此错误。为什么我会收到此错误?