java.lang.ExceptionInInitializerError with gradle












6















I've updated java from 8 to 9-ea and gradle from 2.13 to 3.4.1. Below is the gradle --version output.



------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------

Build time: 2017-03-03 19:45:41 UTC
Revision: 9eb76efdd3d034dc506c719dac2955efb5ff9a93

Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 9-ea (Oracle Corporation 9-ea+158)
OS: Linux 4.8.0-36-generic amd64


while compiling below error is encountered:



FAILURE: Build failed with an exception.

* What went wrong:
java.lang.ExceptionInInitializerError (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


and the output of gradle --stacktrace is below:



java.lang.ExceptionInInitializerError
at org.gradle.initialization.DefaultClassLoaderRegistry.restrictTo(DefaultClassLoaderRegistry.java:40)
at org.gradle.initialization.DefaultClassLoaderRegistry.restrictToGradleApi(DefaultClassLoaderRegistry.java:36)
at org.gradle.initialization.DefaultClassLoaderRegistry.<init>(DefaultClassLoaderRegistry.java:30)
at org.gradle.internal.service.scopes.GlobalScopeServices.createClassLoaderRegistry(GlobalScopeServices.java:213)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:547)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.internal.service.DefaultServiceRegistry.invoke(DefaultServiceRegistry.java:462)
at org.gradle.internal.service.DefaultServiceRegistry.access$1200(DefaultServiceRegistry.java:84)
at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:805)
at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:761)
at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:598)
at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:643)
at org.gradle.internal.service.DefaultServiceRegistry.applyConfigureMethod(DefaultServiceRegistry.java:253)
at org.gradle.internal.service.DefaultServiceRegistry.findProviderMethods(DefaultServiceRegistry.java:214)
at org.gradle.internal.service.DefaultServiceRegistry.addProvider(DefaultServiceRegistry.java:352)
at org.gradle.internal.service.ServiceRegistryBuilder.build(ServiceRegistryBuilder.java:52)
at org.gradle.launcher.cli.BuildActionsFactory.createGlobalClientServices(BuildActionsFactory.java:148)
at org.gradle.launcher.cli.BuildActionsFactory.runBuildWithDaemon(BuildActionsFactory.java:108)
at org.gradle.launcher.cli.BuildActionsFactory.createAction(BuildActionsFactory.java:83)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.createAction(CommandLineActionFactory.java:249)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:239)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:217)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:547)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected java.lang.Package java.lang.ClassLoader.getPackages() accessible: module java.base does not "opens java.lang" to unnamed module @6c7a164b
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:335)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:278)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:196)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:190)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:42)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:32)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:36)
at org.gradle.internal.reflect.JavaReflectionUtil.method(JavaReflectionUtil.java:223)
at org.gradle.internal.classloader.FilteringClassLoader.<clinit>(FilteringClassLoader.java:49)
... 40 more


when I set



export GRADLE_OPTS="-Dorg.gradle.jvmargs=--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED"


as suggested at different places, issue remains the same.



Kindly help me out in resolving the issue.



UPDATE:
Changed GRADLE_OPTS to



export GRADLE_OPTS="-Dorg.gradle.jvmargs=--add-opens java.lang=ALL-UNNAMED --add-opens java.util=ALL-UNNAMED --add-opens java.io=ALL-UNNAMED"


Got the following error:



Error: Could not find or load main class java.lang=ALL-UNNAMED
Caused by: java.lang.ClassNotFoundException: java.lang=ALL-UNNAMED









share|improve this question

























  • The --add-opens syntax seems to be slightly off: Unless things changed, there should be no = after --add-opens - see here.

    – Nicolai
    Mar 17 '17 at 8:55






  • 1





    I think Groovy 2.x doesn't work yet with JDK9. This being said, you can't run Gradle with JDK9 but you can use it to compile code targeting JDK9, that is Gradle must run with JDK8 or JDK7, compiler options in the buld file can be set to JDK9

    – aalmiray
    Mar 17 '17 at 9:01











  • @Nicolai After removing '=' I got the above mentioned error.

    – Obi Wan - PallavJha
    Mar 17 '17 at 9:21
















6















I've updated java from 8 to 9-ea and gradle from 2.13 to 3.4.1. Below is the gradle --version output.



------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------

Build time: 2017-03-03 19:45:41 UTC
Revision: 9eb76efdd3d034dc506c719dac2955efb5ff9a93

Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 9-ea (Oracle Corporation 9-ea+158)
OS: Linux 4.8.0-36-generic amd64


while compiling below error is encountered:



FAILURE: Build failed with an exception.

* What went wrong:
java.lang.ExceptionInInitializerError (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


and the output of gradle --stacktrace is below:



java.lang.ExceptionInInitializerError
at org.gradle.initialization.DefaultClassLoaderRegistry.restrictTo(DefaultClassLoaderRegistry.java:40)
at org.gradle.initialization.DefaultClassLoaderRegistry.restrictToGradleApi(DefaultClassLoaderRegistry.java:36)
at org.gradle.initialization.DefaultClassLoaderRegistry.<init>(DefaultClassLoaderRegistry.java:30)
at org.gradle.internal.service.scopes.GlobalScopeServices.createClassLoaderRegistry(GlobalScopeServices.java:213)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:547)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.internal.service.DefaultServiceRegistry.invoke(DefaultServiceRegistry.java:462)
at org.gradle.internal.service.DefaultServiceRegistry.access$1200(DefaultServiceRegistry.java:84)
at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:805)
at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:761)
at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:598)
at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:643)
at org.gradle.internal.service.DefaultServiceRegistry.applyConfigureMethod(DefaultServiceRegistry.java:253)
at org.gradle.internal.service.DefaultServiceRegistry.findProviderMethods(DefaultServiceRegistry.java:214)
at org.gradle.internal.service.DefaultServiceRegistry.addProvider(DefaultServiceRegistry.java:352)
at org.gradle.internal.service.ServiceRegistryBuilder.build(ServiceRegistryBuilder.java:52)
at org.gradle.launcher.cli.BuildActionsFactory.createGlobalClientServices(BuildActionsFactory.java:148)
at org.gradle.launcher.cli.BuildActionsFactory.runBuildWithDaemon(BuildActionsFactory.java:108)
at org.gradle.launcher.cli.BuildActionsFactory.createAction(BuildActionsFactory.java:83)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.createAction(CommandLineActionFactory.java:249)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:239)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:217)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:547)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected java.lang.Package java.lang.ClassLoader.getPackages() accessible: module java.base does not "opens java.lang" to unnamed module @6c7a164b
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:335)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:278)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:196)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:190)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:42)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:32)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:36)
at org.gradle.internal.reflect.JavaReflectionUtil.method(JavaReflectionUtil.java:223)
at org.gradle.internal.classloader.FilteringClassLoader.<clinit>(FilteringClassLoader.java:49)
... 40 more


when I set



export GRADLE_OPTS="-Dorg.gradle.jvmargs=--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED"


as suggested at different places, issue remains the same.



Kindly help me out in resolving the issue.



UPDATE:
Changed GRADLE_OPTS to



export GRADLE_OPTS="-Dorg.gradle.jvmargs=--add-opens java.lang=ALL-UNNAMED --add-opens java.util=ALL-UNNAMED --add-opens java.io=ALL-UNNAMED"


Got the following error:



Error: Could not find or load main class java.lang=ALL-UNNAMED
Caused by: java.lang.ClassNotFoundException: java.lang=ALL-UNNAMED









share|improve this question

























  • The --add-opens syntax seems to be slightly off: Unless things changed, there should be no = after --add-opens - see here.

    – Nicolai
    Mar 17 '17 at 8:55






  • 1





    I think Groovy 2.x doesn't work yet with JDK9. This being said, you can't run Gradle with JDK9 but you can use it to compile code targeting JDK9, that is Gradle must run with JDK8 or JDK7, compiler options in the buld file can be set to JDK9

    – aalmiray
    Mar 17 '17 at 9:01











  • @Nicolai After removing '=' I got the above mentioned error.

    – Obi Wan - PallavJha
    Mar 17 '17 at 9:21














