Please answer these questions before submitting your issue.
3.2.5
Fedora 26 x64
[soi@master target]$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
[soi@master target]$ java -javaagent:/home/soi/ops/skywalking/skywalking-agent/skywalking-agent.jar -jar spring-boot-thymeleaf-1.0.0-SNAPSHOT.war
DEBUG 2017-11-26 20:33:12 AgentPackagePath : The beacon class location is jar:file:/home/soi/ops/skywalking/skywalking-agent/skywalking-agent.jar!/org/skywalking/apm/agent/core/boot/AgentPackagePath.class.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.4.RELEASE)
2017-11-26 20:33:13.795 INFO 9839 --- [ main] pl.codeleak.demos.sbt.Application : Starting Application v1.0.0-SNAPSHOT on master.soi.io with PID 9839 (/home/soi/java/spring-boot-thymeleaf/target/spring-boot-thymeleaf-1.0.0-SNAPSHOT.war started by soi in /home/soi/java/spring-boot-thymeleaf/target)
2017-11-26 20:33:13.799 INFO 9839 --- [ main] pl.codeleak.demos.sbt.Application : No active profile set, falling back to default profiles: default
2017-11-26 20:33:14.325 INFO 9839 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1283bb96: startup date [Sun Nov 26 20:33:14 CST 2017]; root of context hierarchy
2017-11-26 20:33:16.888 INFO 9839 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8180 (http)
2017-11-26 20:33:16.903 INFO 9839 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-11-26 20:33:16.904 INFO 9839 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-11-26 20:33:17.603 INFO 9839 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-11-26 20:33:17.604 INFO 9839 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3283 ms
2017-11-26 20:33:17.919 INFO 9839 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'metricsFilter' to: [/*]
2017-11-26 20:33:17.919 INFO 9839 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-11-26 20:33:17.919 INFO 9839 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-11-26 20:33:17.919 INFO 9839 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-11-26 20:33:17.920 INFO 9839 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-11-26 20:33:17.924 INFO 9839 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2017-11-26 20:33:17.924 INFO 9839 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2017-11-26 20:33:17.924 INFO 9839 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*]
2017-11-26 20:33:17.924 INFO 9839 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-11-26 20:33:18.002 WARN 9839 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'thymeleafTextTemplates' defined in URL [jar:file:/home/soi/java/spring-boot-thymeleaf/target/spring-boot-thymeleaf-1.0.0-SNAPSHOT.war!/WEB-INF/classes!/pl/codeleak/demos/sbt/thymeleaf/ThymeleafTextTemplates.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [pl.codeleak.demos.sbt.thymeleaf.ThymeleafTextTemplates]: No default constructor found; nested exception is java.lang.NoSuchMethodException: pl.codeleak.demos.sbt.thymeleaf.ThymeleafTextTemplates.<init>()
2017-11-26 20:33:18.006 INFO 9839 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2017-11-26 20:33:18.543 INFO 9839 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-11-26 20:33:18.550 ERROR 9839 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'thymeleafTextTemplates' defined in URL [jar:file:/home/soi/java/spring-boot-thymeleaf/target/spring-boot-thymeleaf-1.0.0-SNAPSHOT.war!/WEB-INF/classes!/pl/codeleak/demos/sbt/thymeleaf/ThymeleafTextTemplates.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [pl.codeleak.demos.sbt.thymeleaf.ThymeleafTextTemplates]: No default constructor found; nested exception is java.lang.NoSuchMethodException: pl.codeleak.demos.sbt.thymeleaf.ThymeleafTextTemplates.<init>()
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1155) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE]
at pl.codeleak.demos.sbt.Application.main(Application.java:12) [classes!/:1.0.0-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [spring-boot-thymeleaf-1.0.0-SNAPSHOT.war:1.0.0-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [spring-boot-thymeleaf-1.0.0-SNAPSHOT.war:1.0.0-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [spring-boot-thymeleaf-1.0.0-SNAPSHOT.war:1.0.0-SNAPSHOT]
at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59) [spring-boot-thymeleaf-1.0.0-SNAPSHOT.war:1.0.0-SNAPSHOT]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [pl.codeleak.demos.sbt.thymeleaf.ThymeleafTextTemplates]: No default constructor found; nested exception is java.lang.NoSuchMethodException: pl.codeleak.demos.sbt.thymeleaf.ThymeleafTextTemplates.<init>()
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1147) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
... 25 common frames omitted
Caused by: java.lang.NoSuchMethodException: pl.codeleak.demos.sbt.thymeleaf.ThymeleafTextTemplates.<init>()
at java.lang.Class.getConstructor0(Class.java:3082) ~[na:1.8.0_144]
at java.lang.Class.getDeclaredConstructor(Class.java:2178) ~[na:1.8.0_144]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:80) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
... 26 common frames omitted
This issue cause by weaved the Controller code. The Skywalking agent generate another constructor if the class has interceptor constructor. and Spring create bean instance by default constructor if the bean has multi constructors.
Here is the code of spring class org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
if (candidateConstructors == null) {
.....
} else if (rawCandidates.length == 1 && rawCandidates[0].getParameterTypes().length > 0) {
candidateConstructors = new Constructor<?>[] {rawCandidates[0]};
} else {
candidateConstructors = new Constructor<?>[0];
}
@ycrxun This bug is a conflict, caused by our class manipulate mechanism. We will provide a fix in next version.
fixed this issue in PR: #624, close it
@ycrxun #624 has been merged. If you are in hurry, please download the master branch, run mvn clean package. Then you can find the apm-spring-core-patch-*.jar in /packages/skywalking-agent/plugins folder. Copy it to and remove the old one in your agent folder. You can check the bug is fixed or not.
We tested it in our own sample applications. You can do yours. Make sure it is good enough for you.
Most helpful comment
This issue cause by weaved the Controller code. The Skywalking agent generate another constructor if the class has interceptor constructor. and Spring create bean instance by default constructor if the bean has multi constructors.
Here is the code of spring class
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor