I am a little lost with this - below is my code...when I run it via IntelliJ debug mode, my Spring app fails to initialize with the following error...
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportController' defined in file [my_code_directory/ic/cybs/target/classes/com/ic/cybs/controller/ReportController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.ic.cybs.controller.ReportController]: Constructor threw exception; nested exception is java.lang.NullPointerException
I am not sure why the Constructor is throwing an exception, the error is being thrown by this line in ReportController.java
private Properties mProp = Configuration.getMDetails();
ReportController.java
package com.ic.cybs.controller;
import com.cybs.authsdk.core.ConfigException;
import com.cybs.authsdk.core.MercConfig;
import com.ic.cybs.config.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Properties;
#RestController
#RequestMapping("/v1/cybs")
public class ReportController {
// constructor
public ReportController() throws ConfigException { }
// private
private Properties mProp = Configuration.getMDetails();
private MercConfig mercConfig = new MercConfig(mProp);
// public
#GetMapping("/")
public String getIndex() {
return String.format("%s", HttpStatus.OK);
}
}
Configuration.java
package com.ic.cybs.config;
import java.util.Properties;
public class Configuration {
// constructor
// private
// public
public static Properties getMDetails() {
Properties properties = new Properties();
// HTTP_Signature = http_signature
properties.setProperty("authenticationType", "http_signature");
properties.setProperty("mID", System.getenv("M_ID"));
properties.setProperty("runEnvironment", System.getenv("ENVIRONMENT"));
properties.setProperty("requestJsonPath", "src/main/resources/request.json");
// HTTP Parameters
properties.setProperty("mKeyId", System.getenv("KEY_ID"));
properties.setProperty("mSecretKey", System.getenv("SECRET_KEY"));
// Logging to be enabled or not.
properties.setProperty("enableLog", "true");
// Log directory Path
properties.setProperty("logDirectory", "log");
properties.setProperty("logFilename", "cybs");
// Log file size in KB
properties.setProperty("logMaximumSize", "5M");
return properties;
}
}
Can someone please tell me why I am getting this error...
Also please note that "Properties getMDetails()" is a public static method, therefore an actual constructor is not needed...
Below is the complete stack trace...
/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:56711,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:/Users/me/Library/Caches/IntelliJIdea2019.1/captureAgent/debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "/Users/me/_code/ic/cybs/target/classes:/Users/me/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/2.2.0.M4/spring-boot-starter-actuator-2.2.0.M4.jar:/Users/me/.m2/repository/org/springframework/boot/spring-boot-starter/2.2.0.M4/spring-boot-starter-2.2.0.M4.jar:/Users/me/.m2/repository/org/springframework/boot/spring-boot/2.2.0.M4/spring-boot-2.2.0.M4.jar:/Users/me/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.2.0.M4/spring-boot-autoconfigure-2.2.0.M4.jar:/Users/me/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.2.0.M4/spring-boot-starter-logging-2.2.0.M4.jar:/Users/me/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/Users/me/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/Users/me/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.11.2/log4j-to-slf4j-2.11.2.jar:/Users/me/.m2/repository/org/slf4j/jul-to-slf4j/1.7.26/jul-to-slf4j-1.7.26.jar:/Users/me/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.4/jakarta.annotation-api-1.3.4.jar:/Users/me/.m2/repository/org/yaml/snakeyaml/1.24/snakeyaml-1.24.jar:/Users/me/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/2.2.0.M4/spring-boot-actuator-autoconfigure-2.2.0.M4.jar:/Users/me/.m2/repository/org/springframework/boot/spring-boot-actuator/2.2.0.M4/spring-boot-actuator-2.2.0.M4.jar:/Users/me/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.9/jackson-databind-2.9.9.jar:/Users/me/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/Users/me/.m2/repository/org/springframework/spring-context/5.2.0.M3/spring-context-5.2.0.M3.jar:/Users/me/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.9/jackson-datatype-jsr310-2.9.9.jar:/Users/me/.m2/repository/io/micrometer/micrometer-core/1.1.5/micrometer-core-1.1.5.jar:/Users/me/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.9/HdrHistogram-2.1.9.jar:/Users/me/.m2/repository/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.jar:/Users/me/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.2.0.M4/spring-boot-starter-web-2.2.0.M4.jar:/Users/me/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.2.0.M4/spring-boot-starter-json-2.2.0.M4.jar:/Users/me/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.9/jackson-datatype-jdk8-2.9.9.jar:/Users/me/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.9/jackson-module-parameter-names-2.9.9.jar:/Users/me/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.2.0.M4/spring-boot-starter-tomcat-2.2.0.M4.jar:/Users/me/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.21/tomcat-embed-core-9.0.21.jar:/Users/me/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.21/tomcat-embed-el-9.0.21.jar:/Users/me/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.21/tomcat-embed-websocket-9.0.21.jar:/Users/me/.m2/repository/org/springframework/boot/spring-boot-starter-validation/2.2.0.M4/spring-boot-starter-validation-2.2.0.M4.jar:/Users/me/.m2/repository/jakarta/validation/jakarta.validation-api/2.0.1/jakarta.validation-api-2.0.1.jar:/Users/me/.m2/repository/org/hibernate/validator/hibernate-validator/6.0.17.Final/hibernate-validator-6.0.17.Final.jar:/Users/me/.m2/repository/org/jboss/logging/jboss-logging/3.4.0.Final/jboss-logging-3.4.0.Final.jar:/Users/me/.m2/repository/com/fasterxml/classmate/1.5.0/classmate-1.5.0.jar:/Users/me/.m2/repository/org/springframework/spring-web/5.2.0.M3/spring-web-5.2.0.M3.jar:/Users/me/.m2/repository/org/springframework/spring-beans/5.2.0.M3/spring-beans-5.2.0.M3.jar:/Users/me/.m2/repository/org/springframework/spring-webmvc/5.2.0.M3/spring-webmvc-5.2.0.M3.jar:/Users/me/.m2/repository/org/springframework/spring-aop/5.2.0.M3/spring-aop-5.2.0.M3.jar:/Users/me/.m2/repository/org/springframework/spring-expression/5.2.0.M3/spring-expression-5.2.0.M3.jar:/Users/me/.m2/repository/org/projectlombok/lombok/1.18.8/lombok-1.18.8.jar:/Users/me/.m2/repository/org/springframework/spring-core/5.2.0.M3/spring-core-5.2.0.M3.jar:/Users/me/.m2/repository/org/springframework/spring-jcl/5.2.0.M3/spring-jcl-5.2.0.M3.jar:/Users/me/.m2/repository/com/cybs/AuthenticationSdk/0.0.5/AuthenticationSdk-0.0.5.jar:/Users/me/.m2/repository/org/bouncycastle/bcprov-jdk16/1.45/bcprov-jdk16-1.45.jar:/Users/me/.m2/repository/com/nimbusds/nimbus-jose-jwt/4.22/nimbus-jose-jwt-4.22.jar:/Users/me/.m2/repository/com/github/stephenc/jcip/jcip-annotations/1.0-1/jcip-annotations-1.0-1.jar:/Users/me/.m2/repository/commons-io/commons-io/2.6/commons-io-2.6.jar:/Users/me/.m2/repository/net/minidev/asm/1.0.2/asm-1.0.2.jar:/Users/me/.m2/repository/asm/asm/3.3.1/asm-3.3.1.jar:/Users/me/.m2/repository/org/apache/logging/log4j/log4j-api/2.11.2/log4j-api-2.11.2.jar:/Users/me/.m2/repository/org/apache/logging/log4j/log4j-core/2.11.2/log4j-core-2.11.2.jar:/Users/me/.m2/repository/org/apache/logging/log4j/log4j-1.2-api/2.11.2/log4j-1.2-api-2.11.2.jar:/Users/me/.m2/repository/net/minidev/json-smart/1.0.9/json-smart-1.0.9.jar:/Users/me/.m2/repository/org/slf4j/slf4j-api/1.7.26/slf4j-api-1.7.26.jar:/Users/me/.m2/repository/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar:/Users/me/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/Users/me/.m2/repository/io/vertx/vertx-core/3.5.3/vertx-core-3.5.3.jar:/Users/me/.m2/repository/io/netty/netty-common/4.1.36.Final/netty-common-4.1.36.Final.jar:/Users/me/.m2/repository/io/netty/netty-buffer/4.1.36.Final/netty-buffer-4.1.36.Final.jar:/Users/me/.m2/repository/io/netty/netty-transport/4.1.36.Final/netty-transport-4.1.36.Final.jar:/Users/me/.m2/repository/io/netty/netty-handler/4.1.36.Final/netty-handler-4.1.36.Final.jar:/Users/me/.m2/repository/io/netty/netty-codec/4.1.36.Final/netty-codec-4.1.36.Final.jar:/Users/me/.m2/repository/io/netty/netty-handler-proxy/4.1.36.Final/netty-handler-proxy-4.1.36.Final.jar:/Users/me/.m2/repository/io/netty/netty-codec-socks/4.1.36.Final/netty-codec-socks-4.1.36.Final.jar:/Users/me/.m2/repository/io/netty/netty-codec-http/4.1.36.Final/netty-codec-http-4.1.36.Final.jar:/Users/me/.m2/repository/io/netty/netty-codec-http2/4.1.36.Final/netty-codec-http2-4.1.36.Final.jar:/Users/me/.m2/repository/io/netty/netty-resolver/4.1.36.Final/netty-resolver-4.1.36.Final.jar:/Users/me/.m2/repository/io/netty/netty-resolver-dns/4.1.36.Final/netty-resolver-dns-4.1.36.Final.jar:/Users/me/.m2/repository/io/netty/netty-codec-dns/4.1.36.Final/netty-codec-dns-4.1.36.Final.jar:/Users/me/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.9/jackson-core-2.9.9.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar" com.ic.cybs.cybsApplication
Connected to the target VM, address: '127.0.0.1:56711', transport: 'socket'
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.0.M4)
2019-07-21 13:34:10.051 INFO 68613 --- [ main] c.i.cybs.cybsApplication : Starting cybsApplication on Didiers-MacBook-Pro-2.local with PID 68613 (/Users/me/_code/ic/cybs/target/classes started by me in /Users/me/_code/ic/cybs)
2019-07-21 13:34:10.054 INFO 68613 --- [ main] c.i.cybs.cybsApplication : No active profile set, falling back to default profiles: default
2019-07-21 13:34:11.183 INFO 68613 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-07-21 13:34:11.190 INFO 68613 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-07-21 13:34:11.191 INFO 68613 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.21]
2019-07-21 13:34:11.256 INFO 68613 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-07-21 13:34:11.256 INFO 68613 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1145 ms
2019-07-21 13:34:11.462 WARN 68613 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportController' defined in file [/Users/me/_code/ic/cybs/target/classes/com/ic/cybs/controller/ReportController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.ic.cybs.controller.ReportController]: Constructor threw exception; nested exception is java.lang.NullPointerException
2019-07-21 13:34:11.465 INFO 68613 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-07-21 13:34:11.480 INFO 68613 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-07-21 13:34:11.487 ERROR 68613 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportController' defined in file [/Users/me/_code/ic/cybs/target/classes/com/ic/cybs/controller/ReportController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.ic.cybs.controller.ReportController]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1308) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1202) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:870) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.2.0.M4.jar:2.2.0.M4]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:748) ~[spring-boot-2.2.0.M4.jar:2.2.0.M4]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) ~[spring-boot-2.2.0.M4.jar:2.2.0.M4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-2.2.0.M4.jar:2.2.0.M4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1227) ~[spring-boot-2.2.0.M4.jar:2.2.0.M4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1216) ~[spring-boot-2.2.0.M4.jar:2.2.0.M4]
at com.ic.cybs.cybsApplication.main(cybsApplication.java:80) ~[classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.ic.cybs.controller.ReportController]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:213) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1300) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
... 17 common frames omitted
Caused by: java.lang.NullPointerException: null
at java.base/java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011) ~[na:na]
at java.base/java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1006) ~[na:na]
at java.base/java.util.Properties.put(Properties.java:1316) ~[na:na]
at java.base/java.util.Properties.setProperty(Properties.java:225) ~[na:na]
at com.ic.cybs.config.Configuration.getMerchantDetails(Configuration.java:86) ~[classes/:na]
at com.ic.cybs.controller.ReportController.<init>(ReportController.java:90) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) ~[na:na]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:200) ~[spring-beans-5.2.0.M3.jar:5.2.0.M3]
... 19 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:56711', transport: 'socket'
Process finished with exit code 1
Related
I'm trying to run a Spring Boot project I'm working on, but am facing an unrecoverable exception when starting the application:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.0)
2021-01-27 20:31:16.477 INFO 35041 --- [ main] dev.conductor.centra.CentraApplication : Starting CentraApplication using Java 13.0.5.1 on MacBook-Air.local with PID 35041 (/Users/shamil/Projects/Centra/build/classes/java/main started by shamil in /Users/shamil/Projects/Centra)
2021-01-27 20:31:16.478 INFO 35041 --- [ main] dev.conductor.centra.CentraApplication : No active profile set, falling back to default profiles: default
2021-01-27 20:31:16.852 INFO 35041 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
2021-01-27 20:31:16.901 INFO 35041 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 47ms. Found 16 MongoDB repository interfaces.
2021-01-27 20:31:17.003 WARN 35041 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Pointcut
2021-01-27 20:31:17.009 INFO 35041 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-01-27 20:31:17.017 ERROR 35041 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Pointcut
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:617) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:232) ~[spring-context-5.3.1.jar:5.3.1]
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:767) ~[spring-context-5.3.1.jar:5.3.1]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:572) ~[spring-context-5.3.1.jar:5.3.1]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298) ~[spring-boot-2.4.0.jar:2.4.0]
at dev.conductor.centra.CentraApplication.main(CentraApplication.java:18) ~[main/:na]
Caused by: java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Pointcut
at org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.<clinit>(AbstractAspectJAdvisorFactory.java:62) ~[spring-aop-5.3.1.jar:5.3.1]
at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.initBeanFactory(AnnotationAwareAspectJAutoProxyCreator.java:82) ~[spring-aop-5.3.1.jar:5.3.1]
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.setBeanFactory(AbstractAdvisorAutoProxyCreator.java:65) ~[spring-aop-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1810) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1775) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609) ~[spring-beans-5.3.1.jar:5.3.1]
... 16 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.annotation.Pointcut
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
... 22 common frames omitted
Process finished with exit code 1
As far as I can see, AOP / aspect isn't being used in the application at all, so I'm curious to see what requires the bean to be instantiated?
In my Spring Boot project, I defined 4 profiles
demo
dev
test
prod
properties in YAML files will be replaced by HashiCorp Vault properties during startup. For this, I use Spring Cloud Vault library. Everything works as expected in Spring Boot 2.3.x
When I try to upgrade the project to Spring Boot 2.4.0 with Spring Cloud Vault 3.0.0-SNAPSHOT version, the properties are not being replaced
bootstrap.yml
spring:
cloud:
vault:
authentication: APPROLE
app-role:
role-id: ${role-id}
secret-id: ${secret-id}
role: pres-read
app-role-path: approle
uri: ${vault-server}
connection-timeout: 5000
read-timeout: 15000
kv:
enabled: true
backend: secret
application-name: app/pres
application.yml
spring:
config:
activate:
on-profile: 'demo'
application-demo.yml
## Server Properties
server:
port: 8081
spring:
datasource:
username: ${pres.db.username}
password: ${pres.db.password}
url: ${pres.db.url}
Spring Cloud Vault Library
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-vault-config</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
Error Log:
/Users/jaddap2/Library/Java/JavaVirtualMachines/adopt-openj9-11.0.9/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:59487,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.profiles.active=demo -Dspring.output.ansi.enabled=always -Drole_id=49c8d8fb-1bdd-7f3b-493f-a11e20907a62 -Dsecret_id=a7ee91cc-e259-82ff-2b34-5c333dda300c -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:/Users/jaddap2/Library/Caches/JetBrains/IntelliJIdea2020.2/captureAgent/debugger-agent.jar -Dfile.encoding=UTF-8 -classpath /Users/jaddap2/IdeaProjects/HashiCorpVault-SpringCloud/target/classes:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/2.4.0/spring-boot-starter-data-jpa-2.4.0.jar:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot-starter-aop/2.4.0/spring-boot-starter-aop-2.4.0.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-aop/5.3.1/spring-aop-5.3.1.jar:/Users/jaddap2/.m2/repository/org/aspectj/aspectjweaver/1.9.6/aspectjweaver-1.9.6.jar:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/2.4.0/spring-boot-starter-jdbc-2.4.0.jar:/Users/jaddap2/.m2/repository/com/zaxxer/HikariCP/3.4.5/HikariCP-3.4.5.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-jdbc/5.3.1/spring-jdbc-5.3.1.jar:/Users/jaddap2/.m2/repository/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3.jar:/Users/jaddap2/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar:/Users/jaddap2/.m2/repository/org/hibernate/hibernate-core/5.4.23.Final/hibernate-core-5.4.23.Final.jar:/Users/jaddap2/.m2/repository/org/jboss/logging/jboss-logging/3.4.1.Final/jboss-logging-3.4.1.Final.jar:/Users/jaddap2/.m2/repository/org/javassist/javassist/3.24.0-GA/javassist-3.24.0-GA.jar:/Users/jaddap2/.m2/repository/net/bytebuddy/byte-buddy/1.10.18/byte-buddy-1.10.18.jar:/Users/jaddap2/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/jaddap2/.m2/repository/org/jboss/jandex/2.1.3.Final/jandex-2.1.3.Final.jar:/Users/jaddap2/.m2/repository/com/fasterxml/classmate/1.5.1/classmate-1.5.1.jar:/Users/jaddap2/.m2/repository/org/dom4j/dom4j/2.1.3/dom4j-2.1.3.jar:/Users/jaddap2/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.1.2.Final/hibernate-commons-annotations-5.1.2.Final.jar:/Users/jaddap2/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.3/jaxb-runtime-2.3.3.jar:/Users/jaddap2/.m2/repository/org/glassfish/jaxb/txw2/2.3.3/txw2-2.3.3.jar:/Users/jaddap2/.m2/repository/com/sun/istack/istack-commons-runtime/3.0.11/istack-commons-runtime-3.0.11.jar:/Users/jaddap2/.m2/repository/com/sun/activation/jakarta.activation/1.2.2/jakarta.activation-1.2.2.jar:/Users/jaddap2/.m2/repository/org/springframework/data/spring-data-jpa/2.4.1/spring-data-jpa-2.4.1.jar:/Users/jaddap2/.m2/repository/org/springframework/data/spring-data-commons/2.4.1/spring-data-commons-2.4.1.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-orm/5.3.1/spring-orm-5.3.1.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-context/5.3.1/spring-context-5.3.1.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-tx/5.3.1/spring-tx-5.3.1.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-beans/5.3.1/spring-beans-5.3.1.jar:/Users/jaddap2/.m2/repository/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-aspects/5.3.1/spring-aspects-5.3.1.jar:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.4.0/spring-boot-starter-web-2.4.0.jar:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot-starter/2.4.0/spring-boot-starter-2.4.0.jar:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.4.0/spring-boot-starter-logging-2.4.0.jar:/Users/jaddap2/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/Users/jaddap2/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/Users/jaddap2/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.13.3/log4j-to-slf4j-2.13.3.jar:/Users/jaddap2/.m2/repository/org/apache/logging/log4j/log4j-api/2.13.3/log4j-api-2.13.3.jar:/Users/jaddap2/.m2/repository/org/slf4j/jul-to-slf4j/1.7.30/jul-to-slf4j-1.7.30.jar:/Users/jaddap2/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/jaddap2/.m2/repository/org/yaml/snakeyaml/1.27/snakeyaml-1.27.jar:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.4.0/spring-boot-starter-json-2.4.0.jar:/Users/jaddap2/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.11.3/jackson-databind-2.11.3.jar:/Users/jaddap2/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.11.3/jackson-annotations-2.11.3.jar:/Users/jaddap2/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.11.3/jackson-core-2.11.3.jar:/Users/jaddap2/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.11.3/jackson-datatype-jdk8-2.11.3.jar:/Users/jaddap2/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.11.3/jackson-datatype-jsr310-2.11.3.jar:/Users/jaddap2/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.11.3/jackson-module-parameter-names-2.11.3.jar:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.4.0/spring-boot-starter-tomcat-2.4.0.jar:/Users/jaddap2/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.39/tomcat-embed-core-9.0.39.jar:/Users/jaddap2/.m2/repository/org/glassfish/jakarta.el/3.0.3/jakarta.el-3.0.3.jar:/Users/jaddap2/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.39/tomcat-embed-websocket-9.0.39.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-web/5.3.1/spring-web-5.3.1.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-webmvc/5.3.1/spring-webmvc-5.3.1.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-expression/5.3.1/spring-expression-5.3.1.jar:/Users/jaddap2/.m2/repository/org/springframework/cloud/spring-cloud-starter-vault-config/3.0.0-SNAPSHOT/spring-cloud-starter-vault-config-3.0.0-20201123.200715-420.jar:/Users/jaddap2/.m2/repository/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar:/Users/jaddap2/.m2/repository/commons-codec/commons-codec/1.15/commons-codec-1.15.jar:/Users/jaddap2/.m2/repository/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.jar:/Users/jaddap2/.m2/repository/org/springframework/cloud/spring-cloud-starter/3.0.0-SNAPSHOT/spring-cloud-starter-3.0.0-20201123.160603-486.jar:/Users/jaddap2/.m2/repository/org/springframework/cloud/spring-cloud-context/3.0.0-SNAPSHOT/spring-cloud-context-3.0.0-20201123.160522-488.jar:/Users/jaddap2/.m2/repository/org/springframework/security/spring-security-crypto/5.4.1/spring-security-crypto-5.4.1.jar:/Users/jaddap2/.m2/repository/org/springframework/cloud/spring-cloud-commons/3.0.0-SNAPSHOT/spring-cloud-commons-3.0.0-20201123.160533-486.jar:/Users/jaddap2/.m2/repository/org/springframework/security/spring-security-rsa/1.0.9.RELEASE/spring-security-rsa-1.0.9.RELEASE.jar:/Users/jaddap2/.m2/repository/org/bouncycastle/bcpkix-jdk15on/1.64/bcpkix-jdk15on-1.64.jar:/Users/jaddap2/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.64/bcprov-jdk15on-1.64.jar:/Users/jaddap2/.m2/repository/org/springframework/cloud/spring-cloud-vault-config/3.0.0-SNAPSHOT/spring-cloud-vault-config-3.0.0-20201123.200557-420.jar:/Users/jaddap2/.m2/repository/org/springframework/vault/spring-vault-core/2.3.0-M1/spring-vault-core-2.3.0-M1.jar:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot-devtools/2.4.0/spring-boot-devtools-2.4.0.jar:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot/2.4.0/spring-boot-2.4.0.jar:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.4.0/spring-boot-autoconfigure-2.4.0.jar:/Users/jaddap2/.m2/repository/mysql/mysql-connector-java/8.0.22/mysql-connector-java-8.0.22.jar:/Users/jaddap2/.m2/repository/org/springframework/boot/spring-boot-configuration-processor/2.4.0/spring-boot-configuration-processor-2.4.0.jar:/Users/jaddap2/.m2/repository/org/projectlombok/lombok/1.18.16/lombok-1.18.16.jar:/Users/jaddap2/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar:/Users/jaddap2/.m2/repository/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-core/5.3.1/spring-core-5.3.1.jar:/Users/jaddap2/.m2/repository/org/springframework/spring-jcl/5.3.1/spring-jcl-5.3.1.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar com.pj.vaultdemo.VaultDemoApplication
Connected to the target VM, address: '127.0.0.1:59487', transport: 'socket'
{spring.web.resources.chain.cache=false, spring.web.resources.cache.period=0}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.0)
2020-11-24 14:57:53.788 INFO 95795 --- [ restartedMain] com.pj.vaultdemo.VaultDemoApplication : Starting VaultDemoApplication using Java 11.0.9 on macOsMachine with PID 95795 (/Users/jaddap2/IdeaProjects/HashiCorpVault-SpringCloud/target/classes started by jaddap2 in /Users/jaddap2/IdeaProjects/HashiCorpVault-SpringCloud)
2020-11-24 14:57:53.792 INFO 95795 --- [ restartedMain] com.pj.vaultdemo.VaultDemoApplication : The following profiles are active: demo
2020-11-24 14:57:53.895 INFO 95795 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-11-24 14:57:53.895 INFO 95795 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-11-24 14:57:54.904 INFO 95795 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-11-24 14:57:54.962 INFO 95795 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 48 ms. Found 1 JPA repository interfaces.
2020-11-24 14:57:55.300 INFO 95795 --- [ restartedMain] o.s.cloud.context.scope.GenericScope : BeanFactory id=80a5ef39-fa0c-39ac-928e-c0ba95b06c78
2020-11-24 14:57:56.347 INFO 95795 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2020-11-24 14:57:56.358 INFO 95795 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-11-24 14:57:56.359 INFO 95795 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.39]
2020-11-24 14:57:56.490 INFO 95795 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-11-24 14:57:56.491 INFO 95795 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2594 ms
2020-11-24 14:57:56.580 WARN 95795 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$JpaInvokerConfiguration': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalArgumentException: URL must start with 'jdbc'
2020-11-24 14:57:56.585 INFO 95795 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-11-24 14:57:56.627 INFO 95795 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-11-24 14:57:56.661 ERROR 95795 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$JpaInvokerConfiguration': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalArgumentException: URL must start with 'jdbc'
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:429) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1780) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$247/000000000000000000.getObject(Unknown Source) ~[na:na]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1161) ~[spring-context-5.3.1.jar:5.3.1]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:915) ~[spring-context-5.3.1.jar:5.3.1]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588) ~[spring-context-5.3.1.jar:5.3.1]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298) ~[spring-boot-2.4.0.jar:2.4.0]
at com.pj.vaultdemo.VaultDemoApplication.main(VaultDemoApplication.java:11) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.4.0.jar:2.4.0]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalArgumentException: URL must start with 'jdbc'
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$247/000000000000000000.getObject(Unknown Source) ~[na:na]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$JpaInvokerConfiguration.init(RefreshAutoConfiguration.java:131) ~[spring-cloud-context-3.0.0-20201123.160522-488.jar:3.0.0-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.3.1.jar:5.3.1]
... 25 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalArgumentException: URL must start with 'jdbc'
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1179) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:571) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$247/000000000000000000.getObject(Unknown Source) ~[na:na]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.getIfUnique(DefaultListableBeanFactory.java:2050) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.getDataSourceInitializer(DataSourceInitializerInvoker.java:98) ~[spring-boot-autoconfigure-2.4.0.jar:2.4.0]
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.afterPropertiesSet(DataSourceInitializerInvoker.java:61) ~[spring-boot-autoconfigure-2.4.0.jar:2.4.0]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1847) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784) ~[spring-beans-5.3.1.jar:5.3.1]
... 40 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalArgumentException: URL must start with 'jdbc'
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.3.1.jar:5.3.1]
... 57 common frames omitted
Caused by: java.lang.IllegalArgumentException: URL must start with 'jdbc'
at org.springframework.util.Assert.isTrue(Assert.java:121) ~[spring-core-5.3.1.jar:5.3.1]
at org.springframework.boot.jdbc.DatabaseDriver.fromJdbcUrl(DatabaseDriver.java:283) ~[spring-boot-2.4.0.jar:2.4.0]
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:229) ~[spring-boot-autoconfigure-2.4.0.jar:2.4.0]
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:176) ~[spring-boot-autoconfigure-2.4.0.jar:2.4.0]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:48) ~[spring-boot-autoconfigure-2.4.0.jar:2.4.0]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:90) ~[spring-boot-autoconfigure-2.4.0.jar:2.4.0]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.1.jar:5.3.1]
... 58 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:59487', transport: 'socket'
Process finished with exit code 0
As pointed put by Nicoll, With Spring Cloud Vault 3.0 and Spring Boot 2.4, the bootstrap context initialization (bootstrap.yml, bootstrap.properties) of property sources was deprecated. This can be fixed in one of the 2 ways
Use Spring Boot 2.4.0 Config Data API to import configuration from Vault (Preferred)
Legacy Processing: Enable the bootstrap context either by setting the configuration property spring.cloud.bootstrap.enabled=true or by including the dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
1. Use Spring Boot 2.4.0 Config Data API (Preferred)
Move bootstrap.yml configuration to application.yml and updated file looks like below
application.yml
spring:
cloud:
vault:
authentication: APPROLE
app-role:
role-id: ${role-id}
secret-id: ${secret-id}
role: pres-read
app-role-path: approle
uri: ${vault-server}
connection-timeout: 5000
read-timeout: 15000
config:
import: vault://secret/app/pres/
And define individual profiles as shown below. Add spring.config.import: vault://secret/app/pres/demo property.
application-demo.yml
## Server Properties
server:
port: 8081
spring:
config:
import: vault://secret/app/pres/demo
datasource:
username: ${pres.db.username}
password: ${pres.db.password}
url: ${pres.db.url}
driver-class-name: com.mysql.cj.jdbc.Driver
Repeat the same process for all profiles like dev, test, qc, staging and prod.
2. Legacy Processing:
Add the following dependency if you still want to use bootstrap.yml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
to the project. The issue will be resolved.
See Spring Cloud Vault docs for more information
I spent a whole day trying to resolve this issue.
For everyone who is following any outdated cloud tutorials:- from springboot 2.4 bootstrap starter dependency has to be added, to follow along the tutorial to use bootstrap.properties (bootstrap.yml) for external configuration.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
So, thiss error appears in one of my team-members IntelliJ.
Anyone faced this or similar problem before?
Same code runs with no problems on my pc on intelliJ with same settings and 2 others with mac, also tried installing on another pc and no problem.
It's a big project, so you would need to ask for any code that would be helpfull.
But still, the code should be ok because of running on several other machines.
We checked javaversion in project settings, he got 8.241 and me 8.211. Trying the 8.211 didn't help.
We checked java path in windows env variables, seems ok.
We tried reinstall IntelliJ.
We tried remove git repo, then new clone from bitBucket.
We tried maven refresh/update
We tried removing the .m2 folder
We tried another computer (this one had same login though as the team-members pc that wont work)
We checked env.variables in project
We checked pom.xml
Everything seems ok, but application won't run.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.5.RELEASE)
2020-03-23 16:45:31.820 INFO 12592 --- [ main] se.companyName.appName.appNameApplication : Starting appNameApplication on computer with PID 12592 (C:\git-repos\appName-api\target\classes started by myUserName in C:\git-repos\appName-api)
2020-03-23 16:45:31.858 DEBUG 12592 --- [ main] se.companyName.appName.appNameApplication : Running with Spring Boot v2.1.5.RELEASE, Spring v5.1.7.RELEASE
2020-03-23 16:45:31.860 INFO 12592 --- [ main] se.companyName.appName.appNameApplication : No active profile set, falling back to default profiles: default
2020-03-23 16:45:34.317 INFO 12592 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2020-03-23 16:45:34.600 INFO 12592 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 257ms. Found 3 repository interfaces.
2020-03-23 16:45:35.751 INFO 12592 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$349c9192] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-23 16:45:35.867 INFO 12592 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$cd4a59cc] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-23 16:45:35.892 INFO 12592 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-23 16:45:35.897 INFO 12592 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler#378f002a' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-23 16:45:35.906 INFO 12592 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$f21efc7e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-23 16:45:35.915 INFO 12592 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-23 16:45:36.643 INFO 12592 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-03-23 16:45:36.699 INFO 12592 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-03-23 16:45:36.700 INFO 12592 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.19]
2020-03-23 16:45:37.229 INFO 12592 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-03-23 16:45:37.356 DEBUG 12592 --- [ main] s.h.a.security.filter.UserStatusFilter : Filter 'userStatusFilter' configured for use
2020-03-23 16:45:37.913 INFO 12592 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-03-23 16:45:38.818 INFO 12592 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-03-23 16:45:42.256 INFO 12592 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-03-23 16:45:43.980 WARN 12592 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot configure enpdoints
2020-03-23 16:45:44.003 INFO 12592 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-03-23 16:45:44.008 INFO 12592 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-03-23 16:45:44.026 INFO 12592 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-03-23 16:45:44.029 INFO 12592 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-03-23 16:45:44.056 INFO 12592 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-23 16:45:44.093 ERROR 12592 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot configure enpdoints
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:139) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:414) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:843) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
at se.companyName.appName.appNameApplication.main(appNameApplication.java:17) ~[classes/:na]
Caused by: java.lang.IllegalStateException: Cannot configure enpdoints
at org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration.init(AuthorizationServerEndpointsConfiguration.java:81) ~[spring-security-oauth2-2.3.5.RELEASE.jar:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:363) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:307) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
... 18 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accessTokenConverter' defined in class path resource [se/companyName/appName/security/config/AuthorizationServerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'accessTokenConverter' threw exception; nested exception is java.lang.IllegalArgumentException: failed to construct sequence from byte[]: DER length more than 4 bytes: 18
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:394) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:366) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at se.companyName.appName.security.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$c09734a8.accessTokenConverter(<generated>) ~[classes/:na]
at se.companyName.appName.security.config.AuthorizationServerConfig.configure(AuthorizationServerConfig.java:66) ~[classes/:na]
at org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration.init(AuthorizationServerEndpointsConfiguration.java:79) ~[spring-security-oauth2-2.3.5.RELEASE.jar:na]
... 25 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'accessTokenConverter' threw exception; nested exception is java.lang.IllegalArgumentException: failed to construct sequence from byte[]: DER length more than 4 bytes: 18
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
... 39 common frames omitted
Caused by: java.lang.IllegalArgumentException: failed to construct sequence from byte[]: DER length more than 4 bytes: 18
at org.bouncycastle.asn1.ASN1Sequence.getInstance(Unknown Source) ~[bcprov-jdk15on-1.56.jar:1.56.0]
at org.springframework.security.jwt.crypto.sign.RsaKeyHelper.parseKeyPair(RsaKeyHelper.java:56) ~[spring-security-jwt-1.0.9.RELEASE.jar:na]
at org.springframework.security.jwt.crypto.sign.RsaSigner.loadPrivateKey(RsaSigner.java:77) ~[spring-security-jwt-1.0.9.RELEASE.jar:na]
at org.springframework.security.jwt.crypto.sign.RsaSigner.<init>(RsaSigner.java:48) ~[spring-security-jwt-1.0.9.RELEASE.jar:na]
at org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter.setSigningKey(JwtAccessTokenConverter.java:177) ~[spring-security-oauth2-2.3.5.RELEASE.jar:na]
at se.companyName.appName.security.config.AuthorizationServerConfig.accessTokenConverter(AuthorizationServerConfig.java:87) ~[classes/:na]
at se.companyName.appName.security.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$c09734a8.CGLIB$accessTokenConverter$3(<generated>) ~[classes/:na]
at se.companyName.appName.security.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$c09734a8$$FastClassBySpringCGLIB$$616eb46b.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at se.companyName.appName.security.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$c09734a8.accessTokenConverter(<generated>) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
... 40 common frames omitted
Process finished with exit code 1
Caused by: java.lang.IllegalArgumentException: failed to construct sequence from byte[]: DER length more than 4 bytes: 18
at org.bouncycastle.asn1.ASN1Sequence.getInstance(Unknown Source) ~[bcprov-jdk15on-1.56.jar:1.56.0]
It looks like that the Self signed certificate or the PEM file is NOT present as expected in your setup. Checkout those files once, PEM file should not be encrypted.
Use the same SSL engine which was used to create those.
I'm trying to build a secured (JWT) reactive (webflow) spring-boot app, but can't get it starting.
I've built a servlet companion app with same components and similar config which works fine, but it looks like something is missing in my conf and can't figure out what.
#SpringBootApplication(scanBasePackageClasses = { ReactiveApp.class, GreetingHandler.class, GreetingRouter.class,
MessageService.class, MessageServiceImpl.class })
public class ReactiveApp {
public static void main(String[] args) {
SpringApplication.run(ReactiveApp.class, args);
}
#EnableWebFluxSecurity
#EnableReactiveMethodSecurity
public class ReactiveSecurityConfig {
#Value("${spring.security.oauth2.resourceserver.jwt.issuer-uri}")
String issuerUri;
#Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
// #formatter:off
http.csrf().disable().httpBasic().disable().formLogin().disable();
http.authorizeExchange().pathMatchers("/secret-endpoint").hasAnyRole("AUTHORIZED_PERSONNEL").anyExchange()
.authenticated();
http.oauth2ResourceServer().jwt().jwtAuthenticationConverter(authExtractor());
// #formatter:on
return http.build();
}
#Bean
ReactiveJwtDecoder jwtDecoder() {
return ReactiveJwtDecoders.fromOidcIssuerLocation(issuerUri);
}
#Bean
public AuthenticationConverter authExtractor() {
KeycloackOidcIdAuthenticationConverter extractor = new KeycloackOidcIdAuthenticationConverter() {
};
return jwt -> Mono.just(jwt).map(extractor::convert);
}
}
private static interface AuthenticationConverter extends Converter<Jwt, Mono<AbstractAuthenticationToken>> {
}
}
Logs are minimal :/
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.4.RELEASE)
2020-02-12 18:47:23.975 INFO 13320 --- [ main] c.c.s.sample.reactive.ReactiveApp : Starting ReactiveApp on LAPTOP-JEREM with PID 13320 (C:\Users\jwacongne\dev\workspaces\libs\spring-addons\spring-security-test-keycloack-addons\target\test-classes started by jwacongne in C:\Users\jwacongne\dev\workspaces\libs\spring-addons\spring-security-test-keycloack-addons)
2020-02-12 18:47:23.978 INFO 13320 --- [ main] c.c.s.sample.reactive.ReactiveApp : No active profile set, falling back to default profiles: default
2020-02-12 18:47:25.091 INFO 13320 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8090 (https)
2020-02-12 18:47:25.109 INFO 13320 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-02-12 18:47:25.110 INFO 13320 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-02-12 18:47:25.259 INFO 13320 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-02-12 18:47:25.260 INFO 13320 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1238 ms
2020-02-12 18:47:26.054 INFO 13320 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-02-12 18:47:26.234 WARN 13320 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtDecoderWebSecurityConfigurerAdapter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor<?>' available
2020-02-12 18:47:26.235 INFO 13320 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-02-12 18:47:26.237 INFO 13320 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-02-12 18:47:26.249 INFO 13320 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-02-12 18:47:26.386 ERROR 13320 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' in your configuration.
While debugging, I can see exception with following message is thrown:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtDecoderWebSecurityConfigurerAdapter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor<?>' available
Spring-boot version: 2.2.4
I’m setting up a Spring Boot maven multi-module project where I have Domain layer, Persistence layer and Web layer.
ive been looking up similar questions,but none seem to be my case,i suspect its due to the fact the project is divided in individual maven modules Spring cant find the bean.
tried some posible solutions but they dont seem to be solving the problem.
Main
#SpringBootApplication(scanBasePackages = { "com.imricki.movie.domain", "com.imricki.movie.persistence",
"com.imricki.movie.web" })
public class SpringBootAplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootAplication.class, args);
}
}
RestController
#RequestMapping(value = "/api")
#RestController
class MovieRestController {
#Autowired
private MovieService service;
#RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
ResponseEntity<Void> delete(#PathVariable Long Id) {
this.service.delete(Id);
return new ResponseEntity<>(HttpStatus.OK);
}
Service
#Service
public class MovieServiceImpl implements MovieService {
#Autowired
MovieRepository repo;
/** The model mapper to convert. */
private final ModelMapper modelMapper = new ModelMapper();
#Override
#Transactional
public void delete(Long id) {
this.repo.deleteById(id);
}
Persistence
#Repository
public interface MovieRepository extends JpaRepository<Movie, Long> {
}
this is what the structure looks like
Im getting a excepcion wen starting the embebed tomcat,as i said before i think ists because it cant find the service so it cant inject the bean
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.3.RELEASE)
2019-05-18 21:42:40.598 INFO 1696 --- [ main] c.i.movie.web.SpringBootAplication : Starting SpringBootAplication on DESKTOP-Q7NDFBT with PID 1696 (C:\Desarollo\wks\Parent\Web\target\classes started by Usuario in C:\Desarollo\wks\Parent\Web)
2019-05-18 21:42:40.598 INFO 1696 --- [ main] c.i.movie.web.SpringBootAplication : No active profile set, falling back to default profiles: default
2019-05-18 21:42:43.114 INFO 1696 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2019-05-18 21:42:43.134 INFO 1696 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-05-18 21:42:43.134 INFO 1696 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-05-18 21:42:43.165 INFO 1696 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_202\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_202/bin/server;C:/Program Files/Java/jre1.8.0_202/bin;C:/Program Files/Java/jre1.8.0_202/lib/amd64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Calibre2\;C:\Program Files\Git\cmd;C:\Users\Usuario\AppData\Local\Microsoft\WindowsApps;;C:\Microsoft VS Code\bin;C:\eclipse\eclipse-jee-2019-03-R-win32-x86_64\eclipse;;.]
2019-05-18 21:42:43.745 INFO 1696 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-05-18 21:42:43.745 INFO 1696 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3100 ms
2019-05-18 21:42:44.276 WARN 1696 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'movieService' defined in file [C:\Desarollo\wks\Parent\Domain\target\classes\com\imricki\movie\domain\impl\MovieServiceImpl.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.imricki.movie.domain.impl.MovieServiceImpl] from ClassLoader [sun.misc.Launcher$AppClassLoader#764c12b6]
2019-05-18 21:42:44.286 INFO 1696 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-05-18 21:42:44.348 INFO 1696 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-05-18 21:42:44.442 ERROR 1696 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'movieService' defined in file [C:\Desarollo\wks\Parent\Domain\target\classes\com\imricki\movie\domain\impl\MovieServiceImpl.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.imricki.movie.domain.impl.MovieServiceImpl] from ClassLoader [sun.misc.Launcher$AppClassLoader#764c12b6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:570) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at com.imricki.movie.web.SpringBootAplication.main(SpringBootAplication.java:11) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.imricki.movie.domain.impl.MovieServiceImpl] from ClassLoader [sun.misc.Launcher$AppClassLoader#764c12b6]
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:785) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:717) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:365) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:350) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:298) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1061) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:567) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
... 15 common frames omitted
Caused by: java.lang.NoClassDefFoundError: Lcom/imricki/movie/persistence/repository/MovieRepository;
at java.lang.Class.getDeclaredFields0(Native Method) ~[na:1.8.0_202]
at java.lang.Class.privateGetDeclaredFields(Class.java:2583) ~[na:1.8.0_202]
at java.lang.Class.getDeclaredFields(Class.java:1916) ~[na:1.8.0_202]
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:780) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.imricki.movie.persistence.repository.MovieRepository
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_202]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_202]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_202]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_202]
... 25 common frames omitted
I solved the problem by adding component scan in the main class
#SpringBootApplication(scanBasePackages = { "com" })
#EntityScan(basePackages = { "com" })
public class SpringBootAplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootAplication.class, args);
}
}
this way spring has a common base package in all the maven modules in witch it scans for the components.
Seems that main issue is lack of MovieRepository implementation
Caused by: java.lang.ClassNotFoundException: com.imricki.movie.persistence.repository.MovieRepository
you didn't provide pom.xml so it's not possible to verify that all dependencies are correct, but I suspect you may lack of #EnableJpaRepositories annotation
more about this annotation here and in this SO question
Example:
#Configuration
#EnableJpaRepositories("com.acme.repositories")
class ApplicationConfiguration {
#Bean
EntityManagerFactory entityManagerFactory() {
// …
}
}
You need to scan the packages. By adding #componentScan annotation