Unable to make field public static volatile

Using hibernate-core 6.2.7.Final and jre11
I have this annotated class

@Entity
@Table(name="Departamento")
public class Departamento1 {
	private IntegerProperty id = new SimpleIntegerProperty();
	@Id
	@GeneratedValue(generator="increment")
	@GenericGenerator(name = "increment", type = IncrementGenerator.class)
	public int getId() {
		return id.get();
	}
	public void setId(int id) {
		this.id.set(id);
	}
	public IntegerProperty idProperty() {
		return id;
	}

}

and when running my application I’m recieving this error:

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:77)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:568)

at javafx.graphics@19.0.2.1/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:465)

at javafx.graphics@19.0.2.1/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:568)

at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1082)

Caused by: java.lang.RuntimeException: Exception in Application start method

at javafx.graphics@19.0.2.1/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)

at javafx.graphics@19.0.2.1/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)

at java.base/java.lang.Thread.run(Thread.java:833)

Caused by: org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.SingleTableEntityPersister

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:103)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:75)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.processBootEntities(MappingMetamodelImpl.java:247)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:185)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.internal.SessionFactoryImpl.initializeMappingModel(SessionFactoryImpl.java:320)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:270)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:431)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.boot.internal.MetadataImpl.buildSessionFactory(MetadataImpl.java:205)

at com.bachiller.calendario/com.bachiller.calendario.modules.CalendarioModule.<init>(CalendarioModule.java:74)

at com.bachiller.calendario/com.bachiller.calendario.App.start(App.java:29)

at javafx.graphics@19.0.2.1/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)

at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)

at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)

at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)

at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)

at javafx.graphics@19.0.2.1/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)

at javafx.graphics@19.0.2.1/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)

at javafx.graphics@19.0.2.1/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)

... 1 more

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field public static volatile java.util.concurrent.Callable com.bachiller.calendario.model.Departamento1$HibernateAccessOptimizer$gvsCpj7F.invocationTarget$k90u5u0 accessible: module com.bachiller.calendario does not "exports com.bachiller.calendario.model" to unnamed module @14a2f921

at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)

at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)

at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)

at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)

at net.bytebuddy.utility.privilege.SetAccessibleAction.run(SetAccessibleAction.java:49)

at net.bytebuddy.utility.privilege.SetAccessibleAction.run(SetAccessibleAction.java:28)

at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)

at net.bytebuddy.implementation.LoadedTypeInitializer$ForStaticField.doPrivileged(LoadedTypeInitializer.java)

at net.bytebuddy.implementation.LoadedTypeInitializer$ForStaticField.onLoad(LoadedTypeInitializer.java:168)

at net.bytebuddy.implementation.LoadedTypeInitializer$Compound.onLoad(LoadedTypeInitializer.java:234)

at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:103)

at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6317)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.load(ByteBuddyState.java:146)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl.getReflectionOptimizer(BytecodeProviderImpl.java:242)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.metamodel.internal.EntityRepresentationStrategyPojoStandard.resolveReflectionOptimizer(EntityRepresentationStrategyPojoStandard.java:293)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.metamodel.internal.EntityRepresentationStrategyPojoStandard.<init>(EntityRepresentationStrategyPojoStandard.java:161)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.metamodel.internal.ManagedTypeRepresentationResolverStandard.resolveStrategy(ManagedTypeRepresentationResolverStandard.java:62)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:509)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:140)

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)

at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)

at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)

at org.hibernate.orm.core@6.2.7.Final/org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:92)

... 18 more

Exception running application com.bachiller.calendario.App

Any idea why is it happening and how to solve it?
Thank you

Apparently you are running an application with Java modules, but you are not exporting the packages that contain your entities to Hibernate ORM (org.hibernate.orm.core) and byte buddy (net.bytebuddy).
Maybe it’s easiest though to just mark your module as open.

Thank you.
I was opening my module to org.hibernate.orm.core but not to net.bytebuddy. I tried to add it but it is giving me the same exception.
I solved it by adding -add-opens to ALL-UNNAMED in VM arguments.
I’m new to modules and they are giving me some headaches. I don’t now if it is the correct solution but it works…

No idea how you are starting your application, but in order for automatic-modules to work, I believe you must put them on the module path. I know Maven and Gradle both have problems to figure out whether to put JARs on one path or the other, so I guess you might see some more problems like that along the way. Usually, once you figure out what is going on, you should be able to fix these issue :slight_smile: