1

Eclipse で wsdl2java と cxf-codegen-plugin を使用して、WSDL ファイルのクライアント コードを生成しました。しかし、SecurityException: Prohibited package name: java.util.xsd が原因でクライアントを実行できません。

これを解決する方法はありますか?

例外はこのようなものでした。

スレッド「メイン」での例外 java.lang.SecurityException: 禁止されたパッケージ名: java.lang.ClassLoader.preDefineClass(ClassLoader.java:649) で java.util.xsd (java.lang.ClassLoader.defineClass(ClassLoader.java:785) で) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) で java.net.URLClassLoader.defineClass(URLClassLoader.java:449) で java.net.URLClassLoader.access$100(URLClassLoader.java:71) で java. net.URLClassLoader$1.run(URLClassLoader.java:361) で java.net.URLClassLoader$1.run(URLClassLoader.java:355) で java.security.AccessController.doPrivileged(ネイティブ メソッド) で java.net.URLClassLoader.findClass( URLClassLoader.java:354) で java.lang.ClassLoader.loadClass(ClassLoader.java:423) で sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) で java.lang.ClassLoader.loadClass(ClassLoader.java:356) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:266) at sun.reflect.generics.factory.CoreReflectionFactory. makeNamedType(CoreReflectionFactory.java:114) で sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) で sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) で sun.reflect .annotation.AnnotationParser.parseSig(AnnotationParser.java:390) で sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:371) で、sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:673) で。 reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:480) (sun.reflect.annotation.AnnotationParser)。parseMemberValue(AnnotationParser.java:306) で sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:241) で sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88) で sun.reflect.annotation.AnnotationParser .parseAnnotations(AnnotationParser.java:70) at java.lang.Class.initAnnotationsIfNecessary(Class.java:3098) at java.lang.Class.getAnnotation(Class.java:3057) at com.sun.xml.internal.ws. model.RuntimeModeler$1.run(RuntimeModeler.java:156) で com.sun.xml.internal.ws.model.RuntimeModeler$1.run(RuntimeModeler.java:154) で java.security.AccessController.doPrivileged(Native Method) でcom.sun.xml.internal.ws.model.RuntimeModeler.getPrivClassAnnotation(RuntimeModeler.java:154) com.sun.xml.internal.ws.model.RuntimeModeler.com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:672) の buildRuntimeModel(RuntimeModeler.java:190) com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate. java:660) com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:329) で com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:312) でcom.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:294) で javax.xml.ws.Service.getPort(Service.java:119) で org.wso2.carbon.statistics.services .StatisticsAdmin.getStatisticsAdminHttpsSoap11Endpoint(StatisticsAdmin.java:101) at test1.StatisticsAdminLibrary.(StatisticsAdminLibrary.java:41) at test1.StatisticsAdminLibrary.main(StatisticsAdminLibrary.java:204)190) com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:672) で com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:660) で.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:329) com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:312) com.sun.xml .internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:294) at javax.xml.ws.Service.getPort(Service.java:119) at org.wso2.carbon.statistics.services.StatisticsAdmin.getStatisticsAdminHttpsSoap11Endpoint(StatisticsAdmin) .java:101) で test1.StatisticsAdminLibrary.(StatisticsAdminLibrary.java:41) で test1.StatisticsAdminLibrary.main(StatisticsAdminLibrary.java:204)190) com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:672) で com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:660) で.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:329) com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:312) com.sun.xml .internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:294) at javax.xml.ws.Service.getPort(Service.java:119) at org.wso2.carbon.statistics.services.StatisticsAdmin.getStatisticsAdminHttpsSoap11Endpoint(StatisticsAdmin) .java:101) で test1.StatisticsAdminLibrary.(StatisticsAdminLibrary.java:41) で test1.StatisticsAdminLibrary.main(StatisticsAdminLibrary.java:204)com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:660) の createSEIPortInfo(WSServiceDelegate.java:672) com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate. java:329) com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:312) で com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:294) でjavax.xml.ws.Service.getPort(Service.java:119) で org.wso2.carbon.statistics.services.StatisticsAdmin.getStatisticsAdminHttpsSoap11Endpoint(StatisticsAdmin.java:101) で test1.StatisticsAdminLibrary.(StatisticsAdminLibrary.java:41) でtest1.StatisticsAdminLibrary.main (StatisticsAdminLibrary.java:204) でcom.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:660) の createSEIPortInfo(WSServiceDelegate.java:672) com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate. java:329) com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:312) で com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:294) でjavax.xml.ws.Service.getPort(Service.java:119) で org.wso2.carbon.statistics.services.StatisticsAdmin.getStatisticsAdminHttpsSoap11Endpoint(StatisticsAdmin.java:101) で test1.StatisticsAdminLibrary.(StatisticsAdminLibrary.java:41) でtest1.StatisticsAdminLibrary.main (StatisticsAdminLibrary.java:204) でcom.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:329) の addSEI(WSServiceDelegate.java:660) com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate. java:312) com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:294) で javax.xml.ws.Service.getPort(Service.java:119) で org.wso2.carbon .statistics.services.StatisticsAdmin.getStatisticsAdminHttpsSoap11Endpoint(StatisticsAdmin.java:101) at test1.StatisticsAdminLibrary.(StatisticsAdminLibrary.java:41) at test1.StatisticsAdminLibrary.main(StatisticsAdminLibrary.java:204)com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:329) の addSEI(WSServiceDelegate.java:660) com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate. java:312) com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:294) で javax.xml.ws.Service.getPort(Service.java:119) で org.wso2.carbon .statistics.services.StatisticsAdmin.getStatisticsAdminHttpsSoap11Endpoint(StatisticsAdmin.java:101) at test1.StatisticsAdminLibrary.(StatisticsAdminLibrary.java:41) at test1.StatisticsAdminLibrary.main(StatisticsAdminLibrary.java:204)org.wso2.carbon.statistics.services.StatisticsAdmin の javax.xml.ws.Service.getPort(Service.java:119) の sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:294)。 getStatisticsAdminHttpsSoap11Endpoint(StatisticsAdmin.java:101) at test1.StatisticsAdminLibrary.(StatisticsAdminLibrary.java:41) at test1.StatisticsAdminLibrary.main(StatisticsAdminLibrary.java:204)org.wso2.carbon.statistics.services.StatisticsAdmin の javax.xml.ws.Service.getPort(Service.java:119) の sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:294)。 getStatisticsAdminHttpsSoap11Endpoint(StatisticsAdmin.java:101) at test1.StatisticsAdminLibrary.(StatisticsAdminLibrary.java:41) at test1.StatisticsAdminLibrary.main(StatisticsAdminLibrary.java:204)

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>test1</groupId>
    <artifactId>test1</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <cxf.version>2.2.3</cxf.version>
    </properties>   

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>1.6.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.5.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-api</artifactId>
            <version>1.2.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-impl</artifactId>
            <version>1.2.13</version>
        </dependency>
        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
            <version>1.6.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.neethi</groupId>
            <artifactId>neethi</artifactId>
            <version>3.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-local</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-http</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.commons.schema</groupId>
            <artifactId>XmlSchema</artifactId>
            <version>1.4.7</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
        </dependency>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>ST4</artifactId>
            <version>4.0.7</version>
        </dependency>


    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>2.7.7</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>                         
                            <wsdlRoot>${basedir}/src/main/resources</wsdlRoot>
                            <includes>
                                <include>*.wsdl</include>
                            </includes>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.googlecode.robotframework-maven-plugin</groupId>
                <artifactId>robotframework-maven-plugin</artifactId>
                <version>1.1.2</version>

                <configuration>
                    <extraPathDirectories>                      
                    </extraPathDirectories>
                </configuration>

                <executions>
                    <execution>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

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

wsdlファイル

4

2 に答える 2

1

同じことが私にも起こりました。おそらく、問題の原因となっている wsdl で、名前が文字列「java:...」で始まる 1 つ以上の名前空間への参照があります。これらの名前空間は、名前が java... で始まるパッケージを生成しています。

これを修正するには、pom.xml ファイルの execution/configuration/extraargs 要素に、「java:...」で始まる名前空間ごとに、このような要素を 1 つ配置する必要があります。

<extraarg>-p</extraarg>                                        
<extraarg>java:...=yourpackagename</extraarg> 
于 2014-07-30T13:59:50.533 に答える