jaxb2-maven-plugin 在 Java 8 上失败。

huangapple go评论85阅读模式
英文:

jaxb2-maven-plugin failing on Java 8

问题

使用版本为1.6的jaxb2-maven-plugin来运行目标xjc。它出现了以下错误。我在.m2文件夹中进行了检查,确实有javax activation jar。我甚至尝试删除了.m2文件夹并重新构建,但仍然出现相同的错误。

下面是我使用的Maven和Java的版本:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven路径:/usr/local/Cellar/maven/3.6.3_1/libexec
Java版本:14.0.1,供应商:N/A,运行时:/usr/local/Cellar/openjdk/14.0.1/libexec/openjdk.jdk/Contents/Home
默认区域设置:en_IN,平台编码:UTF-8
操作系统名称:"mac os x",版本:"10.14.6",架构:"x86_64",系列:"mac"

java版本 "1.8.0_261"
Java(TM) SE Runtime Environment(build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM(build 25.261-b12,mixed mode)

[ERROR] 无法执行目标org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc(generate-source-provider)于项目provider-integrationtests:执行目标org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc的generate-source-provider失败:在执行org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc时缺少所需的类:javax/activation/DataSource
[ERROR] -----------------------------------------------------
[ERROR] 领域 =    plugin>org.codehaus.mojo:jaxb2-maven-plugin:1.6
[ERROR] 策略 = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/ajay/.m2/repository/org/codehaus/mojo/jaxb2-maven-plugin/1.6/jaxb2-maven-plugin-1.6.jar
[ERROR] urls[1] = file:/Users/ajay/.m2/repository/org/slf4j/slf4j-jdk14/1.5.6/slf4j-jdk14-1.5.6.jar
[ERROR] ...

[ERROR] : javax.activation.DataSource
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: 无法执行目标org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc(generate-source-provider)于项目provider-integrationtests:执行目标org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc的generate-source-provider失败:在执行org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc时缺少所需的类:javax/activation/DataSource

at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:169)
...
Caused by: java.lang.NoClassDefFoundError: javax/activation/DataSource
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit> (RuntimeBuiltinLeafInfoImpl.java:464)
    ...
英文:

I am using jaxb2-maven-plugin version 1.6 to run the goal xjc. It's failing with the below error. I checked in the .m2 folder and it does have the javax activation jar. I even tried deleting the .m2 folder and building it again but getting the same error.

Below are the versions of maven and Java I am using

Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 14.0.1, vendor: N/A, runtime: /usr/local/Cellar/openjdk/14.0.1/libexec/openjdk.jdk/Contents/Home
Default locale: en_IN, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc (generate-source-provider) on project provider-integrationtests: Execution generate-source-provider of goal org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc failed: A required class was missing while executing org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc: javax/activation/DataSource
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.codehaus.mojo:jaxb2-maven-plugin:1.6
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/ajay/.m2/repository/org/codehaus/mojo/jaxb2-maven-plugin/1.6/jaxb2-maven-plugin-1.6.jar
[ERROR] urls[1] = file:/Users/ajay/.m2/repository/org/slf4j/slf4j-jdk14/1.5.6/slf4j-jdk14-1.5.6.jar
[ERROR] urls[2] = file:/Users/ajay/.m2/repository/org/slf4j/jcl-over-slf4j/1.5.6/jcl-over-slf4j-1.5.6.jar
[ERROR] urls[3] = file:/Users/ajay/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar
[ERROR] urls[4] = file:/Users/ajay/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.1/doxia-sink-api-1.1.jar
[ERROR] urls[5] = file:/Users/ajay/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
[ERROR] urls[6] = file:/Users/ajay/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar
[ERROR] urls[7] = file:/Users/ajay/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
[ERROR] urls[8] = file:/Users/ajay/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[9] = file:/Users/ajay/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[10] = file:/Users/ajay/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[11] = file:/Users/ajay/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
[ERROR] urls[12] = file:/Users/ajay/.m2/repository/com/sun/xml/bind/jaxb-xjc/2.2.7/jaxb-xjc-2.2.7.jar
[ERROR] urls[13] = file:/Users/ajay/.m2/repository/com/sun/xml/bind/jaxb-core/2.2.7/jaxb-core-2.2.7.jar
[ERROR] urls[14] = file:/Users/ajay/.m2/repository/javax/xml/bind/jaxb-api/2.2.7/jaxb-api-2.2.7.jar
[ERROR] urls[15] = file:/Users/ajay/.m2/repository/com/sun/istack/istack-commons-runtime/2.16/istack-commons-runtime-2.16.jar
[ERROR] urls[16] = file:/Users/ajay/.m2/repository/com/sun/xml/bind/jaxb-jxc/2.2.7/jaxb-jxc-2.2.7.jar
[ERROR] urls[17] = file:/Users/ajay/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.7/jaxb-impl-2.2.7.jar
[ERROR] urls[18] = file:/Users/ajay/.m2/repository/com/sun/xml/fastinfoset/FastInfoset/1.2.12/FastInfoset-1.2.12.jar
[ERROR] urls[19] = file:/Users/ajay/.m2/repository/org/codehaus/plexus/plexus-compiler-api/1.9.1/plexus-compiler-api-1.9.1.jar
[ERROR] urls[20] = file:/Users/ajay/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.16/plexus-utils-3.0.16.jar
[ERROR] urls[21] = file:/Users/ajay/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] : javax.activation.DataSource
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc (generate-source-provider) on project provider-integrationtests: Execution generate-source-provider of goal org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc failed: A required class was missing while executing org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc: javax/activation/DataSource
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:169)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.NoClassDefFoundError: javax/activation/DataSource
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit> (RuntimeBuiltinLeafInfoImpl.java:464)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init> (RuntimeTypeInfoSetImpl.java:64)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet (RuntimeModelBuilder.java:133)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet (RuntimeModelBuilder.java:85)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.<init> (ModelBuilder.java:162)
</details>
# 答案1
**得分**: 0
问题出在Maven版本上。Brew一直使用OpenJDK 14依赖项安装它。我下载了Maven,并按照[这里](https://maven.apache.org/install.html)的安装说明进行了安装。然后我运行了 `mvn clean` 命令,然后重新构建了项目。问题迎刃而解。
<details>
<summary>英文:</summary>
The problem was the maven version. Brew was always installing it with OpenJDK 14 dependency. I downloaded maven and followed the installation instructions from [here][1]. Then I did `mvn clean` and built the project again. Voila! The problem got solved.
[1]: https://maven.apache.org/install.html
</details>
# 答案2
**得分**: 0
请使用当前的 jaxb2 版本,您正在使用的是 1.6 版本。
> org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc 
这个版本对我有效:
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<details>
<summary>英文:</summary>
Please use the current jaxb2 version, you are using the 1.6 version.
&gt; org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc 
This version works for me:
&lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
&lt;artifactId&gt;jaxb2-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;2.5.0&lt;/version&gt;
</details>
# 答案3
**得分**: 0
如果您正在使用STS并且遇到以下错误,请按照以下步骤操作:
右键单击您的项目->点击“构建路径”->点击“添加库”->选择“JRE系统库”,然后点击“下一步”->点击“已安装的JRE”->点击“添加”,然后从您的本地选择JDK。
<details>
<summary>英文:</summary>
if you are using sts and facing the error the follow below steps
right click on your project-&gt;click on Build path-&gt;click on Add libraries-&gt;select JRE System Library then click next-&gt;click Installed JREs -&gt;click on add and select jdk from your local 
</details>

huangapple
  • 本文由 发表于 2020年7月24日 16:38:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/63069962.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定