Package javax.xml.bind.annotations is declared in module java.xml.bind, which is not in the module graph

已回答

Hello, since I upgraded to 2018.1 all my JAXB annotations are breaking with error "Package javax.xml.bind.annotations is declared in module java.xml.bind, which is not in the module graph"

I was using JDK9.0.1 from Oracle before the upgrade and I'm still using the same JDK after the IntelliJ upgrade, so I'm not sure if this is a new restriction or what.

Has anyone faced a similar issue or any idea what the problem might be?

Thanks!

Cyril

3

Hello Cyril,

Do you have "--add-modules" option enabled: https://www.logicbig.com/tutorials/core-java-tutorial/modules/root-modules.html ?

 

0

Hi, having the same issue since 2018.1.

Package 'javax.xml.bind' is declared in module 'java.xml.bind', which is not in the module graph

My code compiles perfectly fine because of this maven dependency: https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api

But IntelliJ isn't detecting it anymore

0

Does adding --add-modules "java.xml.bind" JVM flag help?

0

Doesn't seem to do anything for me.

0

Please follow the issue on YouTrack for updates: https://youtrack.jetbrains.com/issue/IDEA-189060

0
Avatar
Permanently deleted user

Thank you Yaroslav. Is there a way to subscribe for updates on YouTrack tickets?

Just like Mikuschger, my mvn build works fine w/o any --add-modules. Please specify how to add this flag to IntelliJ 2018 if it that's what you meant.

I'm on Ubuntu 16.04 FYI if that makes a difference. My colleagues on OSX don't seem to have this issue with the same project files.

0

I have a similar issues, but with maven. If I run mvn clean install for a project from within a terminal, all forks fine. Using the maven support in IDEA gives me the error from the title.

This is what I use regarding the compilation:

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>--add-modules=java.xml.bind</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

IntelliJ Version is:

IntelliJ IDEA 2018.2.2 (Ultimate Edition)
Build #IU-182.4129.33, built on August 21, 2018
Licensed to Marcel Lautenbach
Subscription is active until April 27, 2019
JRE: 1.8.0_152-release-1248-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.17.0-1-amd64

I have also tried to set these flags for modules and the compiler in the general settings. But no luck. ;-(
0

Hello Marcel,

Could you please share project example? It works fine on my machine with test project.

0

Hi Yaroslav, thank you for the extremly quick answer. I worked my way through our maven hierarchy of parent and root poms and finally came up with a simple pom and test class. 

So, here is the pom:

<?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>

<groupId>example_debug</groupId>
<artifactId>module-test</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<id>jpa-processor</id>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
<execution>
<id>jpa-processor-additional-sources</id>
<phase>compile</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>3.7.4</version>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<classifier>apt</classifier>
<version>3.7.4</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>10</source>
<target>10</target>
<compilerArgs>
<arg>--add-modules=java.xml.bind</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>


</project>

 

And here is a simple class:

 

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "TestResponse")
public class TestResponse {

private String error;

}

 

 

Additonal Infos:

Apache Maven 3.5.3
Maven home: /usr/share/maven
Java version: 10.0.2, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-10-oracle
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.17.0-1-amd64", arch: "amd64", family: "unix"

 

I have set up IntelliJ to use the same maven, but also tried with the bundled version.

If you remove the <executions> tag including its children, It will compile in IntelliJ.

0

Marcel,

Test project based on provided pom.xml builds fine on my machine. Is it possible to provide whole project dir with IDE files/folders (.idea and .iml)?

 

0

Of course. Could you please provide an e-mail address or a space where I can upload the project?

0

Thanks for example! I reported an issue on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-197956. Please follow it for updates.

 

0

Marcel,

Don't you run "install" action from maven-install-plugin in command line? Message is generated by apt-plugin and is shown when running from command line.

0
Avatar
Permanently deleted user

I guess you are using java 9. If that's the case then you need to download and add the javax jar into your project

0
Avatar
Permanently deleted user

Hi 

I have got 2019.1 version of Pyharm and trying to use Custom JDBC driver provided by Vendor.I believe connections goes through half way and fails with following error 

java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter

I tried adding the additonal jar files for Jaxb-Api, but it is still displaying same error. I am new to Pycharm and less java knowledge. Any advice on how I can resolve this please ?

 

Regards


Venky

0

@... see https://youtrack.jetbrains.com/issue/DBE-8917 about similar error. PyCharm uses JDK 11 to run under. The jdbc driver you are using must be compatible with 11 JDK version. If you are using driver provided by the IDE, - latest PyCharm version provides the compatible jdbc drivers. Or else you can download driver and set it up manually in driver settings for the Data Source.

0

请先登录再写评论。