我有一个Java应用程序,我将使用它通过Web服务将某些jTextFields
的值发送到数据库。测试此功能时,我在客户端上收到以下错误:
线程中的异常" AWT-EventQueue-0" com.sun.xml.internal.ws.fault.ServerSOAPFaultException:客户端 从服务器收到SOAP Fault:java.awt.HeadlessException请参阅 服务器日志以查找有关确切原因的更多详细信息 失败。 at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178) 在 com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:116) 在 com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(StubHandler.java:238) 在 com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:189) 在 com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:276) 在 com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:104) 在 com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77) 在 com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147) 在com.sun.proxy。$ Proxy32.insertDVD(未知来源)at code.insertView.insertDVD(insertView.java:176)at code.insertView.jButton1ActionPerformed(insertView.java:169)at code.insertView.access $ 000(insertView.java:13)at code.insertView $ 1.actionPerformed(insertView.java:68)at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) 在 javax.swing.AbstractButton中的$ Handler.actionPerformed(AbstractButton.java:2346) 在 javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) 在 javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) 在 javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) 在java.awt.Component.processMouseEvent(Component.java:6525)at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)at java.awt.Component.processEvent(Component.java:6290)at java.awt.Container.processEvent(Container.java:2234)at java.awt.Component.dispatchEventImpl(Component.java:4881)at java.awt.Container.dispatchEventImpl(Container.java:2292)at java.awt.Component.dispatchEvent(Component.java:4703)at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898) 在 java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462) 在java.awt.Container.dispatchEventImpl(Container.java:2278)at java.awt.Window.dispatchEventImpl(Window.java:2739)at java.awt.Component.dispatchEvent(Component.java:4703)at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)at at java.awt.EventQueue.access $ 400(EventQueue.java:97)at java.awt.EventQueue $ 3.run(EventQueue.java:697)at java.awt.EventQueue $ 3.run(EventQueue.java:691)at java.security.AccessController.doPrivileged(Native Method)at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75) 在 java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:86) 在java.awt.EventQueue $ 4.run(EventQueue.java:719)at java.awt.EventQueue $ 4.run(EventQueue.java:717)at java.security.AccessController.doPrivileged(Native Method)at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75) 在java.awt.EventQueue.dispatchEvent(EventQueue.java:716)at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) 在 java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) 在 java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) 在java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
GlassFish中的以下异常:
严重:java.awt.HeadlessException at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207) 在java.awt.Window。(Window.java:536)at java.awt.Frame。(Frame.java:420)at java.awt.Frame。(Frame.java:385)at javax.swing.SwingUtilities中的$ SharedOwnerFrame。(SwingUtilities.java:1758) 在 javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1833) 在javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1696)at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:863)at at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:666)at at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:637)at at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:608)at at webServicePackage.NewWebService.insertDVD(NewWebService.java:27)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:483)at org.glassfish.webservices.InstanceResolverImpl $ 1.invoke(InstanceResolverImpl.java:143) at com.sun.xml.ws.server.InvokerTube $ 2.invoke(InvokerTube.java:149) 在 com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:88) 在com.sun.xml.ws.api.pipe.Fiber .__ doRun(Fiber.java:1136)at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)at at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)at at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:136) 在 org.glassfish.webservices.MonitoringPipe.process(MonitoringPipe.java:142) 在 com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:119) 在com.sun.xml.ws.api.pipe.Fiber .__ doRun(Fiber.java:1136)at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)at at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)at at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:136) 在 com.sun.enterprise.security.webservices.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:210) 在 com.sun.enterprise.security.webservices.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:142) 在 com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:119) 在com.sun.xml.ws.api.pipe.Fiber .__ doRun(Fiber.java:1136)at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)at at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)at at com.sun.xml.ws.server.WSEndpointImpl $ 2.process(WSEndpointImpl.java:420) 在 com.sun.xml.ws.transport.http.HttpAdapter $ HttpToolkit.handle(HttpAdapter.java:687) 在 com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:266) 在 com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:169) 在 org.glassfish.webservices.JAXWSServlet.doPost(JAXWSServlet.java:169) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:707)at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)at at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 在 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) 在 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 在 org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) 在 org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) 在com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 在 org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260) 在 com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188) 在 org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) 在 org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) 在 org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189) 在 org.glassfish.grizzly.filterchain.ExecutorResolver $ 9.execute(ExecutorResolver.java:119) 在 org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) 在 org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206) 在 org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136) 在 org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114) 在 org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 在 org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838) 在 org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113) 在 org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) 在 org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100(WorkerThreadIOStrategy.java:55) 在 org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) 在 org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:564) 在 org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:544) 在java.lang.Thread.run(Thread.java:745)
我查看了StackOverflow和Google的搜索结果,但我找不到HeadlessException
因此被排除在外。
以下是点击按钮的代码:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String titleVal=titleField.getText();
int yearVal=Integer.parseInt(yearField.getText());
String actorsVal=actorField.getText();
double ratingVal=Double.parseDouble(ratingField.getText());
String formatVal=formatField.getText();
int copiesVal=Integer.parseInt(copiesField.getText());
insertDVD(titleVal, yearVal, actorsVal, ratingVal, formatVal, copiesVal);
}
Web服务调用方法的代码:
private static String insertDVD(java.lang.String title, int year, java.lang.String actors, double rating, java.lang.String format, int copies) {
webservicepackage.NewWebService_Service service = new webservicepackage.NewWebService_Service();
webservicepackage.NewWebService port = service.getNewWebServicePort();
return port.insertDVD(title, year, actors, rating, format, copies);
}
网络服务的网络方法:
@WebMethod(operationName = "insertDVD")
public String insertDVD(@WebParam(name = "title") String title, @WebParam(name = "year") int year, @WebParam(name = "actors") String actors, @WebParam(name = "rating") double rating, @WebParam(name = "format") String format, @WebParam(name = "copies") int copies) {
//JOptionPane.showMessageDialog(null, (title+" "+Integer.toString(year)+" "+actors+" "+Double.toString(rating)+" "+format+" "+Integer.toString(copies)));
JOptionPane.showMessageDialog(null, "Values received");
return null;
}
编辑:尽管此处的另一个问题:java.awt.HeadlessException thrown from HeadlessGraphicsEnvironment.getDefaultScreenDevice也有类似的错误,但在尝试进行某些图像处理时会出现该错误。我的错误只是在没有任何对这样的库,类或方法的任何调用的情况下出现。我没有尝试任何复杂的事情,这是一件非常简单的事情,它引发了一个它不应该发生的异常!
答案 0 :(得分:0)
好吧,似乎无法在Web服务中创建消息对话框。我不知道会发生这种情况,因为它完全适用于C#。
很抱歉,如果这个问题似乎没必要。