IntelliJ issues with javax.xml.ws.spi.Provider
I have a SOAP application that works fine with Java 8 because it uses the in-built J2EE libraries ( JAX-WS and JAXB )
When I switch to JDK 11, these libraries are external. The following error then occurs
java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl
The provider is hard-wired in javax.xml.ws.api.Provider
private static final String DEFAULT_JAXWSPROVIDER ="com.sun"+".xml.internal.ws.spi.ProviderImpl";
However, this should be overridden by META-INF/services/javax.xml.ws.spi.Provider which contains the correct provider information "com.sun.xml.ws.spi.ProviderImpl"
The code works as expected when run from Eclipse IDE 2019-03 but it fails with the above error on IDEA 2019.1.2
There must be some difference in the class loader order that I am not able to find. Any suggestions would be appreciated
请先登录再写评论。
For loading classes in classpath IDE uses order, specified in a module's dependencies tab.
Possibly related: https://youtrack.jetbrains.com/issue/IDEA-171320. Try adding --add-exports=module/package=ALL-UNNAMED VM options for the run configuration you use to run the app. A sample project would help to understand your setup and possible problem more clear: if you use module-info, Maven, what Run/Debug Configuration is used to run.
Check also https://stackoverflow.com/a/52664241/2000323
JAXB and JAX-WS have many dependencies and the code that accesses them comes from Oracle Web Services libraries. Because the same code works with Eclipse, I was hoping to find some obvious difference in the way that IDEA treats modules. I built the IDEA project from the pom.xml that works with Eclipse and I use the same module-info.java file. I have tried to add "--add-exports=com.sun.xml.ws/com.sun.xml.ws=ALL-UNNAMED but there is no difference. Perhaps it is easier to continue using Eclipse but I like prefer IDEA. This is clearly a run-time problem but I am not sure how to debug the class loading.
A test project would be very helpful to investigate the problem (for uploading you can use ftp://ftp.intellij.net/.uploads / https://uploads.services.jetbrains.com - access to servers is closed from outside).
Unfortunately, testing this code requires access to a Web Services provider which is not publicly available. Building a test project would require considerable effort and it would be uncertain about how similar it would be to the application that I have been using. I don't believe that a useful test project could be constructed.
"C:\Program Files\Java\jdk-11.0.3\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:59001,suspend=y,server=n --add-modules javafx.base,javafx.graphics --add-reads javafx.base=ALL-UNNAMED --add-reads javafx.graphics=ALL-UNNAMED -javaagent:C:\Users\dalbert\.IntelliJIdea2019.1\system\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "D:\Program Files\JetBrains\IntelliJ IDEA 2018.3.4\lib\idea_rt.jar" -p C:\Users\dalbert\.m2\repository\org\openjfx\javafx-base\11.0.2\javafx-base-11.0.2-win.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-graphics\11.0.2\javafx-graphics-11.0.2-win.jar;D:\Data\Java\IdeaProjects\gust\target\classes;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-controls\11.0.2\javafx-controls-11.0.2.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-controls\11.0.2\javafx-controls-11.0.2-win.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-graphics\11.0.2\javafx-graphics-11.0.2.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-base\11.0.2\javafx-base-11.0.2.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-fxml\11.0.2\javafx-fxml-11.0.2.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-fxml\11.0.2\javafx-fxml-11.0.2-win.jar;C:\Users\dalbert\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.4.0-b180830.0438\jaxb-runtime-2.4.0-b180830.0438.jar;C:\Users\dalbert\.m2\repository\javax\xml\bind\jaxb-api\2.4.0-b180830.0359\jaxb-api-2.4.0-b180830.0359.jar;C:\Users\dalbert\.m2\repository\org\glassfish\jaxb\txw2\2.4.0-b180830.0438\txw2-2.4.0-b180830.0438.jar;C:\Users\dalbert\.m2\repository\com\sun\istack\istack-commons-runtime\3.0.7\istack-commons-runtime-3.0.7.jar;C:\Users\dalbert\.m2\repository\org\jvnet\staxex\stax-ex\1.8\stax-ex-1.8.jar;C:\Users\dalbert\.m2\repository\com\sun\xml\fastinfoset\FastInfoset\1.2.15\FastInfoset-1.2.15.jar;C:\Users\dalbert\.m2\repository\com\sun\xml\ws\rt\2.3.1\rt-2.3.1.jar;C:\Users\dalbert\.m2\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;C:\Users\dalbert\.m2\repository\com\sun\xml\ws\policy\2.7.5\policy-2.7.5.jar;C:\Users\dalbert\.m2\repository\com\sun\activation\javax.activation\1.2.0\javax.activation-1.2.0.jar;C:\Users\dalbert\.m2\repository\org\glassfish\gmbal\gmbal-api-only\3.1.0-b001\gmbal-api-only-3.1.0-b001.jar;C:\Users\dalbert\.m2\repository\org\glassfish\external\management-api\3.0.0-b012\management-api-3.0.0-b012.jar;C:\Users\dalbert\.m2\repository\com\sun\xml\stream\buffer\streambuffer\1.5.6\streambuffer-1.5.6.jar;C:\Users\dalbert\.m2\repository\org\jvnet\mimepull\mimepull\1.9.10\mimepull-1.9.10.jar;C:\Users\dalbert\.m2\repository\com\fasterxml\woodstox\woodstox-core\5.1.0\woodstox-core-5.1.0.jar;C:\Users\dalbert\.m2\repository\org\codehaus\woodstox\stax2-api\4.1\stax2-api-4.1.jar;C:\Users\dalbert\.m2\repository\org\glassfish\ha\ha-api\3.1.9\ha-api-3.1.9.jar;C:\Users\dalbert\.m2\repository\com\sun\xml\messaging\saaj\saaj-impl\1.5.0\saaj-impl-1.5.0.jar;C:\Users\dalbert\.m2\repository\javax\xml\ws\jaxws-api\2.3.1\jaxws-api-2.3.1.jar;C:\Users\dalbert\.m2\repository\javax\xml\soap\javax.xml.soap-api\1.4.0\javax.xml.soap-api-1.4.0.jar;C:\Users\dalbert\.m2\repository\javax\jws\javax.jws-api\1.1\javax.jws-api-1.1.jar;C:\Users\dalbert\.m2\repository\org\apache\commons\commons-lang3\3.9\commons-lang3-3.9.jar;C:\Users\dalbert\.m2\repository\commons-beanutils\commons-beanutils\1.9.3\commons-beanutils-1.9.3.jar;C:\Users\dalbert\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\dalbert\.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;C:\Users\dalbert\.m2\repository\com\google\appengine\appengine-api-1.0-sdk\1.9.74\appengine-api-1.0-sdk-1.9.74.jar;C:\Users\dalbert\.m2\repository\org\antlr\ST4\4.1\ST4-4.1.jar;C:\Users\dalbert\.m2\repository\org\antlr\antlr-runtime\3.5.2\antlr-runtime-3.5.2.jar -m com.db/com.db.GustMain
Connected to the target VM, address: '127.0.0.1:59001', transport: 'socket'
Exception in Application start method
java.lang.reflect.InvocationTargetException
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 javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
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 java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javafx.fxml.LoadException:
/D:/Data/Java/IdeaProjects/gust/target/classes/com/db/base.fxml
at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2625)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2595)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2466)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3237)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
at com.db/com.db.GustMain.start(GustMain.java:15)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run$$$capture(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
Caused by: java.lang.reflect.InvocationTargetException
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 com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:76)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javafx.base/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:273)
at javafx.fxml/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:83)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2591)
... 18 more
Caused by: javax.xml.ws.WebServiceException: Error while searching for service [javax.xml.ws.spi.Provider]
at java.xml.ws/javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:61)
at java.xml.ws/javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:58)
at java.xml.ws/javax.xml.ws.spi.ServiceLoaderUtil.firstByServiceLoader(ServiceLoaderUtil.java:70)
at java.xml.ws/javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:89)
at java.xml.ws/javax.xml.ws.spi.Provider.provider(Provider.java:96)
at java.xml.ws/javax.xml.ws.Service.<init>(Service.java:112)
at com.db/com.agile.ws.service.collaboration.v1.jaxws.CollaborationService.<init>(CollaborationService.java:50)
at com.db/com.db.Base.agileLogin(Base.java:123)
at com.db/com.db.Base.initialize(Base.java:48)
... 29 more
Caused by: java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider com.sun.xml.ws.spi.ProviderImpl not found
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:588)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1211)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1220)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1264)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1299)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1384)
at java.xml.ws/javax.xml.ws.spi.ServiceLoaderUtil.firstByServiceLoader(ServiceLoaderUtil.java:63)
... 35 more
Exception running application com.db.GustMain
Disconnected from the target VM, address: '127.0.0.1:59001', transport: 'socket'
Process finished with exit code 1
The code runs without error if I use the same "Run Configuration" that Eclipse uses
"C:\Program Files\Java\jdk-11.0.3\bin\java.exe" -p "D:\Data\Java\IdeaProjects\gust\target\classes;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-controls\11.0.2\javafx-controls-11.0.2-win.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-graphics\11.0.2\javafx-graphics-11.0.2-win.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-base\11.0.2\javafx-base-11.0.2-win.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-fxml\11.0.2\javafx-fxml-11.0.2-win.jar;C:\Users\dalbert\.m2\repository\javax\xml\bind\jaxb-api\2.4.0-b180830.0359\jaxb-api-2.4.0-b180830.0359.jar;C:\Users\dalbert\.m2\repository\javax\activation\javax.activation-api\1.2.0\javax.activation-api-1.2.0.jar;C:\Users\dalbert\.m2\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;C:\Users\dalbert\.m2\repository\com\sun\activation\javax.activation\1.2.0\javax.activation-1.2.0.jar;C:\Users\dalbert\.m2\repository\javax\xml\ws\jaxws-api\2.3.1\jaxws-api-2.3.1.jar;C:\Users\dalbert\.m2\repository\javax\xml\soap\javax.xml.soap-api\1.4.0\javax.xml.soap-api-1.4.0.jar;C:\Users\dalbert\.m2\repository\javax\jws\javax.jws-api\1.1\javax.jws-api-1.1.jar;C:\Users\dalbert\.m2\repository\org\apache\commons\commons-lang3\3.9\commons-lang3-3.9.jar;C:\Users\dalbert\.m2\repository\commons-beanutils\commons-beanutils\1.9.3\commons-beanutils-1.9.3.jar;C:\Users\dalbert\.m2\repository\com\google\appengine\appengine-api-1.0-sdk\1.9.74\appengine-api-1.0-sdk-1.9.74.jar;C:\Users\dalbert\.m2\repository\org\antlr\ST4\4.1\ST4-4.1.jar" -classpath "C:\Users\dalbert\.m2\repository\org\openjfx\javafx-controls\11.0.2\javafx-controls-11.0.2.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-graphics\11.0.2\javafx-graphics-11.0.2.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-base\11.0.2\javafx-base-11.0.2.jar;C:\Users\dalbert\.m2\repository\org\openjfx\javafx-fxml\11.0.2\javafx-fxml-11.0.2.jar;C:\Users\dalbert\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.4.0-b180830.0438\jaxb-runtime-2.4.0-b180830.0438.jar;C:\Users\dalbert\.m2\repository\org\glassfish\jaxb\txw2\2.4.0-b180830.0438\txw2-2.4.0-b180830.0438.jar;C:\Users\dalbert\.m2\repository\com\sun\istack\istack-commons-runtime\3.0.7\istack-commons-runtime-3.0.7.jar;C:\Users\dalbert\.m2\repository\org\jvnet\staxex\stax-ex\1.8\stax-ex-1.8.jar;C:\Users\dalbert\.m2\repository\com\sun\xml\fastinfoset\FastInfoset\1.2.15\FastInfoset-1.2.15.jar;C:\Users\dalbert\.m2\repository\com\sun\xml\ws\rt\2.3.1\rt-2.3.1.jar;C:\Users\dalbert\.m2\repository\com\sun\xml\ws\policy\2.7.5\policy-2.7.5.jar;C:\Users\dalbert\.m2\repository\org\glassfish\gmbal\gmbal-api-only\3.1.0-b001\gmbal-api-only-3.1.0-b001.jar;C:\Users\dalbert\.m2\repository\org\glassfish\external\management-api\3.0.0-b012\management-api-3.0.0-b012.jar;C:\Users\dalbert\.m2\repository\com\sun\xml\stream\buffer\streambuffer\1.5.6\streambuffer-1.5.6.jar;C:\Users\dalbert\.m2\repository\org\jvnet\mimepull\mimepull\1.9.10\mimepull-1.9.10.jar;C:\Users\dalbert\.m2\repository\com\fasterxml\woodstox\woodstox-core\5.1.0\woodstox-core-5.1.0.jar;C:\Users\dalbert\.m2\repository\org\codehaus\woodstox\stax2-api\4.1\stax2-api-4.1.jar;C:\Users\dalbert\.m2\repository\org\glassfish\ha\ha-api\3.1.9\ha-api-3.1.9.jar;C:\Users\dalbert\.m2\repository\com\sun\xml\messaging\saaj\saaj-impl\1.5.0\saaj-impl-1.5.0.jar;C:\Users\dalbert\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\dalbert\.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;C:\Users\dalbert\.m2\repository\org\antlr\antlr-runtime\3.5.2\antlr-runtime-3.5.2.jar" -m com.db/com.db.GustMain
This suggests that the configuration that IDEA creates is not correct. It is missing the "target\classes" in the module path
How can I change this ?
No, `target\classes` is there - between `javafx-graphics-11.0.2-win.jar` and `javafx-controls-11.0.2.jar`. The biggest difference is that IDEA places all dependencies on the module path, while Eclipse splits them between class- and module paths.
In module path mode, the service loader uses `provides ... with ...` statements instead of `META-INF/...` files, so you need a JAX-WS runtime with a correct "module-info" file - like "com.sun.xml.ws:jaxws-rt:2.3.2".
Thank you so much for this advice, Roman. I have been trying to solve this for a long time and was not able to find the right run-time package. Now the project runs perfectly, both with Maven and the IDEA build
I need to learn more about the service loader and modules.
When I tried to create a JAR file for deployment, this error occurred
java.lang.ClassNotFoundException: com.sun.org.apache.xml.internal.resolver.CatalogManager
I was able to fix this by adding com.sun.org.apache.xml.internal:resolver:20050927
This move to JDK 11 and OpenJFX has been a difficult process but also good education. Is there a place at jetbrains where I could post advice for others ?
Glad it helped.
This forum is the right place, other users are able to find this thread.