我尝试使用ApacheCXF框架在Eclipse中生成Web服务,首先创建与所需Web服务相对应的Java类,然后生成两个动态Web项目,一个用于Web服务(wsdl文件)和另一个用于客户端的文件。Web服务在我创建后运行良好,但过了一段时间后(一到三天)我在服务器启动时收到显示在图像中的错误。
INFO: Starting service Catalina
Dec 7, 2011 9:27:55 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.4
Dec 7, 2011 9:27:55 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Documents and Settings\user\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Prosys_Doctorat_Servicii_FAS_servicii\WEB-INF\lib\geronimo-servlet_3.0_spec-1.0.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Dec 7, 2011 9:27:59 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1672)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1517)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4287)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4816)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1028)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:773)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1028)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:278)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:429)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:662)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.startup.Catalina.start(Catalina.java:592)
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.catalina.startup.Bootstrap.start(Bootstrap.java:290)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:418)
Dec 7, 2011 9:27:59 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
Dec 7, 2011 9:27:59 PM org.apache.catalina.core.StandardContext startInternal
然后,当我尝试从项目中调用Web服务时,出现以下错误:
Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:90)
at javax.xml.ws.Service.<init>(Unknown Source)
at read_variable_value.ReadVariableNodeService1Service.<init>(ReadVariableNodeService1Service.java:50)
at FAS.Model2_FAS.asociere_valori(Model2_FAS.java:206)
at FAS.Model2_FAS.main(Model2_FAS.java:2596)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:93)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:203)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
... 5 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'http://localhost:8081/Prosys_Doctorat_Servicii_FAS_servicii/services/ReadVariableNodeService1Port?wsdl'.: java.io.FileNotFoundException: http://localhost:8081/Prosys_Doctorat_Servicii_FAS_servicii/services/ReadVariableNodeService1Port?wsdl
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:239)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:186)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:91)
... 7 more
Caused by: java.io.FileNotFoundException: http://localhost:8081/Prosys_Doctorat_Servicii_FAS_servicii/services/ReadVariableNodeService1Port?wsdl
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
... 13 more
是什么原因导致了这个错误,而且这个错误只在重复使用Web服务后才会出现?
http://i.stack.imgur.com/4mTNZ.jpg
http://i.stack.imgur.com/rYkQb.jpg
您好,客户端会以下列方式自动产生:
private static final QName SERVICE_NAME = new QName("http://read_variable/", "ReadVariableNodeServiceService");
URL wsdlURL = ReadVariableNodeServiceService.WSDL_LOCATION;
ReadVariableNodeServiceService ss = new ReadVariableNodeServiceService(wsdlURL, SERVICE_NAME);
SEIReadValue port = ss.getReadVariableNodeServicePort();
{
System.out.println("Invoking getValue...");
java.lang.String _getValue_arg0 = "Alina";
java.lang.String _getValue_arg1 = "WorkspaceS1";
try {
double _getValue__return = port.getValue(_getValue_arg0, _getValue_arg1);
System.out.println("getValue.result=" + _getValue__return);
................
上周我发现了一个有趣的文档,它推荐了以下调用Web服务的方法:
ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"read_variable/client3_beans.xml"});
SEIReadValue port = (SEIReadValue) context.getBean("readvariableClient");
{
System.out.println("Invoking getValue...");
java.lang.String _getValue_arg0 = "Alina";
java.lang.String _getValue_arg1 = "WorkspaceS1";
try {
double _getValue__return = port.getValue(_getValue_arg0, _getValue_arg1);
System.out.println("getValue.result=" + _getValue__return);
.........
"你怎么想?这是我犯错的原因吗?"
我很高兴我几乎找到了我的错误的原因。但是我是一个初学者在网络服务,我还没有完全理解你的信息。我想指定我有一组基本/简单的网络服务,然后在这些网络服务的基础上,我创建了一个复杂的网络服务,我获得了每个简单的网络服务的上下文,以获得其功能,正如你所说(我的理解是),这不是正确的做法。
ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"write_a_matrix/client2_beans.xml"});
SEIWriteMatrix port = (SEIWriteMatrix) context.getBean("write_a_matrix_Client");
...........................................................
ClassPathXmlApplicationContext context_WV=new ClassPathXmlApplicationContext(new String[]{"write_value/client1_beans.xml"});
SEIWriteValue port_WV = (SEIWriteValue) context_WV.getBean("write_a_value_Client");
...........................................................
我已经为每个Web服务客户端创建了一个client_beans xml文件。可以吗?您可以提供一个示例,说明如何调用Web服务以及如何只保存一个应用程序上下文吗?
我将向您提供我的电子邮件地址〈berlindutza@yahoo.com〉,以防您希望更方便地进行沟通,因为我已经看到我们的电子邮件地址限制为一定数量的字符(用于 * 添加评论 * 部分)。
谢谢你的好意!
1条答案
按热度按时间pzfprimi1#
这里猜测:您可能要为每个请求重新创建CXF客户机,而不是创建一次,将其作为一个单一示例并为每个后续请求使用这个示例。
理想情况下,您应该能够使用webservice接口生成客户端。如果您显式指定了wsdl,cxf将基于WSDL生成代理,这似乎是您正在发生的事情。偶尔,提供wsdl的服务会失败,您会得到此错误。
如果您使用的是Spring,则可以执行以下操作: