cxf codegen插件生成禁止的包名称:java.util.xsd
在eclipse中使用wsdl2java和cxf codegen插件,我为WSDL文件生成了客户机代码。但是我无法运行客户端,因为SecurityException:禁止的包名:java.util.xsd 有办法解决这个问题吗 例外是这样的 线程“main”java.lang.SecurityException中的异常:禁止 包名称:java.util.xsd at 预定义类(ClassLoader.java:649)位于 java.lang.ClassLoader.defineClass(ClassLoader.java:785)位于 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)位于 loadClass(ClassLoader.java:423)位于 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)位于 loadClass(ClassLoader.java:356)位于 java.lang.Class.forName0(本机方法)位于 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(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) 在 sun.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) 在java.lang.Class.InitAnnotationSifRequired(Class.java:3098)中 java.lang.Class.getAnnotation(Class.java:3057)位于 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(本机方法) com.sun.xml.internal.ws.model.RuntimeModeler.getPrivClassAnnotation(RuntimeModeler.java:154) 在 com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:190) 在 com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:672) 在 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) 在 test1.StatisticsAdminLibrary.(StatisticsAdminLibrary.java:41) 位于test1.StatisticsAdminLibrary.main(StatisticsAdminLibrary.java:204) pom.xmlcxf codegen插件生成禁止的包名称:java.util.xsd,java,wsdl,wsdl2java,cxf-codegen-plugin,Java,Wsdl,Wsdl2java,Cxf Codegen Plugin,在eclipse中使用wsdl2java和cxf codegen插件,我为WSDL文件生成了客户机代码。但是我无法运行客户端,因为SecurityException:禁止的包名:java.util.xsd 有办法解决这个问题吗 例外是这样的 线程“main”java.lang.SecurityException中的异常:禁止 包名称:java.util.xsd at 预定义类(ClassLoader.java:649)位于 java.lang.ClassLoader.defineClass(Cl
<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>
4.0.0
测试1
同样的事情也发生在我身上。可能,在给您带来麻烦的wsdl上,您引用了一个或多个名称空间,其名称以字符串“java:…”开头。这些名称空间正在生成名称以java…开头的包
为了修复它,您必须在pom.xml文件的execution/configuration/extraargs元素中放置一个这样的元素,用于每个以“java:…”开头的名称空间
-p
java:…=yourpackagename
我想我会分享我的gradle.build解决方案:
buildscript {
ext {
springBootVersion = '1.5.1.RELEASE'
}
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("no.nils:wsdl2java:0.10")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: "no.nils.wsdl2java"
// Prevents the boot packager from requiring a main class
bootRepackage {
bootRepackage.enabled = false
}
jar {
baseName = 'JAR-NAME'
version = '1.0.0-SNAPSHOT'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
// Generate sources off ccds wsdls
wsdl2java {
generatedWsdlDir = file("$projectDir/src/generated/java")
wsdlDir = file("$projectDir/src/main/resources/wsdl")
stabilizeAndMergeObjectFactory = true
wsdlsToGenerate = [
// These foo wsdl files make a reference to util.java and generated classes with package java.util.xsd
// The first argument to each renames that package to avoid security exceptions
// foo version
['-xjc','-p', 'http://util.java/xsd=com.foo.java.util.xsd','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/foo/wsdl-catalog.wsdl")],
['-xjc','-p', 'http://util.java/xsd=com.foo.java.util.xsd','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/foo/wsdl-inventory.wsdl")],
['-xjc','-p', 'http://util.java/xsd=com.foo.java.util.xsd','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/foo/wsdl-customer.wsdl")],
['-xjc','-p', 'http://util.java/xsd=com.foo.java.util.xsd','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/foo/wsdl-entity.wsdl")],
// Does not require renaming
['-xjc','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/foo/wsdl-workflow.wsdl")],
// bar version
['-xjc','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/bar/wsdl-billing.wsdl")]
]
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
}
欢迎来到StackOverflow。请用更多信息编辑您的问题。例如,您肯定希望包含您已经拥有的代码。这样,我和其他人就可以运行代码并在同一行上获得与您相同的错误。附加您的WSDL文件。如何生成代码?如果使用Maven,请附加pom.xml片段;如果使用wsdl2java生成,请附加command。也许您的WSDL包含奇怪的名称空间,这会转化为禁止的包名。谢谢您的指导。此异常仅在某些wsdl中发生。在${basedir}/src/main/resources中有多少wsdl文件?只有您链接的一个才能形成此github?不相关的问题-为什么同时使用axis2和cxf?不。目前我有6个wsdl。但是如果没有这个wsdl,它是可以的。当我把这个wsdl放到目录中时,它就会得到那个异常。在我的例子中,wsdl引用了“”命名空间,这导致了这个问题。左侧的参数必须完全等于名称空间,才能使此映射工作!
buildscript {
ext {
springBootVersion = '1.5.1.RELEASE'
}
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("no.nils:wsdl2java:0.10")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: "no.nils.wsdl2java"
// Prevents the boot packager from requiring a main class
bootRepackage {
bootRepackage.enabled = false
}
jar {
baseName = 'JAR-NAME'
version = '1.0.0-SNAPSHOT'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
// Generate sources off ccds wsdls
wsdl2java {
generatedWsdlDir = file("$projectDir/src/generated/java")
wsdlDir = file("$projectDir/src/main/resources/wsdl")
stabilizeAndMergeObjectFactory = true
wsdlsToGenerate = [
// These foo wsdl files make a reference to util.java and generated classes with package java.util.xsd
// The first argument to each renames that package to avoid security exceptions
// foo version
['-xjc','-p', 'http://util.java/xsd=com.foo.java.util.xsd','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/foo/wsdl-catalog.wsdl")],
['-xjc','-p', 'http://util.java/xsd=com.foo.java.util.xsd','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/foo/wsdl-inventory.wsdl")],
['-xjc','-p', 'http://util.java/xsd=com.foo.java.util.xsd','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/foo/wsdl-customer.wsdl")],
['-xjc','-p', 'http://util.java/xsd=com.foo.java.util.xsd','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/foo/wsdl-entity.wsdl")],
// Does not require renaming
['-xjc','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/foo/wsdl-workflow.wsdl")],
// bar version
['-xjc','-b', file("$wsdlDir/binding.xml"), file("$wsdlDir/bar/wsdl-billing.wsdl")]
]
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
}