0

I have the same error as described on this Google Discussion, ie. the push subscriptions of the google cloud emulator for the pubsub service aren't working and raise a:

java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter

The solution proposed in this thread is to use the --add-modules flag:

java ... --add-modules ...

but this is no longer possible in Java11.

So I followed up to see how to replace this --add-modules flag, but now I have to edit a pom.xml file and use maven to add the new dependencies. I looked up some maven plugin commands like mvn exec:java, because I am not sure how to rebuild the project and would just like to run my:

java -jar cloud-pubsub-emulator-0.1-SNAPSHOT-all.jar ...

by adding the necessary dependencies that would substitute the --add-modules flag.

PS: I tried to downgrade to Java version < 11 and re-install the pubsub emulator, but another error was raised, so I decided to stick with Java's latest version.

Jorn Vernee
  • 26,917
  • 3
  • 67
  • 80
eddiemalou
  • 103
  • 1
  • 7
  • Right, --add-modules has not been removed. Instead, the question is about the java.xml.bind module which was deprecated-for-removal in Java SE 9 and eventually removed in Java SE 11. JEP 320 has all the details. The standalone version of JAXB is published in Maven so shouldn't be too hard to migrate and it shouldn't require any changes to java code. – Alan Bateman Jan 01 '19 at 08:19
  • Thanks so much, I have finally worked it out using the .jar files as specified in [this answer](https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j#answer-48404582) and using `java -cp` as detailed [here](https://stackoverflow.com/questions/219585/including-all-the-jars-in-a-directory-within-the-java-classpath#answer-219801), so as not having to go through the pom.xml and mvn. – eddiemalou Jan 01 '19 at 21:28

0 Answers0