title: Error creating extended parser class: Could not determine whether class has been loaded (Java 8.0_202)
body: <p>I'm trying to create a JPA in <strong>Ktor</strong> that can access MySQL and MongoDB using the same application. The MySQL part is working fine. But I'm unable to connect with MongoDB.
  log showing successful connection to MongoDB</p>
  <pre><code>2022-07-24 16:09:45.219 [main] INFO  o.h.o.d.m.i.MongoDBDatastoreProvider - OGM001207: Connecting to Mongo database named [alien].
  2022-07-24 16:09:45.247 [main] INFO  org.mongodb.driver.cluster - Cluster description not yet available. Waiting for 30000 ms before timing out
  2022-07-24 16:09:45.276 [cluster-ClusterId{value='62dd217111eba42ed4e057d1', description='null'}-localhost:27017] INFO  org.mongodb.driver.connection - Opened connection [connectionId{localValue:1, serverValue:35}] to localhost:27017
  2022-07-24 16:09:45.276 [cluster-ClusterId{value='62dd217111eba42ed4e057d1', description='null'}-localhost:27017] DEBUG org.mongodb.driver.cluster - Checking status of localhost:27017
  2022-07-24 16:09:45.303 [cluster-ClusterId{value='62dd217111eba42ed4e057d1', description='null'}-localhost:27017] DEBUG org.mongodb.driver.protocol.command - Sending command '{ &quot;ismaster&quot; : 1, &quot;$db&quot; : &quot;admin&quot; }' with request id 4 to database admin on connection [connectionId{localValue:1, serverValue:35}] to server localhost:27017
  2022-07-24 16:09:45.306 [cluster-ClusterId{value='62dd217111eba42ed4e057d1', description='null'}-localhost:27017] DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 4 completed successfully in 23.34 ms on connection [connectionId{localValue:1, serverValue:35}] to server localhost:27017
  2022-07-24 16:09:45.308 [cluster-ClusterId{value='62dd217111eba42ed4e057d1', description='null'}-localhost:27017] INFO  org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 23]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=30094600}
  2022-07-24 16:09:45.309 [cluster-ClusterId{value='62dd217111eba42ed4e057d1', description='null'}-localhost:27017] TRACE org.mongodb.driver.cluster - Handling description changed event for server localhost:27017 with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 23]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=30094600}
  2022-07-24 16:09:45.309 [cluster-ClusterId{value='62dd217111eba42ed4e057d1', description='null'}-localhost:27017] INFO  org.mongodb.driver.cluster - Discovered cluster type of STANDALONE
  2022-07-24 16:09:45.309 [cluster-ClusterId{value='62dd217111eba42ed4e057d1', description='null'}-localhost:27017] DEBUG org.mongodb.driver.cluster - Updating cluster description to  {type=STANDALONE, servers=[{address=localhost:27017, type=STANDALONE, roundTripTime=30.1 ms, state=CONNECTED}]
  2022-07-24 16:09:45.317 [main] TRACE org.mongodb.driver.connection - Checked out connection [connectionId{localValue:2}] to server localhost:27017
  2022-07-24 16:09:45.324 [main] INFO  org.mongodb.driver.connection - Opened connection [connectionId{localValue:2, serverValue:36}] to localhost:27017
  2022-07-24 16:09:45.333 [main] DEBUG org.mongodb.driver.protocol.command - Sending command '{ &quot;listDatabases&quot; : 1, &quot;nameOnly&quot; : true, &quot;$db&quot; : &quot;admin&quot; }' with request id 8 to database admin on connection [connectionId{localValue:2, serverValue:36}] to server localhost:27017
  2022-07-24 16:09:45.334 [main] DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 8 completed successfully in 1.38 ms on connection [connectionId{localValue:2, serverValue:36}] to server localhost:27017
  2022-07-24 16:09:45.338 [main] TRACE org.mongodb.driver.connection - Checked in connection [connectionId{localValue:2, serverValue:36}] to server localhost:27017
  </code></pre>
  <p>But after that, I'm getting the exception message as given below.</p>
  <p>***Exception ***</p>
  <pre><code>Exception in thread &quot;main&quot; java.lang.ExceptionInInitializerError
      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.ogm.dialect.impl.GridDialectInitiator$GridDialectInstantiator.newInstance(GridDialectInitiator.java:95)
      at org.hibernate.ogm.dialect.impl.GridDialectInitiator$GridDialectInstantiator.newInstance(GridDialectInitiator.java:66)
      at org.hibernate.ogm.util.configurationreader.impl.DefaultClassPropertyReaderContext.getDefaultValue(DefaultClassPropertyReaderContext.java:117)
      at org.hibernate.ogm.util.configurationreader.impl.DefaultClassPropertyReaderContext.getTypedValue(DefaultClassPropertyReaderContext.java:87)
      at org.hibernate.ogm.util.configurationreader.impl.PropertyReaderContextBase.getValue(PropertyReaderContextBase.java:98)
      at org.hibernate.ogm.util.configurationreader.impl.DefaultClassPropertyReaderContext.getValue(DefaultClassPropertyReaderContext.java:29)
      at org.hibernate.ogm.dialect.impl.GridDialectInitiator.initiateService(GridDialectInitiator.java:63)
      at org.hibernate.ogm.dialect.impl.GridDialectInitiator.initiateService(GridDialectInitiator.java:36)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:94)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
      at org.hibernate.ogm.dialect.eventstate.impl.EventStateLifecycles$OperationsQueueLifecycle.mustBeEnabled(EventStateLifecycles.java:94)
      at org.hibernate.ogm.dialect.eventstate.impl.EventStateLifecycles.getEnabledLifecycles(EventStateLifecycles.java:51)
      at org.hibernate.ogm.dialect.eventstate.impl.EventContextManager.injectServices(EventContextManager.java:51)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
      at org.hibernate.ogm.dialect.impl.GridDialectInitiator.initiateService(GridDialectInitiator.java:55)
      at org.hibernate.ogm.dialect.impl.GridDialectInitiator.initiateService(GridDialectInitiator.java:36)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:94)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
      at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator$OgmDialectFactory.&lt;init&gt;(OgmDialectFactoryInitiator.java:44)
      at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator.initiateService(OgmDialectFactoryInitiator.java:31)
      at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator.initiateService(OgmDialectFactoryInitiator.java:25)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:94)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
      at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:50)
      at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:94)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
      at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
      at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.&lt;init&gt;(InFlightMetadataCollectorImpl.java:179)
      at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:119)
      at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:904)
      at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935)
      at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)
      at org.hibernate.ogm.jpa.HibernateOgmPersistence.createEntityManagerFactory(HibernateOgmPersistence.java:57)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
      at com.example.routes.CustomRoutingKt$customRouting$1.invoke(CustomRouting.kt:15)
      at com.example.routes.CustomRoutingKt$customRouting$1.invoke(CustomRouting.kt:14)
      at io.ktor.server.routing.RoutingKt.routing(Routing.kt:147)
      at com.example.routes.CustomRoutingKt.customRouting(CustomRouting.kt:14)
      at com.example.ApplicationKt$main$1.invoke(Application.kt:14)
      at com.example.ApplicationKt$main$1.invoke(Application.kt:11)
      at io.ktor.server.engine.internal.CallableUtilsKt.executeModuleFunction(CallableUtils.kt:51)
      at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$launchModuleByName$1.invoke(ApplicationEngineEnvironmentReloading.kt:329)
      at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$launchModuleByName$1.invoke(ApplicationEngineEnvironmentReloading.kt:328)
      at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.avoidingDoubleStartupFor(ApplicationEngineEnvironmentReloading.kt:353)
      at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.launchModuleByName(ApplicationEngineEnvironmentReloading.kt:328)
      at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.access$launchModuleByName(ApplicationEngineEnvironmentReloading.kt:32)
      at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$instantiateAndConfigureApplication$1.invoke(ApplicationEngineEnvironmentReloading.kt:316)
      at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$instantiateAndConfigureApplication$1.invoke(ApplicationEngineEnvironmentReloading.kt:307)
      at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.avoidingDoubleStartup(ApplicationEngineEnvironmentReloading.kt:335)
      at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.instantiateAndConfigureApplication(ApplicationEngineEnvironmentReloading.kt:307)
      at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.createApplication(ApplicationEngineEnvironmentReloading.kt:144)
      at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.start(ApplicationEngineEnvironmentReloading.kt:274)
      at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:185)
      at com.example.ApplicationKt.main(Application.kt:15)
      at com.example.ApplicationKt.main(Application.kt)
  Caused by: java.lang.RuntimeException: Error creating extended parser class: Could not determine whether class 'org.hibernate.ogm.datastore.mongodb.query.parsing.nativequery.impl.NativeQueryParser$$parboiled' has already been loaded
      at org.parboiled.Parboiled.createParser(Parboiled.java:58)
      at org.hibernate.ogm.datastore.mongodb.MongoDBDialect.&lt;clinit&gt;(MongoDBDialect.java:218)
      ... 75 more
  Caused by: java.lang.RuntimeException: Could not determine whether class 'org.hibernate.ogm.datastore.mongodb.query.parsing.nativequery.impl.NativeQueryParser$$parboiled' has already been loaded
      at org.parboiled.transform.AsmUtils.findLoadedClass(AsmUtils.java:217)
      at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:35)
      at org.parboiled.Parboiled.createParser(Parboiled.java:54)
      ... 76 more
  Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) accessible: module java.base does not &quot;opens java.lang&quot; to unnamed module @5b202a3a
      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.Method.checkCanSetAccessible(Method.java:199)
      at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
      at org.parboiled.transform.AsmUtils.findLoadedClass(AsmUtils.java:210)
      ... 78 more
  
  </code></pre>
  <p>The class I'm using is a simple one.</p>
  <pre><code>package com.example.data
  
  import javax.persistence.*
  
  @Entity
  class Person(
      @Column(nullable = false)
      val name: String,
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      val id: Int?=null,
  )
  </code></pre>
  <p>I'm using hibernate OGM 5.4.1 with ORM 5.3.6. My MongoDb database version is 3.6 and MongoDB java driver used is 3.9. ( can be seen in build.gradle file). Earlier I was having issues with dependencies hence I configured accordingly as per the documentation. (using the minimum version mentioned).</p>
  <p><em><strong>build.gradle.kts</strong></em></p>
  <pre><code>
  val ktor_version: String by project
  val kotlin_version: String by project
  val logback_version: String by project
  
  plugins {
      application
      kotlin(&quot;jvm&quot;) version &quot;1.7.10&quot;
                  id(&quot;org.jetbrains.kotlin.plugin.serialization&quot;) version &quot;1.7.10&quot;
  }
  group = &quot;com.example&quot;
  version = &quot;0.0.1&quot;
  application {
      mainClass.set(&quot;com.example.ApplicationKt&quot;)
  
      val isDevelopment: Boolean = project.ext.has(&quot;development&quot;)
      applicationDefaultJvmArgs = listOf(&quot;-Dio.ktor.development=$isDevelopment&quot;)
  }
  repositories {
      mavenCentral()
  }
  dependencies {
      implementation(&quot;io.ktor:ktor-server-core-jvm:$ktor_version&quot;)
      implementation(&quot;io.ktor:ktor-server-locations-jvm:$ktor_version&quot;)
      implementation(&quot;io.ktor:ktor-server-content-negotiation-jvm:$ktor_version&quot;)
      implementation(&quot;io.ktor:ktor-serialization-jackson-jvm:$ktor_version&quot;)
      implementation(&quot;io.ktor:ktor-serialization-gson-jvm:$ktor_version&quot;)
      implementation(&quot;io.ktor:ktor-serialization-kotlinx-json-jvm:$ktor_version&quot;)
      implementation(&quot;io.ktor:ktor-server-netty-jvm:$ktor_version&quot;)
      implementation(&quot;ch.qos.logback:logback-classic:$logback_version&quot;)
      testImplementation(&quot;io.ktor:ktor-server-tests-jvm:$ktor_version&quot;)
      testImplementation(&quot;org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version&quot;)
      implementation(&quot;org.jetbrains.kotlin:kotlin-maven-plugin:1.2.30&quot;)
      implementation(&quot;org.jetbrains.kotlin:kotlin-maven-noarg:1.2.30&quot;)
      implementation(&quot;org.hibernate:hibernate-core:5.3.6.Final&quot;)
      implementation(&quot;org.jetbrains.exposed:exposed-dao:0.38.2&quot;)
      implementation(&quot;org.jetbrains.exposed:exposed-jdbc:0.38.2&quot;)
      implementation (&quot;org.mongodb:mongo-java-driver:3.9.1&quot;)
      implementation(&quot;org.hibernate.ogm:hibernate-ogm-mongodb:5.4.1.Final&quot;)
      implementation(&quot;javax.transaction:jta:1.1&quot;)
      implementation(&quot;javax.xml.bind:jaxb-api:2.4.0-b180830.0359&quot;)
      implementation(&quot;javax.persistence:javax.persistence-api:2.2&quot;)
  
     
  //  implementation(&quot;org.mongodb:mongo-java-driver:3.12.11&quot;)
  //    implementation(&quot;jakarta.persistence:jakarta.persistence-api:2.2.3&quot;)
  //    implementation(&quot;org.hibernate.ogm:hibernate-ogm-core:5.3.1.Final&quot;)
  //    implementation(&quot;org.hibernate:hibernate-entitymanager:5.4.1.Final&quot;)
  
  }
  </code></pre>
  <p><strong>persistence.xml</strong></p>
  <pre><code> 
  &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!--&lt;persistence version=&quot;3.0&quot;--&gt;
  &lt;!--             xmlns=&quot;https://jakarta.ee/xml/ns/persistence&quot;&gt;--&gt;&lt;!--        xsi:schemalocation=&quot;http://jakarta.ee/xml/ns/persistence http://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd&quot;&gt;--&gt;
  &lt;persistence xmlns=&quot;http://xmlns.jcp.org/xml/ns/persistence&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd&quot; version=&quot;2.2&quot;&gt;
  
  &lt;!--    &lt;persistence-unit name=&quot;mysql&quot;&gt;--&gt;
  &lt;!--        &lt;provider&gt;--&gt;
  &lt;!--            org.hibernate.jpa.HibernatePersistenceProvider--&gt;
  &lt;!--        &lt;/provider&gt;--&gt;
  &lt;!--        &lt;class&gt;com.example.data.Alien&lt;/class&gt;--&gt;
  &lt;!--        &lt;properties&gt;--&gt;
  &lt;!--            &lt;property name=&quot;jakarta.persistence.jdbc.driver&quot; value=&quot;com.mysql.cj.jdbc.Driver&quot;/&gt;--&gt;
  &lt;!--            &lt;property name=&quot;jakarta.persistence.jdbc.url&quot; value=&quot;jdbc:mysql://localhost:3306/students&quot;/&gt;--&gt;
  &lt;!--            &lt;property name=&quot;jakarta.persistence.jdbc.user&quot; value=&quot;root&quot;/&gt;--&gt;
  &lt;!--            &lt;property name=&quot;jakarta.persistence.jdbc.password&quot; value=&quot;rzzzootpass&quot;/&gt;--&gt;
  &lt;!--        &lt;/properties&gt;--&gt;
  &lt;!--    &lt;/persistence-unit&gt;--&gt;
      &lt;persistence-unit name=&quot;mdb&quot; transaction-type=&quot;JTA&quot;&gt;
          &lt;provider&gt;
              org.hibernate.ogm.jpa.HibernateOgmPersistence
          &lt;/provider&gt;
  
          &lt;class&gt;com.example.data.Person&lt;/class&gt;
  
          &lt;properties&gt;
              &lt;property name=&quot;hibernate.ogm.datastore.provider&quot; value=&quot;org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider&quot; /&gt;
              &lt;property name=&quot;hibernate.ogm.mongodb.host&quot; value=&quot;127.0.0.1&quot;/&gt;
              &lt;property name=&quot;hibernate.ogm.mongodb.port&quot; value=&quot;27017&quot;/&gt;
              &lt;property name=&quot;hibernate.ogm.datastore.create_database&quot; value=&quot;true&quot;/&gt;
  &lt;!--            &lt;property name=&quot;hibernate.ogm.mongodb.url&quot; value=&quot;mongodb+srv://root:rootpass@cluster0.9myqe.mongodb.net/test&quot;/&gt;--&gt;
              &lt;property name=&quot;hibernate.ogm.datastore.database&quot; value=&quot;alien&quot;/&gt;
  &lt;!--            &lt;property name=&quot;jboss.as.jpa.adapterModule&quot; value=&quot;org.jboss.as.jpa.hibernate:4&quot;/&gt;--&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  
  </code></pre>
  <p>I'm really stuck on this one. So any help is appreciated. If more information is needed do mention in the comments and I'll edit the post accordingly.</p>