title: javax.xml.bind.JAXBException Hibernate Java 10
body: <p>I am trying to update my Hibernate Gradle project to Java 10. I get the following error:</p>
  
  <pre><code>Caused by: org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 0 and column 0 in RESOURCE hibernate.cfg.xml. Message: null
          at org.hibernate.orm.core@5.3.6.Final/org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:133)
          at org.hibernate.orm.core@5.3.6.Final/org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:65)
          at org.hibernate.orm.core@5.3.6.Final/org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57)
          at org.hibernate.orm.core@5.3.6.Final/org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:165)
          at org.hibernate.orm.core@5.3.6.Final/org.hibernate.cfg.Configuration.configure(Configuration.java:258)
          at org.hibernate.orm.core@5.3.6.Final/org.hibernate.cfg.Configuration.configure(Configuration.java:244)
          at com.kiryltkach.bettingtools.betstore.utils.HibernateUtil.buildSessionFactory(HibernateUtil.java:14)
          ... 75 more
  Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
   - with linked exception:
  [java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]
          at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:278)
          at javax.xml.bind.ContextFinder.find(ContextFinder.java:409)
          at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721)
          at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662)
          at org.hibernate.orm.core@5.3.6.Final/org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:122)
          ... 81 more
  Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory
          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
          at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
          at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
          at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122)
          at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155)
          at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:276)
          ... 85 more
  </code></pre>
  
  <p>I carefully read <a href="https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j">this answer</a>, and this is my build.gradle file:</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'application'
  
  mainClassName = 'com.project.example.Main'
  
  repositories {
      // Use 'jcenter' for resolving your dependencies.
      // You can declare any Maven/Ivy/file repository here.
      jcenter()
  }
  
  buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath 'com.google.gradle:osdetector-gradle-plugin:1.6.0'
      }
  }
  
  apply plugin: 'com.google.osdetector'
  
  ext.platform = osdetector.os == 'osx' ? 'mac' : osdetector.os == 'windows' ? 'win' : osdetector.os
  
  compileJava {
      doFirst {
          options.compilerArgs = [
                  '--module-path', classpath.asPath,
                  '--add-modules', 'javafx.controls'
          ]
      }
  }
  
  run {
      doFirst {
          jvmArgs = [
                  '--module-path', classpath.asPath,
                  '--add-modules', 'javafx.controls',
                  //'--add-modules', 'java.xml.bind',                
                  //'--add-modules', 'java.se.ee',
                  '--add-exports', 'javafx.graphics/com.sun.javafx.util=ALL-UNNAMED',
                  '--add-exports', 'javafx.base/com.sun.javafx.reflect=ALL-UNNAMED', 
                  '--add-exports', 'javafx.base/com.sun.javafx.beans=ALL-UNNAMED'
                  //--add-exports=javafx.graphics/com.sun.glass.utils=ALL-UNNAMED 
                  //--add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
          ]
      }
  }
  
  dependencies {
      testCompile group: 'junit', name: 'junit', version: '4.12'    
      compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
      compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
      compile 'org.hibernate:hibernate-core:5.3.6.Final'
      compile group: 'postgresql', name: 'postgresql', version: '9.4.1208-jdbc42-atlassian-hosted'
      compile group: 'com.sun.mail', name: 'javax.mail', version: '1.6.1'
      compile group: 'org.jsoup', name: 'jsoup', version: '1.11.3'
      compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
      compile group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0.1'
      compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.1'
      compile group: 'javax.activation', name: 'activation', version: '1.1.1'
  
      compile "org.openjfx:javafx-base:11:$platform"
      compile "org.openjfx:javafx-graphics:11:$platform"
      compile "org.openjfx:javafx-controls:11:$platform"
      compile "org.openjfx:javafx-fxml:11:$platform"
      compile "org.openjfx:javafx-web:11:$platform"
  }
  </code></pre>
  
  <p>As you see, I've added <code>javax.xml.bind</code> as a dependency, but it seems that hibernate still ignores it. But if I try to add jvm arguments <code>'--add-modules', 'java.xml.bind'</code>, I get <code>java.lang.module.ResolutionException: Modules activation and java.activation export package javax.activation to module org.jsoup</code>. So, how can I solve this problem?</p>
  
  <p>Edit: the IDE (in my case eclipse) knows about the class com.sun.xml.bind.v2.ContextFactory (autocomplete is working on this class).</p>