1

SOAP使用Apache CXFand开发了一个客户端,maven当我从 Eclipse、JUnit 或 shell 运行它时它工作正常。但是当我将它打包EAR并部署在 上时Websphere 8,它会失败并出现错误:

java.lang.NoSuchFieldError:org/apache/ws/commons/schema/XmlSchemaForm.QUALIFIED

代码:

SIOSProyectosService service = new SIOSProyectosService();
SIOSProyectos port = service.getHTTPPort(); // Here fails on WAS 8

POM.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.atsistemas.san</groupId>
    <artifactId>sap-clients</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>sap-clients</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.6</maven.compiler.source>
        <maven.compiler.target>1.6</maven.compiler.target>
        <cxf.version>3.0.16</cxf.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <!-- Jetty is needed if you're are not using the CXFServlet -->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf.build-utils</groupId>
            <artifactId>cxf-buildtools</artifactId>
            <version>3.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.xmlschema</groupId>
            <artifactId>xmlschema-core</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>SAP-Clients</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>${cxf.version}</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <!-- <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot> -->
                            <sourceRoot>${basedir}/src/main/java/</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>${basedir}/src/main/resources/services/ProyectoFactoryPRE.wsdl</wsdl>
                                    <wsdlLocation>services/ProyectoFactoryPRE.wsdl</wsdlLocation>
                                    <extraargs>
                                        <extraarg>-client</extraarg>
                                        <extraarg>-verbose</extraarg>
                                    </extraargs>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <createDependencyReducedPom>true</createDependencyReducedPom>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>## you name class name ##</mainClass>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.handlers</resource>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.schemas</resource>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/services/com.sun.tools.xjc.Plugin</resource>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/cxf/cxf.extension</resource>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/extensions.xml</resource>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/cxf/extensions.xml</resource>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/cxf/bus-extensions.txt</resource>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/cxf/bus-extensions.xml</resource>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/wsdl.plugin.xml</resource>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/tools.service.validator.xml</resource>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/cxf/java2wsbeans.xml</resource>
                                </transformer>
                            </transformers>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <shadedClassifierName>executable</shadedClassifierName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> 
                <version>2.6</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> 
                </descriptorRefs> </configuration> <executions> <execution> <id>make-assembly</id> 
                <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> 
                </executions> </plugin> -->
        </plugins>
    </build>
</project>

堆栈跟踪:

java.lang.NoSuchFieldError: org/apache/ws/commons/schema/XmlSchemaForm.QUALIFIED
[org.apache.cxf.service.model.SchemaInfo.setSchema(SchemaInfo.java:145),
 org.apache.cxf.wsdl11.SchemaUtil.extractSchema(SchemaUtil.java:143),
 org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:73),
 org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:65),
 org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:60),
 org.apache.cxf.wsdl11.WSDLServiceBuilder.getSchemas(WSDLServiceBuilder.java:378),
 org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:345),
 org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:209),
 org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:162),
 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:408),
 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:528),
 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263),
 org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215),
 org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103),
 org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91),
 org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:157),
 org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142),
 org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:493),
 org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:359),
 org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:350),
 javax.xml.ws.Service.getPort(Service.java:99),
 sc.factory.proyectos.SIOSProyectosService.getHTTPPort(SIOSProyectosService.java:100),
 com.ibm.san.factory.provider.common.organizationalunit.OrganizationalUnitProviderImpl.getAsignacionesFromSAP(OrganizationalUnitProviderImpl.java:878),
 com.ibm.san.factory.provider.common.organizationalunit.OrganizationalUnitProviderImpl.getInformationWS(OrganizationalUnitProviderImpl.java:841),
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method),
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60),
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37),
 java.lang.reflect.Method.invoke(Method.java:611),
 org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:63),
 org.apache.wink.server.handlers.AbstractHandler.handleRequest(AbstractHandler.java:33),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),
 org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67),
 com.ibm.san.factory.handlers.ParameterRequiredCheckingHandler.handleRequest(ParameterRequiredCheckingHandler.java:73),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),
 org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67),
 org.apache.wink.server.internal.handlers.CreateInvocationParametersHandler.handleRequest(CreateInvocationParametersHandler.java:54),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),
 org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67),
 org.apache.wink.server.handlers.AbstractHandler.handleRequest(AbstractHandler.java:34),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),
 org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67),
 org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleSubResourceMethod(FindResourceMethodHandler.java:183),
 org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleRequest(FindResourceMethodHandler.java:110),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),
 org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67),
 org.apache.wink.server.internal.handlers.FindRootResourceHandler.handleRequest(FindRootResourceHandler.java:95),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),
 org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67),
 org.apache.wink.server.internal.handlers.HeadMethodHandler.handleRequest(HeadMethodHandler.java:53),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),
 org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67),
 org.apache.wink.server.internal.handlers.OptionsMethodWADLHandler.handleRequest(OptionsMethodWADLHandler.java:51),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),
 org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67),
 org.apache.wink.server.internal.handlers.SearchResultHandler.handleRequest(SearchResultHandler.java:33),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),
 org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67),
 org.apache.wink.server.internal.log.ResourceInvocation.handleRequest(ResourceInvocation.java:92),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),
 org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67),
 org.apache.wink.server.internal.log.Requests.handleRequest(Requests.java:76),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),
 org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),
 org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67),
 org.apache.wink.server.handlers.AbstractHandlersChain.run(AbstractHandlersChain.java:52),
 org.apache.wink.server.internal.RequestProcessor.handleRequestWithoutFaultBarrier(RequestProcessor.java:207),
 org.apache.wink.server.internal.RequestProcessor.handleRequest(RequestProcessor.java:154),
 org.apache.wink.server.internal.servlet.RestServlet.service(RestServlet.java:124),
 javax.servlet.http.HttpServlet.service(HttpServlet.java:668),
 com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1214),
 com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774),
 com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456),
 com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178),
 com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125),
 com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:92),
 com.ibm.san.factory.context.filters.EntityManagerFilter.doFilter(EntityManagerFilter.java:55),
 com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192),
 com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89),
 com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:926),
 com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1023),
 com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703),
 com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304),
 com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962),
 com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662),
 com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195),
 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452),
 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511),
 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305),
 com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83),
 com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784),
 com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165),
 com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217),
 com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161),
 com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138),
 com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204),
 com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775),
 com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905),
 com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)]
4

0 回答 0