在为maven apache cxf codegen插件添加授权时,authenticatorreplacer的java扩展异常?

tzcvj98z  于 2021-07-09  发布在  Java
关注(0)|答案(0)|浏览(305)

如本文所述,我已经覆盖了authenticatorreplacer,以便在从wsdl url生成java代码时提供身份验证。我已经执行了maven install,将依赖项添加到本地存储库中。
如果下载wsdl并引用本地文件,就会得到401http响应,因为web服务链接3个文件(2个wsdl和1个xsd文件),每个文件都需要身份验证。
这是pom.xml的代码,其中依赖项被添加到cxf codegen插件:

<?xml version="1.0" encoding="UTF-8"?>
<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>org.example</groupId>
    <artifactId>testwsdl</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>11</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <maven.compiler.plugin>3.8.1</maven.compiler.plugin>
        <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>3.3.7</version>
                <dependencies>
                <dependency>
                    <groupId>org.example</groupId>
                    <artifactId>cxf-authenticator-replacer2</artifactId>
                    <version>1.0-SNAPSHOT</version>
                </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>http://exampleService.com:8081/SO/Services/ExampleService.svc?wsdl</wsdl>
                                    <extraargs>
                                        <extraarg>-impl</extraarg>
                                        <extraarg>-verbose</extraarg>
                                        <extraarg>-autoNameResolution</extraarg>
                                    </extraargs>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>

我得到以下错误代码:

[WARNING] Exception in thread "main" org.apache.cxf.tools.common.ToolException: org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.example.AuthenticatorReplacer.
Exception in thread "main" org.apache.cxf.tools.common.ToolException: org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.example.AuthenticatorReplacer.
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:412)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:105)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
    at org.apache.cxf.maven_plugin.wsdl2java.ForkOnceWSDL2Java.main(ForkOnceWSDL2Java.java:51)
Caused by: org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.example.AuthenticatorReplacer.
    at org.apache.cxf.bus.extension.Extension.tryClass(Extension.java:183)
    at org.apache.cxf.bus.extension.Extension.getClassObject(Extension.java:199)
    at org.apache.cxf.bus.extension.ExtensionManagerImpl.activateAllByType(ExtensionManagerImpl.java:139)
    at org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:145)
    at org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:151)
    at org.apache.cxf.bus.CXFBusFactory.createBus(CXFBusFactory.java:40)
    at org.apache.cxf.bus.CXFBusFactory.createBus(CXFBusFactory.java:36)
    at org.apache.cxf.bus.CXFBusFactory.createBus(CXFBusFactory.java:32)
    at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:146)
    at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:122)
    at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:94)
    at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:83)
    at org.apache.cxf.BusFactory.getDefaultBus(BusFactory.java:107)
    at org.apache.cxf.BusFactory.getDefaultBus(BusFactory.java:96)
    at org.apache.cxf.tools.common.toolspec.AbstractToolContainer.getBus(AbstractToolContainer.java:189)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:184)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:156)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:404)
    ... 4 more
Caused by: java.lang.ClassNotFoundException: org.example.AuthenticatorReplacer
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at org.apache.cxf.bus.extension.Extension.tryClass(Extension.java:164)
    ... 21 more

我希望有人能帮我,谢谢。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题