NoSuchFieldError:在Tomcat项目中集成Web服务时的QUALIFIED

时间:2014-03-17 14:49:41

标签: java xml tomcat xsd cxf

由于这个问题,我几天就撞到了墙上。

我开发了一个基于CXF的测试客户端(契约优先服务)并从控制台运行它。它工作得很好,只需遵循关于客户端的CXF教程并将CXF jar添加到类路径

  1. 我将WSDL编译为java文件并将它们导入Eclipse项目
  2. 我将CXF jar添加到类路径
  3. 我写了一个调用服务的主要方法
  4. 我将项目编译成一个独立的JAR
  5. Main.java

        XmlValidator_Service service = new XmlValidator_Service(new URL("http://localhost:50501/edwin?wsdl"));
    
        XmlValidator proxy = service.getXmlValidationService();
    
        BindingProvider provider = (BindingProvider) proxy;
        provider.getRequestContext()
                .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:50501/edwin/XmlValidator");
    
        ValidationResult result = proxy.validate("C:\\phoenix\\edwin\\filerepository\\2014\\03\\17\\15\\09\\EDWIN_20140317_150913.xml",
                                                 XsdSchema.EDWIN_CONSUMER_CREDIT);
    
        System.out.println(new ObjectMapper().writeValueAsString(result));
    

    步骤4:我将该代码集成到Tomcat 6上运行的Web应用程序项目中,但是当我点击Web服务时,我收到了主题中的错误。

    从Tomcat项目运行主类使用以下类路径:

    15/11/2013  11:01            55.147 activation-1.0.2.jar
    15/11/2013  10:59           443.432 antlr-2.7.6.jar
    15/11/2013  10:59             4.467 aopalliance-1.0.jar
    15/11/2013  10:59           200.050 asm-all-3.1.jar
    15/11/2013  11:02           114.980 aspectjrt-1.5.4.jar
    15/11/2013  11:02         1.894.165 aspectjweaver-1.5.4.jar
    23/02/2011  05:10           174.074 bcpg-jdk16-1.46.jar
    15/11/2013  11:02         1.876.535 bcprov-jdk16-1.46.jar
    15/11/2013  10:59           608.376 c3p0-0.9.1.jar
    15/11/2013  11:00           278.682 cglib-2.2.jar
    15/11/2013  11:00           176.447 chartserver-3.0.1.jar
    15/11/2013  11:00           188.671 commons-beanutils-1.7.0.jar
    15/11/2013  11:00            46.725 commons-codec-1.3.jar
    15/11/2013  11:00           575.389 commons-collections-3.2.1.jar
    15/11/2013  11:00           121.757 commons-dbcp-1.2.2.jar
    15/11/2013  11:00           143.602 commons-digester-1.8.jar
    15/11/2013  11:00            57.779 commons-fileupload-1.2.1.jar
    15/11/2013  11:00           109.043 commons-io-1.4.jar
    15/11/2013  11:00           132.165 commons-jexl-1.1.jar
    15/11/2013  11:00           261.809 commons-lang-2.4.jar
    05/01/2014  18:01           385.091 commons-lang3-3.2.1.jar
    15/11/2013  11:00            60.686 commons-logging-1.1.1.jar
    15/11/2013  11:00           269.014 commons-net-3.0.1.jar
    15/11/2013  11:00            62.086 commons-pool-1.3.jar
    15/11/2013  11:00           138.956 commons-validator-1.3.1.jar
    06/02/2014  12:42         7.143.253 cxf-2.7.10.jar
    15/11/2013  11:02         6.920.452 cxf-2.7.3.jar
    06/02/2014  12:52            14.479 cxf-manifest.jar
    29/01/2013  01:08           379.396 cxf-rt-frontend-jaxws-2.7.3.jar
    06/02/2014  12:36           246.342 cxf-services-sts-core-2.7.10.jar
    06/02/2014  12:39            63.317 cxf-services-ws-discovery-api-2.7.10.jar
    06/02/2014  12:39             9.983 cxf-services-ws-discovery-service-2.7.10.jar
    06/02/2014  12:38           233.305 cxf-services-wsn-api-2.7.10.jar
    06/02/2014  12:38            62.446 cxf-services-wsn-core-2.7.10.jar
    16/07/2013  17:22            13.883 cxf-xjc-boolean-2.6.2.jar
    16/07/2013  17:23            11.193 cxf-xjc-bug671-2.6.2.jar
    16/07/2013  17:21            15.769 cxf-xjc-dv-2.6.2.jar
    16/07/2013  17:23            11.574 cxf-xjc-runtime-2.6.2.jar
    16/07/2013  17:22            12.190 cxf-xjc-ts-2.6.2.jar
    15/11/2013  11:00           313.898 dom4j-1.6.1.jar
    17/03/2014  13:57        30.327.080 edwin-services.jar
    09/01/2014  11:02         1.346.296 ehcache-core-2.6.6.jar
    09/01/2014  11:02            47.650 ehcache-jgroups3replication-1.7.4.jar
    04/01/2013  13:47            60.171 geronimo-jaxws_2.2_spec-1.1.jar
    15/11/2013  11:02            28.592 geronimo-stax-api_1.0_spec-1.0.jar
    15/11/2013  11:02         3.894.821 hibernate-3.5.1.jar
    15/11/2013  11:02           100.884 hibernate-jpa-2.0-api-1.0.0.jar
    15/11/2013  11:02         1.256.297 hsqldb-2.0.0.jar
    17/02/2014  21:47           157.516 httpasyncclient-4.0.1.jar
    17/07/2013  09:48           433.368 httpclient-4.2.5.jar
    12/02/2014  21:44           282.269 httpcore-4.3.2.jar
    12/02/2014  21:45           316.524 httpcore-nio-4.3.2.jar
    15/11/2013  11:00         1.117.661 itext-2.1.5.jar
    15/11/2013  11:00           157.240 itext-rtf-2.1.5.jar
    15/11/2013  11:02         1.107.440 jackson-all-1.9.2.jar
    01/12/2008  23:29         2.202.189 jasperreports-3.1.2.jar
    23/11/2010  08:21           597.476 javassist-3.9.0.GA.jar
    15/11/2013  11:01            99.570 jaxb-api-2.2.6.jar
    30/07/2012  16:45         1.112.659 jaxb-impl-2.2.6.jar
    30/07/2012  16:46         2.078.376 jaxb-xjc-2.2.6.jar
    15/11/2013  11:01           296.672 jcommon-1.0.0.jar
    15/11/2013  11:02           153.115 jdom-1.1.jar
    15/11/2013  11:01         1.074.536 jfreechart-1.0.0.jar
    15/11/2013  11:01           581.571 joda-time-2.3.jar
    15/11/2013  11:01         1.876.578 jpedalSTD-1.0.jar
    15/11/2013  11:01            20.682 jstl-1.1.2.jar
    15/11/2013  11:01            15.071 jta-1.1.jar
    15/11/2013  11:01           237.344 junit-4.8.2.jar
    15/11/2013  11:01           391.834 log4j-1.2.15.jar
    15/11/2013  11:02         1.034.173 lucene-core-3.0.3.jar
    15/11/2013  11:01           447.676 mail-1.4.1.jar
    29/01/2014  12:01            71.487 neethi-3.0.3.jar
    15/11/2013  11:03           321.190 org.springframework.aop-3.0.5.RELEASE.jar
    15/11/2013  11:03            53.082 org.springframework.asm-3.0.5.RELEASE.jar
    15/11/2013  11:03           555.410 org.springframework.beans-3.0.5.RELEASE.jar
    15/11/2013  11:03           668.861 org.springframework.context-3.0.5.RELEASE.jar
    15/11/2013  11:03           100.870 org.springframework.context.support-3.0.5.RELEASE.jar
    15/11/2013  11:03           382.442 org.springframework.core-3.0.5.RELEASE.jar
    15/11/2013  11:03           169.752 org.springframework.expression-3.0.5.RELEASE.jar
    15/11/2013  11:03           385.712 org.springframework.jdbc-3.0.5.RELEASE.jar
    15/11/2013  11:03           334.327 org.springframework.orm-3.0.5.RELEASE.jar
    15/11/2013  11:03           231.922 org.springframework.transaction-3.0.5.RELEASE.jar
    15/11/2013  11:03           395.587 org.springframework.web-3.0.5.RELEASE.jar
    15/11/2013  11:03           398.282 org.springframework.web.servlet-3.0.1.RELEASE.jar
    07/03/2014  15:35         1.376.142 phoenix-web-1.8.9.jar
    15/11/2013  11:02         1.539.291 poi-3.6-20091214.jar
    15/11/2013  11:02            69.137 poi-contrib-3.6-20091214.jar
    15/11/2013  11:02           412.783 poi-ooxml-3.6-20091214.jar
    15/11/2013  11:02         3.774.332 poi-ooxml-schemas-3.6-20091214.jar
    15/11/2013  11:02           795.888 poi-scratchpad-3.6-20091214.jar
    15/11/2013  11:04           431.466 quartz-1.6.6.jar
    15/11/2013  11:02            23.671 slf4j-api-1.5.11.jar
    15/11/2013  11:02             9.693 slf4j-log4j12-1.5.11.jar
    15/11/2013  11:03           338.222 spring-ldap-1.3.1.RELEASE-all.jar
    15/11/2013  11:03           199.892 spring-security-config-3.1.0.RC2.jar
    15/11/2013  11:03           340.643 spring-security-core-3.1.0.RC2.jar
    15/11/2013  11:03            93.041 spring-security-ldap-3.1.0.RC2.jar
    15/11/2013  11:03            20.513 spring-security-taglibs-3.1.0.RC2.jar
    15/11/2013  11:03           252.718 spring-security-web-3.1.0.RC2.jar
    15/11/2013  11:04           205.278 spring-test-3.0.5.RELEASE.jar
    20/10/2010  23:50           395.587 spring-web-3.0.5.RELEASE.jar
    15/11/2013  11:02           119.823 sqltool-2.0.0.jar
    15/11/2013  11:04           393.259 standard-1.1.2.jar
    04/01/2013  13:47           182.112 stax2-api-3.1.1.jar
    15/11/2013  11:01           499.949 stripes-1.5.3.jar
    15/11/2013  11:04         2.386.434 testng-5.12.1.jar
    15/11/2013  11:02           449.505 velocity-1.7.jar
    28/03/2013  12:41           482.245 woodstox-core-asl-4.2.0.jar
    19/06/2006  21:27             5.881 ws-commons-java5-1.0.1.jar
    10/03/2014  12:56           186.758 wsdl4j-1.6.3.jar
    29/01/2014  12:02           443.391 wss4j-1.6.14.jar
    22/11/2005  19:28           109.318 xml-apis-1.0.b2.jar
    15/11/2013  11:02         2.666.695 xmlbeans-2.3.0.jar
    22/09/2010  22:32           148.829 XmlSchema-1.4.7.jar
    29/01/2014  14:10           165.787 xmlschema-core-2.1.0.jar
    19/11/2013  15:56           639.643 xmlsec-1.5.6.jar
    15/11/2013  11:00           851.219 yuicompressor-2.4.2.jar
    

    从独立项目运行使用以下类路径。

    13/09/2013  17:14           959.897 activemq-broker-5.8.0.jar
    13/09/2013  17:14         1.143.233 activemq-client-5.8.0.jar
    13/09/2013  17:14           587.589 activemq-openwire-legacy-5.8.0.jar
    04/01/2013  13:48           445.288 antlr-2.7.7.jar
    04/01/2013  13:47             4.467 aopalliance-1.0.jar
    04/01/2013  13:47            43.581 asm-3.3.1.jar
    29/01/2014  14:10           263.965 commons-codec-1.9.jar
    04/01/2013  13:47           575.389 commons-collections-3.2.1.jar
    04/01/2013  13:47           284.220 commons-lang-2.6.jar
    04/01/2013  13:47            60.686 commons-logging-1.1.1.jar
    06/02/2014  12:42         7.143.253 cxf-2.7.10.jar
    06/02/2014  12:52            14.479 cxf-manifest.jar
    06/02/2014  12:36           246.342 cxf-services-sts-core-2.7.10.jar
    06/02/2014  12:39            63.317 cxf-services-ws-discovery-api-2.7.10.jar
    06/02/2014  12:39             9.983 cxf-services-ws-discovery-service-2.7.10.jar
    06/02/2014  12:38           233.305 cxf-services-wsn-api-2.7.10.jar
    06/02/2014  12:38            62.446 cxf-services-wsn-core-2.7.10.jar
    16/07/2013  17:22            13.883 cxf-xjc-boolean-2.6.2.jar
    16/07/2013  17:23            11.193 cxf-xjc-bug671-2.6.2.jar
    16/07/2013  17:21            15.769 cxf-xjc-dv-2.6.2.jar
    16/07/2013  17:23            11.574 cxf-xjc-runtime-2.6.2.jar
    16/07/2013  17:22            12.190 cxf-xjc-ts-2.6.2.jar
    04/01/2013  13:49         1.224.612 ehcache-core-2.5.1.jar
    19/11/2013  18:40           296.714 FastInfoset-1.2.13.jar
    04/01/2013  13:48            20.220 geronimo-j2ee-management_1.1_spec-1.0.1.jar
    04/01/2013  13:48           223.298 geronimo-javamail_1.4_spec-1.7.1.jar
    04/01/2013  13:47            60.171 geronimo-jaxws_2.2_spec-1.1.jar
    04/01/2013  13:48            32.359 geronimo-jms_1.1_spec-1.1.1.jar
    04/01/2013  13:49            96.323 geronimo-servlet_3.0_spec-1.0.jar
    13/09/2013  17:14            50.139 hawtbuf-1.9.jar
    04/01/2013  16:19            82.423 httpasyncclient-4.0-beta3.jar
    17/07/2013  09:48           433.368 httpclient-4.2.5.jar
    17/07/2013  09:48           227.275 httpcore-4.2.4.jar
    17/07/2013  09:48           289.773 httpcore-nio-4.2.4.jar
    04/01/2013  13:48           192.602 isorelax-20030108.jar
    04/01/2013  16:19           110.928 javax.ws.rs-api-2.0-m10.jar
    04/01/2013  16:36            99.570 jaxb-api-2.2.6.jar
    04/01/2013  16:36         1.112.659 jaxb-impl-2.2.6.jar
    04/01/2013  16:36         2.078.376 jaxb-xjc-2.2.6.jar
    20/12/2013  11:25            81.899 jettison-1.3.5.jar
    19/11/2013  18:43            21.162 jetty-continuation-8.1.14.v20131031.jar
    19/11/2013  18:43            96.122 jetty-http-8.1.14.v20131031.jar
    19/11/2013  18:43           104.219 jetty-io-8.1.14.v20131031.jar
    19/11/2013  18:43            89.923 jetty-security-8.1.14.v20131031.jar
    19/11/2013  18:43           357.704 jetty-server-8.1.14.v20131031.jar
    19/11/2013  18:43           287.680 jetty-util-8.1.14.v20131031.jar
    04/01/2013  13:49           543.044 joda-time-1.6.2.jar
    04/01/2013  13:49           871.260 js-1.7R2.jar
    03/05/2013  22:57           644.786 mina-core-2.0.7.jar
    04/01/2013  13:48           681.905 msv-core-2011.1.jar
    29/01/2014  12:01            71.487 neethi-3.0.3.jar
    04/01/2013  13:49            44.209 oauth-20100527.jar
    04/01/2013  13:49            11.744 oauth-provider-20100527.jar
    04/01/2013  13:49         1.352.924 opensaml-2.5.1-1.jar
    04/01/2013  13:49           565.330 openws-1.4.2-1.jar
    04/01/2013  13:48            19.255 relaxngDatatype-20020414.jar
    28/03/2013  12:50            26.084 slf4j-api-1.7.5.jar
    28/03/2013  12:52             7.900 slf4j-jdk14-1.7.5.jar
    04/01/2013  13:53           321.435 spring-aop-3.0.7.RELEASE.jar
    04/01/2013  13:53            53.082 spring-asm-3.0.7.RELEASE.jar
    04/01/2013  13:53           556.747 spring-beans-3.0.7.RELEASE.jar
    04/01/2013  13:53           670.388 spring-context-3.0.7.RELEASE.jar
    04/01/2013  13:53           383.621 spring-core-3.0.7.RELEASE.jar
    04/01/2013  13:53           169.749 spring-expression-3.0.7.RELEASE.jar
    04/01/2013  13:54           185.555 spring-jms-3.0.7.RELEASE.jar
    04/01/2013  13:54           232.066 spring-tx-3.0.7.RELEASE.jar
    04/01/2013  13:54           398.383 spring-web-3.0.7.RELEASE.jar
    04/01/2013  13:47           182.112 stax2-api-3.1.1.jar
    04/01/2013  13:47           449.505 velocity-1.7.jar
    06/02/2014  12:18             3.647 WHICH_JARS
    28/03/2013  12:41           482.245 woodstox-core-asl-4.2.0.jar
    20/03/2013  10:25           186.758 wsdl4j-1.6.3.jar
    29/01/2014  12:02           443.391 wss4j-1.6.14.jar
    04/01/2013  13:48            84.091 xml-resolver-1.2.jar
    04/01/2013  16:19         2.730.866 xmlbeans-2.6.0.jar
    22/09/2010  22:32           148.829 XmlSchema-1.4.7.jar
    29/01/2014  14:10           165.787 xmlschema-core-2.1.0.jar
    19/11/2013  15:56           639.643 xmlsec-1.5.6.jar
    04/01/2013  13:49           610.865 xmltooling-1.3.2-1.jar
    04/01/2013  13:48           229.348 xsdlib-2010.1.jar
    

    我想知道有罪的JAR错过了QUALIFIED属性(可能在javax.xml.bind.annotation.XmlNsForm

    例外细节:

    Exception in thread "main" java.lang.NoSuchFieldError: QUALIFIED
        at org.apache.cxf.service.model.SchemaInfo.setSchema(SchemaInfo.java:146)
        at org.apache.cxf.wsdl11.SchemaUtil.extractSchema(SchemaUtil.java:136)
        at org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:73)
        at org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:65)
        at org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:60)
        at org.apache.cxf.wsdl11.WSDLServiceBuilder.getSchemas(WSDLServiceBuilder.java:372)
        at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:339)
        at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:203)
        at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:175)
        at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:416)
        at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:538)
        at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:252)
        at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:205)
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
        at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
        at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:156)
        at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:156)
        at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:465)
        at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:332)
        at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:319)
        at javax.xml.ws.Service.getPort(Service.java:92)
        at my.package.XmlValidator_Service.getXmlValidationService(XmlValidator_Service.java:67)
        at test.ws.Main.main(Main.java:21)
    

1 个答案:

答案 0 :(得分:21)

您需要删除:XmlSchema-1.4.7.jar

CXF 2.7.x需要2.x版本的XmlSchema(你有:xmlschema-core-2.1.0.jar),但它正在拿起1.4.7版本。