web-dev-qa-db-fra.com

comment résoudre Causé par: Java.lang.ClassNotFoundException: javax.xml.bind.JAXBException migration vers Java 11 (Openjdk-11.0.1)

J'ai installé OpenJDK 11.0.1 et lorsque j'essaie d'exécuter mon application à l'aide de l'installation mvn, j'obtiens l'erreur suivante, j'ai ajouté la dépendance nécessaire en tant que correctif en ajoutant javax.xml.bind à mon pom.xml mais ce n'est pas le cas semblent fonctionner, quelqu'un a fait face à ce problème? dois-je faire autre chose? mon mvn --version retourne ceci

Maven home: /usr/local/Cellar/maven/3.5.2/libexec
Java version: 11.0.1, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.2", Arch: "x86_64", family: "mac"

j'ajoute cela mais n'a pas résolu le problème

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>

et voici ce que j'obtiens

[INFO] --- maven-failsafe-plugin:2.20:integration-test (failsafe-integration-tests) @ name-sample-test ---
[WARNING] Error injecting: org.Apache.maven.plugin.failsafe.IntegrationTestMojo
Java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
    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.getDeclaredConstructors(Class.Java:2358)
    at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.Java:245)
    at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.Java:99)
    at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.Java:658)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.Java:882)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.Java:805)
    at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.Java:282)
    at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.Java:214)
    at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.Java:1006)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.Java:1038)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.Java:1001)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.Java:1051)
    at org.Eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.Java:48)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.Java:81)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.Java:53)
    at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.Java:65)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.Java:115)
    at org.Eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.Java:176)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.Java:126)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.Java:68)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.Java:63)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.Java:45)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.Java:1016)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.Java:1092)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.Java:1012)
    at org.Eclipse.sisu.inject.Guice4$1.get(Guice4.Java:162)
    at org.Eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.Java:81)
    at org.Eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.Java:51)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.Java:263)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.Java:255)
    at org.Apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.Java:517)
    at org.Apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.Java:121)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:207)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:153)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:145)
    at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:116)
    at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:80)
    at org.Apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.Java:51)
    at org.Apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.Java:128)
    at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:307)
    at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:193)
    at org.Apache.maven.DefaultMaven.execute(DefaultMaven.Java:106)
    at org.Apache.maven.cli.MavenCli.execute(MavenCli.Java:863)
    at org.Apache.maven.cli.MavenCli.doMain(MavenCli.Java:288)
    at org.Apache.maven.cli.MavenCli.main(MavenCli.Java:199)
    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:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.Java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.Java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.Java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.Java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.Java:47)
Caused by: Java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
    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)
    ... 56 more
8
Ipkiss

Vous devez également ajouter cette dépendance,

<dependency>
    <groupId>com.Sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.3.0</version>
</dependency>
1
kik

J'ai eu un problème similaire auparavant lorsque j'ai essayé de déployer mon application Spring Boot sur un conteneur de servlet autonome qui porte sa propre implémentation JAXB. Votre application a été obligée d'utiliser la bibliothèque JAXB à partir de l'environnement au lieu d'utiliser le jaxb-api de la dépendance Maven. Vous pouvez résoudre ce problème en incluant une seule ligne dans votre Application.Java.

public static void main(String[] args) {
    // com.Sun.xml.bind.v2.ContextFactory comes from within your depedency
    System.setProperty("javax.xml.bind.JAXBContextFactory", "com.Sun.xml.bind.v2.ContextFactory");

    SpringApplication.run(MonolithicApplication.class, args);
}
0
Mr.J4mes