Having trouble running the mflix application

I am currently having trouble running the mflix application even though I have correctly installed java (version 1.8.0_341) and maven (version 3.8.6). When I run the “mvn spring-boot:run” command I run into the below error:

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @1878ba11
    at java.lang.reflect.AccessibleObject.checkCanSetAccessible (AccessibleObject.java:354)
    at java.lang.reflect.AccessibleObject.checkCanSetAccessible (AccessibleObject.java:297)
    at java.lang.reflect.Method.checkCanSetAccessible (Method.java:200)
    at java.lang.reflect.Method.setAccessible (Method.java:194)
    at org.springframework.cglib.core.ReflectUtils$1.run (ReflectUtils.java:61)
    at java.security.AccessController.doPrivileged (AccessController.java:569)
    at org.springframework.cglib.core.ReflectUtils.<clinit> (ReflectUtils.java:52)
    at org.springframework.cglib.core.KeyFactory$Generator.generateClass (KeyFactory.java:243)
    at org.springframework.cglib.core.DefaultGeneratorStrategy.generate (DefaultGeneratorStrategy.java:25)
    at org.springframework.cglib.core.AbstractClassGenerator.generate (AbstractClassGenerator.java:329)
    at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply (AbstractClassGenerator.java:93)
    at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply (AbstractClassGenerator.java:91)
    at org.springframework.cglib.core.internal.LoadingCache$2.call (LoadingCache.java:54)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at org.springframework.cglib.core.internal.LoadingCache.createEntry (LoadingCache.java:61)
    at org.springframework.cglib.core.internal.LoadingCache.get (LoadingCache.java:34)
    at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get (AbstractClassGenerator.java:116)
    at org.springframework.cglib.core.AbstractClassGenerator.create (AbstractClassGenerator.java:291)
    at org.springframework.cglib.core.KeyFactory$Generator.create (KeyFactory.java:221)
    at org.springframework.cglib.core.KeyFactory.create (KeyFactory.java:174)
    at org.springframework.cglib.core.KeyFactory.create (KeyFactory.java:153)
    at org.springframework.cglib.proxy.Enhancer.<clinit> (Enhancer.java:73)
    at org.springframework.context.annotation.ConfigurationClassEnhancer.newEnhancer (ConfigurationClassEnhancer.java:122)
    at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance (ConfigurationClassEnhancer.java:110)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses (ConfigurationClassPostProcessor.java:403)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory (ConfigurationClassPostProcessor.java:254)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors (PostProcessorRegistrationDelegate.java:284)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors (PostProcessorRegistrationDelegate.java:128)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors (AbstractApplicationContext.java:694)
    at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:532)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
    at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:762)
    at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:398)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:330)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:1258)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:1246)
    at mflix.Application.main (Application.java:10)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
    at java.lang.reflect.Method.invoke (Method.java:577)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:496)
    at java.lang.Thread.run (Thread.java:833)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.269 s
[INFO] Finished at: 2022-08-04T17:40:32-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.3.RELEASE:run (default-cli) on project mflix: An exception occurred while running. null: InvocationTargetException: Cannot load configuration class: mflix.Application: ExceptionInInitializerError: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @1878ba11 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
1 Like

I had the same issue and solved it by adding --add-opens java.base/java.lang=ALL-UNNAMED to JVM run options

Or just run it using JDK 8

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.