Я пытаюсь обновить свой проект Hibernate Gradle до Java 10. Я получаю следующую ошибку:
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
Я внимательно прочитал этот ответ , и это мой файл build.gradle:
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"
}
Как видите, я добавил javax.xml.bind
в качестве зависимости, но похоже, что hibernate по-прежнему игнорирует ее. Но если я попытаюсь добавить аргументы jvm '--add-modules', 'java.xml.bind'
, я получу java.lang.module.ResolutionException: Modules activation and java.activation export package javax.activation to module org.jsoup
. Итак, как я могу решить эту проблему?
Редактировать: среда IDE (в моем случае eclipse) знает о классе com.sun.xml.bind.v2.ContextFactory (автозаполнение работает над этим классом).