1

我尝试使用 cxf-codegen-plugin 从 wsdl2java 生成 java 代码。代码已生成,可以在我的 Eclipse 测试类中看到响应(尝试调用一些方法并正确获取结果)。但是当我创建这个代码的 jar 并移动到 Weblogic 服务器类路径时(我有几个 jsp 页面调用这个 wsdl2java 生成的代码),它正确地调用了我的方法,但每次都得到运行时异常。

注意:我已经在 weblogic 类路径中移动了所有依赖的 jar。

以下是异常快照:

java.lang.RuntimeException: MASM0015: Class [ com.sun.xml.ws.assembler.jaxws.HandlerTubeFactory ] does not implement [ com.sun.xml.internal.ws.assembler.dev.TubeFactory ] interface
    at com.sun.xml.internal.ws.assembler.TubeCreator.<init>(TubeCreator.java:63)
    at com.sun.xml.internal.ws.assembler.TubelineAssemblyController.initializeTubeCreators(TubelineAssemblyController.java:116)
    at com.sun.xml.internal.ws.assembler.TubelineAssemblyController.getTubeCreators(TubelineAssemblyController.java:79)
    at com.sun.xml.internal.ws.assembler.MetroTubelineAssembler.createClient(MetroTubelineAssembler.java:103)
    at com.sun.xml.internal.ws.client.Stub.createPipeline(Stub.java:328)
    at com.sun.xml.internal.ws.client.Stub.<init>(Stub.java:295)
    at com.sun.xml.internal.ws.client.Stub.<init>(Stub.java:228)
    at com.sun.xml.internal.ws.client.Stub.<init>(Stub.java:243)
    at com.sun.xml.internal.ws.client.sei.SEIStub.<init>(SEIStub.java:84)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getStubHandler(WSServiceDelegate.java:814)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:803)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:436)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:404)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:386)
    at javax.xml.ws.Service.getPort(Service.java:119)
    at customeruserextv2.loginservice.LoginService.getLoginServiceSoap(LoginService.java:93)
    at com.ncs.wcm.LoginHelper.login(LoginHelper.java:50)
    at jsp_servlet._jsp._cs_deployed._testportal.__userlogin._jspService(__userlogin.java:322)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:295)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:353)
    at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:492)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:379)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
    at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:64)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
    at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:637)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:508) 

以下是我正在调用并收到错误的方法:

public static boolean login(String userName, String password) {
          URL wsdlURL = LoginService.WSDL_LOCATION;
            LoginService ss = new LoginService(wsdlURL, SERVICE_NAME);
            LoginServiceSoap port = ss.getLoginServiceSoap(); // This is the line where throwing error
        return port.login(userName, password);
}
    

在我的 POM.xml 下面

<description>LoginServiceWcm</description>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.3</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.3.1</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
  
  <build>
        <finalName>LoginService</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>3.2.7</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>${basedir}/src/main/resources/wsdl/login.wsdl</wsdl>
                                    <wsdlLocation>classpath:wsdl/login.wsdl</wsdlLocation>

                                    <extraargs>
                                        <extraarg>-client</extraarg>
                                    </extraargs>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
  
4

0 回答 0