6












6








6








I've updated java from 8 to 9-ea and gradle from 2.13 to 3.4.1. Below is the gradle --version output.



------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------

Build time: 2017-03-03 19:45:41 UTC
Revision: 9eb76efdd3d034dc506c719dac2955efb5ff9a93

Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 9-ea (Oracle Corporation 9-ea+158)
OS: Linux 4.8.0-36-generic amd64


while compiling below error is encountered:



FAILURE: Build failed with an exception.

* What went wrong:
java.lang.ExceptionInInitializerError (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


and the output of gradle --stacktrace is below:



java.lang.ExceptionInInitializerError
at org.gradle.initialization.DefaultClassLoaderRegistry.restrictTo(DefaultClassLoaderRegistry.java:40)
at org.gradle.initialization.DefaultClassLoaderRegistry.restrictToGradleApi(DefaultClassLoaderRegistry.java:36)
at org.gradle.initialization.DefaultClassLoaderRegistry.<init>(DefaultClassLoaderRegistry.java:30)
at org.gradle.internal.service.scopes.GlobalScopeServices.createClassLoaderRegistry(GlobalScopeServices.java:213)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:547)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.internal.service.DefaultServiceRegistry.invoke(DefaultServiceRegistry.java:462)
at org.gradle.internal.service.DefaultServiceRegistry.access$1200(DefaultServiceRegistry.java:84)
at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:805)
at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:761)
at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:598)
at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:643)
at org.gradle.internal.service.DefaultServiceRegistry.applyConfigureMethod(DefaultServiceRegistry.java:253)
at org.gradle.internal.service.DefaultServiceRegistry.findProviderMethods(DefaultServiceRegistry.java:214)
at org.gradle.internal.service.DefaultServiceRegistry.addProvider(DefaultServiceRegistry.java:352)
at org.gradle.internal.service.ServiceRegistryBuilder.build(ServiceRegistryBuilder.java:52)
at org.gradle.launcher.cli.BuildActionsFactory.createGlobalClientServices(BuildActionsFactory.java:148)
at org.gradle.launcher.cli.BuildActionsFactory.runBuildWithDaemon(BuildActionsFactory.java:108)
at org.gradle.launcher.cli.BuildActionsFactory.createAction(BuildActionsFactory.java:83)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.createAction(CommandLineActionFactory.java:249)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:239)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:217)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:547)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected java.lang.Package java.lang.ClassLoader.getPackages() accessible: module java.base does not "opens java.lang" to unnamed module @6c7a164b
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:335)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:278)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:196)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:190)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:42)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:32)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:36)
at org.gradle.internal.reflect.JavaReflectionUtil.method(JavaReflectionUtil.java:223)
at org.gradle.internal.classloader.FilteringClassLoader.<clinit>(FilteringClassLoader.java:49)
... 40 more


when I set



export GRADLE_OPTS="-Dorg.gradle.jvmargs=--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED"


as suggested at different places, issue remains the same.



Kindly help me out in resolving the issue.



UPDATE:
Changed GRADLE_OPTS to



export GRADLE_OPTS="-Dorg.gradle.jvmargs=--add-opens java.lang=ALL-UNNAMED --add-opens java.util=ALL-UNNAMED --add-opens java.io=ALL-UNNAMED"


Got the following error:



Error: Could not find or load main class java.lang=ALL-UNNAMED
Caused by: java.lang.ClassNotFoundException: java.lang=ALL-UNNAMED









share|improve this question
















I've updated java from 8 to 9-ea and gradle from 2.13 to 3.4.1. Below is the gradle --version output.



------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------

Build time: 2017-03-03 19:45:41 UTC
Revision: 9eb76efdd3d034dc506c719dac2955efb5ff9a93

Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 9-ea (Oracle Corporation 9-ea+158)
OS: Linux 4.8.0-36-generic amd64


while compiling below error is encountered:



FAILURE: Build failed with an exception.

