[英]Unable to get public no-arg constructor
Recently I have imported Paho MQTT Spy project into Eclipse. Got error atthe end of import:最近我将Paho MQTT Spy项目导入到Eclipse,导入结束报错:
building has encouted a problem. An internal error occured during: "Build"
An internal error occurred during: "Building".
com.sun.tools.xjc.Plugin: com.sun.tools.xjc.addon.accessors.PluginImpl Unable to get public no-arg constructor
Why I'm getting this message and what does it means?为什么我会收到此消息,这意味着什么? How to fix it?如何解决?
I'm using Java 13.0.1我正在使用 Java 13.0.1
I was trying to build mqtt-spy
project with maven and got the same error.我试图用 maven 构建mqtt-spy
项目,但得到了同样的错误。
I added dependecies below to to pom.xml我将下面的依赖项添加到 pom.xml
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
And now pom.xml looks like below:现在 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>org.eclipse.paho.mqttspy</groupId>
<artifactId>mqtt-spy</artifactId>
<version>1.0.1-beta</version>
<packaging>jar</packaging>
<name>mqtt-spy</name>
<url>https://github.com/eclipse/paho.mqtt-spy</url>
<scm>
<connection>scm:git:../.git</connection>
<url>../.git</url>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.number>${buildNumber}</project.build.number>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy</maven.build.timestamp.format>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jaxb2.plugin.version>0.12.1</jaxb2.plugin.version>
<jaxb2.basics.version>0.11.1</jaxb2.basics.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>11</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.eclipse.paho.mqttspy</groupId>
<artifactId>spy-common</artifactId>
<version>1.0.1</version>
<exclusions>
<exclusion>
<artifactId>maven-jaxb2-plugin</artifactId>
<groupId>org.jvnet.jaxb2.maven2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.paho.mqttspy</groupId>
<artifactId>spy-common-ui</artifactId>
<version>1.0.1</version>
<exclusions>
<exclusion>
<artifactId>maven-jaxb2-plugin</artifactId>
<groupId>org.jvnet.jaxb2.maven2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.paho.mqttspy</groupId>
<artifactId>mqtt-spy-common</artifactId>
<version>1.0.1</version>
<exclusions>
<exclusion>
<artifactId>maven-jaxb2-plugin</artifactId>
<groupId>org.jvnet.jaxb2.maven2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.0</version>
</dependency>
<!--=== TEST === -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-legacy</artifactId>
<version>2.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}-b${buildNumber}</finalName>
<!-- Populate version number in the properties file -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/mqtt-spy.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/mqtt-spy.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<!-- Exclude files -->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>package-client</id>
<phase>package</phase>
<configuration>
<classifier>exclusions</classifier>
<excludes>
<exclude>**/log4j.properties</exclude>
</excludes>
</configuration>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Create a runnable jar with all dependencies -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>pl.baczkowicz.mqttspy.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Generate build number -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>true</doCheck>
<doUpdate>true</doUpdate>
<buildNumberPropertiesFileLocation>buildNumber.properties</buildNumberPropertiesFileLocation>
<format>{0,number,###}</format>
<items>
<item>buildNumber</item>
</items>
</configuration>
</plugin>
<!-- Generate JAXB clases -->
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>${jaxb2.basics.version}</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>${jaxb2.plugin.version}</version>
<executions>
<execution>
<id>configuration</id>
<phase>generate-resources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<locale>en</locale>
<schemaDirectory>src/main/resources/</schemaDirectory>
<schemaIncludes>
<include>mqtt-spy-configuration.xsd</include>
</schemaIncludes>
<!-- Default to the schemaDirectory -->
<bindingDirectory>src/main/resources</bindingDirectory>
<bindingIncludes>
<include>**/mqtt-spy-configuration-bindings.xjb</include>
</bindingIncludes>
<generateDirectory>src/main/java/</generateDirectory>
<generatePackage>pl.baczkowicz.mqttspy.configuration.generated</generatePackage>
<removeOldOutput>false</removeOldOutput>
<strict>false</strict>
<catalogs>
<catalog>
<dependencyResource>
<groupId>org.eclipse.paho.mqttspy</groupId>
<artifactId>mqtt-spy-common</artifactId>
<resource>mqtt-spy-common.catalog</resource>
</dependencyResource>
</catalog>
<catalog>
<dependencyResource>
<groupId>org.eclipse.paho.mqttspy</groupId>
<artifactId>spy-common</artifactId>
<resource>spy-common.catalog</resource>
</dependencyResource>
</catalog>
</catalogs>
<episode>true</episode>
<!-- <episodeFile>src/main/java/META-INF/mqtt-spy-configuration.episode</episodeFile> -->
<episodes>
<episode>
<groupId>org.eclipse.paho.mqttspy</groupId>
<artifactId>mqtt-spy-common</artifactId>
</episode>
<episode>
<groupId>org.eclipse.paho.mqttspy</groupId>
<artifactId>spy-common</artifactId>
</episode>
</episodes>
<args>
<arg>-XtoString</arg>
<arg>-Xequals</arg>
<arg>-XhashCode</arg>
<arg>-Xcopyable</arg>
<arg>-Xvalue-constructor</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>${jaxb2.basics.version}</version>
</plugin>
</plugins>
</configuration>
</execution>
<execution>
<id>stats</id>
<phase>generate-resources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<locale>en</locale>
<schemaDirectory>src/main/resources/</schemaDirectory>
<schemaIncludes>
<include>mqtt-spy-stats.xsd</include>
</schemaIncludes>
<!-- Default to the schemaDirectory -->
<bindingDirectory>src/main/resources</bindingDirectory>
<bindingIncludes>
<include>**/mqtt-spy-stats-bindings.xjb</include>
</bindingIncludes>
<generateDirectory>src/main/java/</generateDirectory>
<generatePackage>pl.baczkowicz.mqttspy.stats.generated</generatePackage>
<removeOldOutput>false</removeOldOutput>
<episode>false</episode>
<!-- <episodeFile>src/main/java/META-INF/mqtt-spy-stats.episode</episodeFile> -->
<args>
<arg>-XtoString</arg>
<arg>-Xequals</arg>
<arg>-XhashCode</arg>
<arg>-Xcopyable</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>${jaxb2.basics.version}</version>
</plugin>
</plugins>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-value-constructor</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>replace</id>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${basedir}/src/main/java</basedir>
<includes>
<include>pl/baczkowicz/mqttspy/configuration/generated/**/*.java</include>
<include>pl/baczkowicz/mqttspy/stats/generated/**/*.java</include>
</includes>
<replacements>
<replacement>
<token>//${line.separator}// This file was generated by the
JavaTM</token>
<value>//
// Copyright (c) ${maven.build.timestamp} Kamil Baczkowicz
//
// CSOFF: a.*
// This file was generated by the JavaTM</value>
</replacement>
<replacement>
<token>^ \*/</token>
<value> */
@SuppressWarnings("all")</value>
</replacement>
<replacement>
<token>^// Generated on.*$</token>
<value>// Timestamp removed by maven-replacer-plugin to avoid
detecting changes - see the project POM for details</value>
</replacement>
</replacements>
<regex>true</regex>
<quiet>false</quiet>
<regexFlags>
<regexFlag>MULTILINE</regexFlag>
</regexFlags>
</configuration>
</plugin>
</plugins>
</build>
</project>
Maven gives error: Maven 给出错误:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.eclipse.paho.mqttspy:mqtt-spy:jar:1.0.1-beta
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 162, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -----------------< org.eclipse.paho.mqttspy:mqtt-spy >------------------
[INFO] Building mqtt-spy 1.0.1-beta
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.sun.xml.bind:jaxb-core:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.sun.xml.bind:jaxb-impl:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.eclipse.paho.mqttspy:spy-common:jar:1.0.1 is missing, no dependency information available
[WARNING] The POM for org.eclipse.paho.mqttspy:spy-common-ui:jar:1.0.1 is missing, no dependency information available
[WARNING] The POM for org.eclipse.paho.mqttspy:mqtt-spy-common:jar:1.0.1 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.384 s
[INFO] Finished at: 2020-01-08T16:10:33+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project mqtt-spy: Could not resolve dependencies for project org.eclipse.paho.mqttspy:mqtt-spy:jar:1.0.1-beta: The following artifacts could not be resolved: org.eclipse.paho.mqttspy:spy-common:jar:1.0.1, org.eclipse.paho.mqttspy:spy-common-ui:jar:1.0.1, org.eclipse.paho.mqttspy:mqtt-spy-common:jar:1.0.1: Failure to find org.eclipse.paho.mqttspy:spy-common:jar:1.0.1 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
UPD更新程序
Java 8 solves problem, but I still trying to make java 13 work with it. Java 8 解决了问题,但我仍在尝试让 java 13 使用它。
Trying to build very root project with pom.xml defined below.尝试使用下面定义的 pom.xml 构建根项目。 pom.xml now contains required javax dependencies. pom.xml 现在包含必需的 javax 依赖项。
<?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>
<name>mqtt-spy project</name>
<groupId>pl.baczkowicz.mqttspy</groupId>
<artifactId>mqtt-spy-pom</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<properties>
<main.basedir>${project.basedir}</main.basedir>
</properties>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<!-- Include all modules in correct order. -->
<modules>
<module>spy-common</module>
<module>spy-common-ui</module>
<module>mqtt-spy-common</module>
<module>mqtt-spy-daemon</module>
<module>mqtt-spy</module>
</modules>
</project>
Got same error:得到同样的错误:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.eclipse.paho.mqttspy:mqtt-spy-daemon:jar:1.0.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 113, column 15
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.eclipse.paho.mqttspy:mqtt-spy:jar:1.0.1-beta
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 162, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] spy-common [jar]
[INFO] spy-common-ui [jar]
[INFO] mqtt-spy-common [jar]
[INFO] mqtt-spy-daemon [jar]
[INFO] mqtt-spy [jar]
[INFO] mqtt-spy project [pom]
[INFO]
[INFO] ----------------< org.eclipse.paho.mqttspy:spy-common >-----------------
[INFO] Building spy-common 1.0.1 [1/6]
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.sun.xml.bind:jaxb-impl:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.sun.xml.bind:jaxb-xjc:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.sun.xml.bind:jaxb-core:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-jaxb2-plugin:0.12.1:generate (spy-common) @ spy-common ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] spy-common 1.0.1 ................................... FAILURE [ 0.737 s]
[INFO] spy-common-ui 1.0.1 ................................ SKIPPED
[INFO] mqtt-spy-common 1.0.1 .............................. SKIPPED
[INFO] mqtt-spy-daemon 1.0.0 .............................. SKIPPED
[INFO] mqtt-spy 1.0.1-beta ................................ SKIPPED
[INFO] mqtt-spy project 0.0.1-SNAPSHOT .................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.910 s
[INFO] Finished at: 2020-01-08T20:05:25+02:00
[INFO] ------------------------------------------------------------------------
......
---------------------------------------------------
Exception in thread "main" java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin: com.sun.tools.xjc.addon.accessors.PluginImpl Unable to get public no-arg constructor
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:583)
at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:674)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1233)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1265)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1300)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1385)
at com.sun.tools.xjc.Options.findServices(Options.java:960)
at com.sun.tools.xjc.Options.getAllPlugins(Options.java:374)
at com.sun.tools.xjc.Options.parseArgument(Options.java:688)
at com.sun.tools.xjc.Options.parseArguments(Options.java:812)
at org.jvnet.mjiip.v_2.OptionsFactory.createOptions(OptionsFactory.java:87)
at org.jvnet.mjiip.v_2.OptionsFactory.createOptions(OptionsFactory.java:18)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:462)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:311)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
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/xml/bind/annotation/XmlAccessType
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3138)
at java.base/java.lang.Class.getConstructor0(Class.java:3343)
at java.base/java.lang.Class.getConstructor(Class.java:2152)
at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:661)
at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:658)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:669)
... 34 more
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlAccessType
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
... 42 more
You are propably not using JAVA 8. Please define Java 8 in project properties and try to build it again.您可能没有使用 JAVA 8。请在项目属性中定义 Java 8 并尝试重新构建它。 If you are using Java9 or greater, since they droped the use of classpath you need to add --add-modules java.xml.bind as a JVM param in order to wire the mdule如果您使用的是 Java9 或更高版本,由于他们放弃了类路径的使用,您需要添加 --add-modules java.xml.bind 作为 JVM 参数以连接 mdule
Apparently this is due to not using a JAVA 8 or higher version.显然这是由于没有使用 JAVA 8 或更高版本。
Here is an example on how to deal with the problem in Eclipse下面举例说明如何处理Eclipse中的问题
MORE DETAILS更多细节
The exception seems to come from another root cause :异常似乎来自另一个根本原因:
Caused by: java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin: com.sun.tools.xjc.addon.accessors.PluginImpl Unable to get public no-arg constructor
...
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlAccessType
Newer java versions seems to carry this bug.较新的Java 版本似乎带有此错误。
You can fix your problem with two options您可以通过两个选项解决您的问题
1) add module dependencies 1) 添加模块依赖
--add-modules java.xml.bind
--add-modules java.se.ee
This would fit to JAVA 9 and higher but will broke compatibility with JAVA 8 and inferior for whom --add-modules is unkwown.这将适合 JAVA 9 及更高版本,但会破坏与 JAVA 8 的兼容性,并且不知道 --add-modules 的情况。
2) add the library as a dependency in POM.XML 2)在POM.XML中添加库作为依赖
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
EDIT :编辑 :
As far as know ther no groupId in maven with a name such org.eclipse.paho.mqttspy
据了解,Maven 中没有 groupId 名称,例如org.eclipse.paho.mqttspy
From the Paho Spy wiki the only dependecy is MQTTV Client从 Paho Spy wiki 中,唯一的依赖是MQTTV Client
Try change you dependency and include instead :尝试更改您的依赖项并改为包含:
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.2</version>
<type>eclipse-plugin</type>
</dependency>
Your build seems also to fail because of a not found dependency :由于未找到依赖项,您的构建似乎也失败了:
[ERROR] Failed to execute goal on project mqtt-spy: Could not resolve dependencies for project org.eclipse.paho.mqttspy:mqtt-spy:jar:1.0.1-beta: The following artifacts could not be resolved: org.eclipse.paho.mqttspy:spy-common:jar:1.0.1, org.eclipse.paho.mqttspy:spy-common-ui:jar:1.0.1, org.eclipse.paho.mqttspy:mqtt-spy-common:jar:1.0.1: Failure to find org.eclipse.paho.mqttspy:spy-common:jar:1.0.1 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1] [错误] 无法在项目 mqtt-spy 上执行目标:无法解析项目 org.eclipse.paho.mqttspy:mqtt-spy:jar:1.0.1-beta 的依赖项:无法解析以下工件:org.eclipse .paho.mqttspy:spy-common:jar:1.0.1, org.eclipse.paho.mqttspy:spy-common-ui:jar:1.0.1, org.eclipse.paho.mqttspy:mqtt-spy-common:jar :1.0.1: failed to find org.eclipse.paho.mqttspy:spy-common:jar:1.0.1 in https://repo.maven.apache.org/maven2已缓存在本地仓库中,不会解析重试直到 Central 的更新间隔已过或强制更新 -> [帮助 1]
EDIT 2 :编辑 2:
try also to check your spy version.还尝试检查您的间谍版本。 Previous versions seemed to have the same problem for JDK > 9. A patch was provided here JDK > 9 以前的版本似乎也有同样的问题。这里提供了一个补丁
This Answer may come a bit late but I've manged to run it on Java 13 with the LATEST version so:这个答案可能来得有点晚,但我已经设法在 Java 13 上使用最新版本运行它,所以:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.basedir}/src/main/resources/xsd</schemaDirectory>
<generatePackage>package.name</generatePackage>
<generateDirectory>${project.basedir}/target/generated-sources/xjc</generateDirectory>
</configuration>
</plugin>
To add the above answers, I had the same issue and was able to resolve by changing the JAVA_HOME environment variable from JDK 11 to JDK 8.要添加上述答案,我遇到了同样的问题,并且能够通过将 JAVA_HOME 环境变量从 JDK 11 更改为 JDK 8 来解决。
I would check the environment variable aswell as your IDE Java settings and your Java version in the project.我会检查环境变量以及项目中的 IDE Java 设置和 Java 版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.