"package javax.xml.soap is declared in the java.xml.ws module, which is not in the module graph"

So, I took the SOAP example in the Soap working client example , put it in the SOAPClientSAAJ.java file and tried to compile it (Openjdk 9 on Debian):

 t@h ~/javatest> javac SOAPClientSAAJ.java SOAPClientSAAJ.java:1: error: package javax.xml.soap is not visible import javax.xml.soap.*; ^ (package javax.xml.soap is declared in module java.xml.ws, which is not in the module graph) 1 error 

After some of them appeared on Google, I found out that compilation and launch are performed as

 t@h ~/javatest> javac --add-modules java.xml.ws SOAPClientSAAJ.java t@h ~/javatest> java --add-modules java.xml.ws SOAPClientSAAJ 

works. See also this video for the general background: https://www.youtube.com/watch?v=y8bpKYDrF5I&t=20m17s

Now the questions are:

  • Should the compiler automatically add the java.xml.ws module? (since he obviously knows that this is necessary) Is this a bug in javax.xml.soap?
  • Why is the -add-modules option not documented in my manual pages? (openjdk 9 on Debian)
  • What should be written in the .java file to automatically add the java.xml.ws module?
+5
source share
1 answer

This is the result of the new Java 9 modules . The javax.xml.soap package is actually a Java EE package , and now it is not visible. The current workaround is to either use --add-modules as you did, or modular code .

Modulating your code requires restructuring it into modules and including the module-info.java file, which defines the modules you use. In your case, specifying java.se.ee will give access to all EE modules.

+8
source

Source: https://habr.com/ru/post/1271578/


All Articles