Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 9+ Dependencies On Java EE Modules #40

Closed
cisba opened this issue Nov 13, 2019 · 2 comments · Fixed by #41
Closed

Java 9+ Dependencies On Java EE Modules #40

cisba opened this issue Nov 13, 2019 · 2 comments · Fixed by #41

Comments

@cisba
Copy link
Contributor

cisba commented Nov 13, 2019

With java 9 executing mvn package produces this error:

package javax.xml.bind is not visible
  (package javax.xml.bind is declared in module java.xml.bind, which is not in the module graph)

The issue is explained here.

Fixes on Java 9 and 10
Once you modularized your code, you can declare a regular dependency in the module’s declaration. Until then, --add-modules $module comes to your rescue, which makes sure $module is available and can be added to both java and javac. If you add java.se.ee, you’ll have access to all Java EE modules.

Fixes on Java 11 and later
Java 11 removes the Java EE modules, so from then on you will need third-party implementations instead. This StackOverflow answer contains a list of alternatives. Note that using third-party dependencies already works from Java 9 on, so you don’t have to use --add-modules as a stopgap.

@cisba
Copy link
Contributor Author

cisba commented Nov 13, 2019

I'm not a java expert, so it could be just a workaround (waiting for someone to do a clean PR), but finally I managed to build with two changes in the pom.xml (tested on macOS 10.15.1, maven 3.6.2 and java 9).

  1. added jabx dependency as suggested here:
   <dependency>
       <groupId>org.glassfish.jaxb</groupId>
       <artifactId>jaxb-runtime</artifactId>
       <version>2.3.1</version>
       <scope>runtime</scope>
   </dependency>

Then I encountered a problem with the javadoc plugin:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar (attach-javadocs) on project java-opentimestamps: Execution attach-javadocs of goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar: java.lang.ExceptionInInitializerError: null

  1. so I changed the plugin config as suggested here
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-javadoc-plugin</artifactId>
-                <version>2.9.1</version>
+                <version>3.1.1</version>
                 <executions>
                     <execution>
                         <id>attach-javadocs</id>
                         <goals>
                             <goal>jar</goal>
                         </goals>
+                        <configuration>
+                            <use>false</use>
+                            <source>1.8</source>
+                                <links>
+                                    <link>http://docs.oracle.com/javase/7/docs/api/</link>
+                                </links>
+                            <doclint>none</doclint>
+                        </configuration>
                     </execution>
                 </executions>
             </plugin>

@cisba
Copy link
Contributor Author

cisba commented Nov 13, 2019

Using openjdk 11 (installed via brew) I encountered the same problems solved with the same changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant