对原有文档管理项目进行简化和调整,同时对客户的其他应用提供webService接口。WS使用CXF提供,功能较简单,但原项目所提供的jar与CXF所依赖的包发生冲突。首先在整合过程中,去除了一些CXF使用的jar改用项目中存在的,项目编译没问题后,进行功能瘦身调整。
整个瘦身过程,没有利用CXF工具生成WSDL文件进而产生客户端服务,而简单了写个客户端调用。能够通过ws传递信息,同时能够通过返回的连接进入文档平台进行文档操作。不过,由于该ws服务需要提供给客户,故而需要提供wsdl文件。
整合后的项目获取wsdl文件产生一系列问题,而在另一个独立WS项目中却没有这类错误。而之前整合时的记录则对后续工作有莫大的帮助。之前去除了一些jar包,很容易了解到原项目与新增的ws依赖jar有冲突。首先确认两者共存必有一方是不被引用的,而之后分别尝试使用其中一方运行项目,均会产生问题。由于项目后端依赖的是FileNet产品,一些jar不能轻易替换掉。而之后的调试发现这几个jar包是不同厂家提供的,具有不同的路径,甚至有些jar包的存在会改变原先CXF生成wsdl所要执行的类(不同jar包中的类)。
由于这种冲突产生在利用CXF生成wsdl,而非在其他功能性开发或运行中,故而只需要将这些暂时有问题的jar排除项目,先生成wsdl,而后在将原文档应用所需要的jar(刚才排除的)取回来就可以。
本地有一个实验项目是可以创建wsdl的,从CXF官网将源码下载下来,调试其逻辑,此过程所利用到的jar,与在有问题项目生成wsdl调试过程中所经历的jar进行对比,不同的,则替换掉CXF依赖的,或者根本利用不到该jar的话就删除掉,直至其按照正常的逻辑进入正确的jar环境。
至此项目便可以生成wsdl文件了。复原原项目所依赖的jar,部署,依据wsdl生成客户端,测试调用,成功了。以下举例为保留下的错误日志。
[ INFO] 2012/11/27 09:20:10.984- Loading configuration resource: FileNetBuild.properties
[ INFO] 2012/11/27 09:20:13.390- An exception has occurred while processing a getObjects request. ThegetObjects request is being retried(1) of (1) times.
javax.xml.rpc.JAXRPCException: com.sun.xml.messaging.saaj.soap.name.NameImpl cannot becast to com.systinet.saaj.soap.NameImpl
at com.filenet.apiimpl.wsi.ClientHeaderProcessor.handleOutput(ClientHeaderProcessor.java:141)
at org.systinet.wasp.handler.WaspGenericHandler.handleRequest(WaspGenericHandler.java:68)
at com.systinet.jaxrpc.rpc.handler.HandlerChainImpl.handleRequest(HandlerChainImpl.java:167)
atcom.systinet.wasp.rpc.handler.ClientHandlerChainInvoker.processOutput(ClientHandlerChainInvoker.java:100)
atcom.systinet.wasp.client.XMLInvocationHelperImpl.invokeHandlers(XMLInvocationHelperImpl.java:760)
atcom.systinet.wasp.client.XMLInvocationHelperImpl.invokeHandlers(XMLInvocationHelperImpl.java:742)
atcom.systinet.wasp.client.XMLInvocationHelperImpl.processHandlers(XMLInvocationHelperImpl.java:576)
at com.systinet.wasp.client.XMLInvocationHelperImpl.processMessage(XMLInvocationHelperImpl.java:510)
at com.systinet.wasp.client.XMLInvocationHelperImpl._call(XMLInvocationHelperImpl.java:144)
at com.systinet.wasp.client.XMLInvocationHelperImpl.call(XMLInvocationHelperImpl.java:75)
at org.systinet.wasp.client.XMLInvocationHelper.call(XMLInvocationHelper.java:18)
at com.systinet.wasp.rpc.WaspCallImpl.invoke(WaspCallImpl.java:501)
at com.systinet.wasp.rpc.WaspCallImpl.invoke(WaspCallImpl.java:459)
at com.systinet.wasp.client.ClientProxy._invoke(ClientProxy.java:476)
at com.systinet.wasp.client.ClientProxy.invoke(ClientProxy.java:111)
at $Proxy62.getObjects(Unknown Source)
at com.filenet.apiimpl.wsi.ClientPort40.getObjects(ClientPort40.java:36)
---------------------------------------------------------------------------------------------------------------------------
DEBUG] 2012/11/27 14:25:02.062- HTTP Session @ SessionContextUtils.getSubject() :org.apache.catalina.session.StandardSessionFacade@deea66
[ WARN] 2012/11/27 14:25:07.984- Interceptor for {http://ws.util.rise.ibm.com/}DocumentInterfaceImplServicehas thrown exception, unwinding now
org.apache.cxf.frontend.WSDLQueryException: Exception occurred while trying to process http://localhost:8080/DocumentInterface/DocumentInterface/DocumentInterface/DocumentInterface
at org.apache.cxf.frontend.WSDLGetUtils.getDocument(WSDLGetUtils.java:265)
at org.apache.cxf.frontend.WSDLGetInterceptor.getDocument(WSDLGetInterceptor.java:158)
at org.apache.cxf.frontend.WSDLGetInterceptor.handleMessage(WSDLGetInterceptor.java:110)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:236)
atorg.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:193)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:130)
atorg.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:221)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.ibm.rise.util.ContainBaseFilter.doFilter(ContainBaseFilter.java:91)
atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.ibm.rise.util.UTF8Filter.doFilter(UTF8Filter.java:25)
atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.RuntimeException: Problem creating schema implementation
atorg.apache.cxf.wsdl11.ServiceWSDLBuilder.getSchemaImplementation(ServiceWSDLBuilder.java:291)
at org.apache.cxf.wsdl11.ServiceWSDLBuilder.buildTypes(ServiceWSDLBuilder.java:307)
at org.apache.cxf.wsdl11.ServiceWSDLBuilder.build(ServiceWSDLBuilder.java:200)
at org.apache.cxf.frontend.WSDLGetUtils.getDocument(WSDLGetUtils.java:186)
... 30 more
Caused by: WSDLException: faultCode=CONFIGURATION_ERROR: No Java extensionType found to representa '{http://www.w3.org/2001/XMLSchema}schema' element in the context of a'javax.wsdl.Types'.:
at javax.wsdl.extensions.ExtensionRegistry.createExtension(ExtensionRegistry.java:335)
atorg.apache.cxf.wsdl11.ServiceWSDLBuilder.getSchemaImplementation(ServiceWSDLBuilder.java:289)
... 33 more
---------------------------------------------------------------------------------------------------------------------------
Missing argument: classname
Usage : java2ws -db|-databinding <databindingname> -frontend|-fe <jaxws or simple> -wsdl -wrapperbean -client-server -ant -o|-output <output-file> -d <resource-directory> -s<source-directory> -classdir <compile-classes-directory>-cp|-classpath <class-path> -soap12 -t <target-namespace> -beans<pathname of the bean definition file.>* -servicename<service-name> -portname <port-name> -a|-address <address>-createxsdimports -h|-?|-help -version|-v -verbose|-V -quiet|-q|-Q<classname>
JavaToWS Error:org.apache.cxf.tools.common.ToolException:org.apache.cxf.tools.common.toolspec.parser.BadUsageException: Missingargument: classname
参考:
如何在 WebSphere 中解决 jar 包冲突
http://www.ibm.com/developerworks/cn/websphere/library/techarticles/haoaili/0512/