java.lang.IllegalStateException:无法加载缓存项

时间:2019-05-31 08:02:59

标签: jpa guice java-11 jigsaw guice-persist

当我向项目中添加Java模块化时,上面的异常是从单元测试抛出的。我找不到解决此异常的方法。

我已添加到MAVEN_OPTS

--add-opens java.base/java.lang=ALL-UNNAMED

与surefire插件的配置相同(无济于事),因为以下是堆栈跟踪的一部分:

throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to module com.google.guice

我的项目是一个具有两个模块的Maven多项目:

module org.veary.debs.api {
    exports org.veary.debs.api;
    exports org.veary.debs.api.model;
    exports org.veary.debs.api.dao;
}

module org.veary.debs.db {
    exports org.veary.debs.db;

    requires com.google.guice;
    requires com.google.guice.extensions.persist;
    requires java.persistence;
    requires javax.inject;
    requires org.veary.debs.api;
}

这是stacktrace的第一部分的代码段。任何帮助将不胜感激。

信息:捕获并报告了异常。消息:java.lang.reflect.InaccessibleObjectException:无法使受保护的最终java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,by te [],int,int,java.security.ProtectionDomain)抛出java.lang.ClassFormatError可访问:模块java.base不会将com.google.guice模块“打开java.lang” java.lang.IllegalStateException:无法加载缓存项         com.google.guice@4.2.2/com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry(LoadingCache.java:79)         com.google.guice@4.2.2/com.google.inject.internal.cglib.core.internal.$LoadingCache.get(LoadingCache.java:34)         com.google.guice@4.2.2/com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)         com.google.guice@4.2.2/com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:291)         com.google.guice@4.2.2/com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:65)         com.google.guice@4.2.2/com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:258)         com.google.guice@4.2.2/com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:207)         com.google.guice@4.2.2/com.google.inject.internal.ProviderMethod.create(ProviderMethod.java:69)         com.google.guice@4.2.2/com.google.inject.internal.ProviderMethodsModule.createProviderMethod(ProviderMethodsModule.java:272)         com.google.guice@4.2.2/com.google.inject.internal.ProviderMethodsModule.getProviderMethods(ProviderMethodsModule.java:116)         com.google.guice@4.2.2/com.google.inject.internal.ProviderMethodsModule.configure(ProviderMethodsModule.java:100)         com.google.guice@4.2.2/com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:344)         com.google.guice@4.2.2/com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:353)         com.google.guice@4.2.2/com.google.inject.spi.Elements.getElements(Elements.java:103)         com.google.guice@4.2.2/com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:137)         com.google.guice@4.2.2/com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)         com.google.guice@4.2.2/com.google.inject.Guice.createInjector(Guice.java:87)         com.google.guice@4.2.2/com.google.inject.Guice.createInjector(Guice.java:69)         com.google.guice@4.2.2/com.google.inject.Guice.createInjector(Guice.java:59)         在org.veary.debs.db / org.veary.debs.tests.PersistenceTest.testAccountDao(PersistenceTest.java:43)         在java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(本机方法)         在java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)         在java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         在java.base / java.lang.reflect.Method.invoke(Method.java:566)

0 个答案:

没有答案