* What went wrong:
java.lang.ExceptionInInitializerError (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


and the output of gradle --stacktrace is below:



java.lang.ExceptionInInitializerError
at org.gradle.initialization.DefaultClassLoaderRegistry.restrictTo(DefaultClassLoaderRegistry.java:40)
at org.gradle.initialization.DefaultClassLoaderRegistry.restrictToGradleApi(DefaultClassLoaderRegistry.java:36)
at org.gradle.initialization.DefaultClassLoaderRegistry.<init>(DefaultClassLoaderRegistry.java:30)
at org.gradle.internal.service.scopes.GlobalScopeServices.createClassLoaderRegistry(GlobalScopeServices.java:213)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:547)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.internal.service.DefaultServiceRegistry.invoke(DefaultServiceRegistry.java:462)
at org.gradle.internal.service.DefaultServiceRegistry.access$1200(DefaultServiceRegistry.java:84)
at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:805)
at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:761)
at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:598)
at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:643)
at org.gradle.internal.service.DefaultServiceRegistry.applyConfigureMethod(DefaultServiceRegistry.java:253)
at org.gradle.internal.service.DefaultServiceRegistry.findProviderMethods(DefaultServiceRegistry.java:214)
at org.gradle.internal.service.DefaultServiceRegistry.addProvider(DefaultServiceRegistry.java:352)
at org.gradle.internal.service.ServiceRegistryBuilder.build(ServiceRegistryBuilder.java:52)
at org.gradle.launcher.cli.BuildActionsFactory.createGlobalClientServices(BuildActionsFactory.java:148)
at org.gradle.launcher.cli.BuildActionsFactory.runBuildWithDaemon(BuildActionsFactory.java:108)
at org.gradle.launcher.cli.BuildActionsFactory.createAction(BuildActionsFactory.java:83)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.createAction(CommandLineActionFactory.java:249)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:239)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:217)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:547)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected java.lang.Package java.lang.ClassLoader.getPackages() accessible: module java.base does not "opens java.lang" to unnamed module @6c7a164b
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:335)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:278)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:196)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:190)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:42)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:32)
at org.gradle.internal.reflect.JavaMethod.<init>(JavaMethod.java:36)
at org.gradle.internal.reflect.JavaReflectionUtil.method(JavaReflectionUtil.java:223)
at org.gradle.internal.classloader.FilteringClassLoader.<clinit>(FilteringClassLoader.java:49)
... 40 more


when I set



export GRADLE_OPTS="-Dorg.gradle.jvmargs=--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED"


as suggested at different places, issue remains the same.



Kindly help me out in resolving the issue.



UPDATE:
Changed GRADLE_OPTS to



export GRADLE_OPTS="-Dorg.gradle.jvmargs=--add-opens java.lang=ALL-UNNAMED --add-opens java.util=ALL-UNNAMED --add-opens java.io=ALL-UNNAMED"


Got the following error:



Error: Could not find or load main class java.lang=ALL-UNNAMED
Caused by: java.lang.ClassNotFoundException: java.lang=ALL-UNNAMED






java gradle java-9






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 17 '17 at 9:26







Obi Wan - PallavJha

















asked Mar 17 '17 at 6:57









Obi Wan - PallavJhaObi Wan - PallavJha

1,3861226




1,3861226













  • The --add-opens syntax seems to be slightly off: Unless things changed, there should be no = after --add-opens - see here.

    – Nicolai
    Mar 17 '17 at 8:55






  • 1





    I think Groovy 2.x doesn't work yet with JDK9. This being said, you can't run Gradle with JDK9 but you can use it to compile code targeting JDK9, that is Gradle must run with JDK8 or JDK7, compiler options in the buld file can be set to JDK9

    – aalmiray
    Mar 17 '17 at 9:01











  • @Nicolai After removing '=' I got the above mentioned error.

    – Obi Wan - PallavJha
    Mar 17 '17 at 9:21



















  • The --add-opens syntax seems to be slightly off: Unless things changed, there should be no = after --add-opens - see here.

    – Nicolai
    Mar 17 '17 at 8:55






  • 1





    I think Groovy 2.x doesn't work yet with JDK9. This being said, you can't run Gradle with JDK9 but you can use it to compile code targeting JDK9, that is Gradle must run with JDK8 or JDK7, compiler options in the buld file can be set to JDK9

    – aalmiray
    Mar 17 '17 at 9:01











  • @Nicolai After removing '=' I got the above mentioned error.

    – Obi Wan - PallavJha
    Mar 17 '17 at 9:21

















