在eclipse中使用wsdl2java和cxf-codegen-plugin我生成了WSDL文件的客戶端代碼。但由於SecurityException:無法運行客戶端:禁止的包名稱:java.util.xsd。cxf-codegen-plugin生成禁止的包名:java.util.xsd
有什麼辦法解決這個問題?
異常是這樣的。
異常在線程 「主」 java.lang.SecurityException異常:在 java.lang.ClassLoader.preDefineClass(ClassLoader.java:649)在 java.lang中java.util.xsd:禁止 包名稱。 ClassLoader.defineClass(ClassLoader.java:785)at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)at java.net.URLClassLoader java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) 。訪問$ 100(URLClassLoader.java:71) java.net.URLClassLoader $ 1.run(URLClassLoader.java:361)at java.net.URLClassLoader $ 1.run(URLClassLoader.java:355)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:354)at java.lang.ClassLoader.loadClass(ClassLoader.java:423)at sun.misc。啓動器$ AppClassLoader.loadClass(Launcher.java:308)at java.lang.ClassLoader.loadClass(ClassLoader.java:356)at java.lang.Class.forName0(Native Method)at java.lang.Class.forName (Class.java:266)在 sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114) 在 sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) 在 sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignat ure.java:49) 在 sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:390) 在 sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:371) 在 sun.reflect .annotation.AnnotationParser.parseClassArray在 sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:480)(AnnotationParser.java:673) 在 sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:306 ) at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:241) at sun.reflect.annotation.A nnotationParser.parseAnnotations2在 sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70) 在java.lang.Class.initAnnotationsIfNecessary(Class.java:3098)(AnnotationParser.java:88) 在 java.lang中.Class.getAnnotation(Class.java:3057)at com.sun.xml.internal.ws.model.RuntimeModeler $ 1.run(RuntimeModeler.java:156) at com.sun.xml.internal.ws.model .RuntimeModeler $ 1.run(RuntimeModeler.java:154) at java.security.AccessController.doPrivileged(Native Method)at com.sun.xml.internal.ws.model.RuntimeModeler.getPrivClassAnnotation(RuntimeModeler.java:154) 在 com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(Ru ntimeModeler.java:190) 在 com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:672) 在 com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI( WSServiceDelegate。java:660) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:329) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate。 java:312) at 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)
的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>
歡迎來到StackOverflow。請使用更多信息編輯您的問題。例如,你一定要包含你已經擁有的代碼。所以我和其他人可以運行代碼,並在同一行上獲取相同的錯誤。 –
附加您的WSDL文件。你如何生成代碼?如果使用Maven或命令附加pom.xml片段(如果使用wsdl2java生成)。也許你的WSDL包含奇怪的命名空間,這將轉化爲禁止的包名稱。 – bary
感謝您的指導。這個異常只發生在一些wsdl。 – user1541368