title: Cannot load configuration class error spring boot
body: <p>I am working on a spring boot project where I am integrating my api with google calendar api.While running the application I am getting this error:</p>
  <pre><code>java.lang.IllegalStateException: Cannot load configuration class: com.api.GoogleCalApplication
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:403) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:249) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:281) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:125) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at com.api.GoogleCalApplication.main(GoogleCalApplication.java:10) ~[classes/:na]
  Caused by: java.lang.ExceptionInInitializerError: null
      at org.springframework.context.annotation.ConfigurationClassEnhancer.newEnhancer(ConfigurationClassEnhancer.java:122) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:110) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:393) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      ... 12 common frames omitted
  Caused by: java.lang.IllegalStateException: Unable to load cache item
      at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:79) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.core.KeyFactory$Generator.create(KeyFactory.java:221) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:174) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:153) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.proxy.Enhancer.&lt;clinit&gt;(Enhancer.java:73) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      ... 15 common frames omitted
  Caused by: java.lang.ExceptionInInitializerError: null
      at org.springframework.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:243) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:329) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
      at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      ... 22 common frames omitted
  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 &quot;opens java.lang&quot; to unnamed module @7a1ebcd8
      at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357) ~[na:na]
      at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[na:na]
      at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199) ~[na:na]
      at java.base/java.lang.reflect.Method.setAccessible(Method.java:193) ~[na:na]
      at org.springframework.cglib.core.ReflectUtils$1.run(ReflectUtils.java:54) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:312) ~[na:na]
      at org.springframework.cglib.core.ReflectUtils.&lt;clinit&gt;(ReflectUtils.java:44) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      ... 30 common frames omitted
  
  2021-07-26 14:09:13.625  INFO 8492 --- [           main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7bedc48a: startup date [Mon Jul 26 14:09:12 IST 2021]; root of context hierarchy
  2021-07-26 14:09:13.636  WARN 8492 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context close
  
  java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7bedc48a: startup date [Mon Jul 26 14:09:12 IST 2021]; root of context hierarchy
      at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:417) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1002) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:794) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at com.api.GoogleCalApplication.main(GoogleCalApplication.java:10) ~[classes/:na]
  
  2021-07-26 14:09:13.638 ERROR 8492 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception
  
  java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7bedc48a: startup date [Mon Jul 26 14:09:12 IST 2021]; root of context hierarchy
      at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:794) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
      at com.api.GoogleCalApplication.main(GoogleCalApplication.java:10) ~[classes/:na]
  </code></pre>
  <p>Here's my controller:</p>
  <pre><code>package com.api.controllers;
  
  import java.io.IOException;
  import java.util.Collections;
  import java.util.Date;
  import java.util.HashSet;
  import java.util.Set;
  
  import javax.servlet.http.HttpServletRequest;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.springframework.beans.factory.annotation.Value;
  import org.springframework.http.HttpStatus;
  import org.springframework.http.ResponseEntity;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.servlet.view.RedirectView;
  
  import com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl;
  import com.google.api.client.auth.oauth2.Credential;
  import com.google.api.client.auth.oauth2.TokenResponse;
  import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
  import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
  import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.Details;
  import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
  import com.google.api.client.http.HttpTransport;
  import com.google.api.client.json.JsonFactory;
  import com.google.api.client.json.jackson2.JacksonFactory;
  import com.google.api.client.util.DateTime;
  import com.google.api.services.calendar.Calendar.Events;
  import com.google.api.services.calendar.CalendarScopes;
  import com.google.api.services.calendar.model.Event;
  
  @Controller
  public class GoogleCalController {
  
      private final static Log logger = LogFactory.getLog(GoogleCalController.class);
      private static final String APPLICATION_NAME = &quot;&quot;;
      private static HttpTransport httpTransport;
      private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
      private static com.google.api.services.calendar.Calendar client;
  
      GoogleClientSecrets clientSecrets;
      GoogleAuthorizationCodeFlow flow;
      Credential credential;
  
      @Value(&quot;${google.client.client-id}&quot;)
      private String clientId;
      @Value(&quot;${google.client.client-secret}&quot;)
      private String clientSecret;
      @Value(&quot;${google.client.redirectUri}&quot;)
      private String redirectURI;
  
      private Set&lt;Event&gt; events = new HashSet&lt;&gt;();
  
      final DateTime date1 = new DateTime(&quot;2020-07-26T16:30:00.000+05:30&quot;);
      final DateTime date2 = new DateTime(new Date());
  
      public void setEvents(Set&lt;Event&gt; events) {
          this.events = events;
      }
  
      @RequestMapping(value = &quot;/login/google&quot;, method = RequestMethod.GET)
      public RedirectView googleConnectionStatus(HttpServletRequest request) throws Exception {
          return new RedirectView(authorize());
      }
  
      @RequestMapping(value = &quot;/login/google&quot;, method = RequestMethod.GET, params = &quot;code&quot;)
      public ResponseEntity&lt;String&gt; oauth2Callback(@RequestParam(value = &quot;code&quot;) String code) {
          com.google.api.services.calendar.model.Events eventList;
          String message;
          try {
              TokenResponse response = flow.newTokenRequest(code).setRedirectUri(redirectURI).execute();
              credential = flow.createAndStoreCredential(response, &quot;userID&quot;);
              client = new com.google.api.services.calendar.Calendar.Builder(httpTransport, JSON_FACTORY, credential)
                      .setApplicationName(APPLICATION_NAME).build();
              Events events = client.events();
              eventList = events.list(&quot;primary&quot;).setTimeMin(date1).setTimeMax(date2).execute();
              message = eventList.getItems().toString();
              System.out.println(&quot;My:&quot; + eventList.getItems());
          } catch (Exception e) {
              logger.warn(&quot;Exception while handling OAuth2 callback (&quot; + e.getMessage() + &quot;).&quot;
                      + &quot; Redirecting to google connection status page.&quot;);
              message = &quot;Exception while handling OAuth2 callback (&quot; + e.getMessage() + &quot;).&quot;
                      + &quot; Redirecting to google connection status page.&quot;;
          }
  
          System.out.println(&quot;cal message:&quot; + message);
          return new ResponseEntity&lt;&gt;(message, HttpStatus.OK);
      }
  
      public Set&lt;Event&gt; getEvents() throws IOException {
          return this.events;
      }
  
      private String authorize() throws Exception {
          AuthorizationCodeRequestUrl authorizationUrl;
          if (flow == null) {
              Details web = new Details();
              web.setClientId(clientId);
              web.setClientSecret(clientSecret);
              clientSecrets = new GoogleClientSecrets().setWeb(web);
              httpTransport = GoogleNetHttpTransport.newTrustedTransport();
              flow = new GoogleAuthorizationCodeFlow.Builder(httpTransport, JSON_FACTORY, clientSecrets,
                      Collections.singleton(CalendarScopes.CALENDAR)).build();
          }
          authorizationUrl = flow.newAuthorizationUrl().setRedirectUri(redirectURI);
          System.out.println(&quot;cal authorizationUrl-&gt;&quot; + authorizationUrl);
          return authorizationUrl.build();
      }
  }
  </code></pre>
  <p>Here's my app starting point:</p>
  <pre><code>package com.api;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class GoogleCalApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(GoogleCalApplication.class, args);
      }
  
  }
  </code></pre>
  <p>How to solve it?I am stuck for hours now.I have all the dependencies installed.</p>
  <p>Here's my pom.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
      xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.app&lt;/groupId&gt;
      &lt;artifactId&gt;google-calendar-api&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
      &lt;name&gt;google-calendar-api&lt;/name&gt;
      &lt;description&gt;Demo Project for Google Calendar Api&lt;/description&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.5.2.RELEASE&lt;/version&gt;
          &lt;relativePath /&gt;
          &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-configuration-processor&lt;/artifactId&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/com.google.api-client/google-api-client --&gt;
  
  &lt;!-- https://mvnrepository.com/artifact/com.google.apis/google-api-services-calendar --&gt;
  &lt;dependency&gt;
          &lt;groupId&gt;com.google.apis&lt;/groupId&gt;
          &lt;artifactId&gt;google-api-services-calendar&lt;/artifactId&gt;
          &lt;version&gt;v3-rev224-1.22.0&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Gmail Maven Dependency--&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.apis&lt;/groupId&gt;
          &lt;artifactId&gt;google-api-services-gmail&lt;/artifactId&gt;
          &lt;version&gt;v1-rev65-1.18.0-rc&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;com.google.apis&lt;/groupId&gt;
      &lt;artifactId&gt;google-api-services-calendar&lt;/artifactId&gt;
      &lt;version&gt;v3-rev411-1.25.0&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;!-- https://mvnrepository.com/artifact/commons-logging/commons-logging --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;commons-logging&lt;/groupId&gt;
      &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
      &lt;version&gt;1.2&lt;/version&gt;
  &lt;/dependency&gt;
  
          
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;fork&gt;true&lt;/fork&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  <p>all my client keys and secret are in resources application.properties file from where I am refering all my variables like clientId and all.While running the application I straight away get this error.How to solve it?</p>