The --add-opens syntax seems to be slightly off: Unless things changed, there should be no = after --add-opens - see here.

– Nicolai
Mar 17 '17 at 8:55





The --add-opens syntax seems to be slightly off: Unless things changed, there should be no = after --add-opens - see here.

– Nicolai
Mar 17 '17 at 8:55




1




1





I think Groovy 2.x doesn't work yet with JDK9. This being said, you can't run Gradle with JDK9 but you can use it to compile code targeting JDK9, that is Gradle must run with JDK8 or JDK7, compiler options in the buld file can be set to JDK9

– aalmiray
Mar 17 '17 at 9:01





I think Groovy 2.x doesn't work yet with JDK9. This being said, you can't run Gradle with JDK9 but you can use it to compile code targeting JDK9, that is Gradle must run with JDK8 or JDK7, compiler options in the buld file can be set to JDK9

– aalmiray
Mar 17 '17 at 9:01













@Nicolai After removing '=' I got the above mentioned error.

– Obi Wan - PallavJha
Mar 17 '17 at 9:21





@Nicolai After removing '=' I got the above mentioned error.

– Obi Wan - PallavJha
Mar 17 '17 at 9:21












2 Answers
2






active

oldest

votes


















1














I was able to make gradle work using Java 9-ea by running the following terminal command:



export JDK_JAVA_OPTIONS='--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED'


-via https://github.com/gradle/gradle/issues/1095



-Added this to /etc/profile so that it runs on startup






share|improve this answer































    1














    Upgrading Gradle to 4.10.2 version and Java JDK 8 to 1.8.0_191 version worked for me.



    Hope it helps!






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42851099%2fjava-lang-exceptionininitializererror-with-gradle%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      I was able to make gradle work using Java 9-ea by running the following terminal command:



      export JDK_JAVA_OPTIONS='--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED'


      -via https://github.com/gradle/gradle/issues/1095



      -Added this to /etc/profile so that it runs on startup






      share|improve this answer




























        1














        I was able to make gradle work using Java 9-ea by running the following terminal command:



        export JDK_JAVA_OPTIONS='--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED'


        -via https://github.com/gradle/gradle/issues/1095



        -Added this to /etc/profile so that it runs on startup






        share|improve this answer


























          1












          1








          1







          I was able to make gradle work using Java 9-ea by running the following terminal command:



          export JDK_JAVA_OPTIONS='--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED'


          -via https://github.com/gradle/gradle/issues/1095



          -Added this to /etc/profile so that it runs on startup






          share|improve this answer













          I was able to make gradle work using Java 9-ea by running the following terminal command:



          export JDK_JAVA_OPTIONS='--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED'


          -via https://github.com/gradle/gradle/issues/1095



          -Added this to /etc/profile so that it runs on startup







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 10 '17 at 23:44









          NathanAckNathanAck

          17615




          17615

























              1














              Upgrading Gradle to 4.10.2 version and Java JDK 8 to 1.8.0_191 version worked for me.



              Hope it helps!






              share|improve this answer




























                1














                Upgrading Gradle to 4.10.2 version and Java JDK 8 to 1.8.0_191 version worked for me.



                Hope it helps!






                share|improve this answer


























                  1












                  1








                  1







                  Upgrading Gradle to 4.10.2 version and Java JDK 8 to 1.8.0_191 version worked for me.



                  Hope it helps!






                  share|improve this answer













                  Upgrading Gradle to 4.10.2 version and Java JDK 8 to 1.8.0_191 version worked for me.



                  Hope it helps!







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 '18 at 0:50









                  GenaritoGenarito

                  4461518




                  4461518






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42851099%2fjava-lang-exceptionininitializererror-with-gradle%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Full-time equivalent

                      さくらももこ

                      13 indicted, 8 arrested in Calif. drug cartel investigation