Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring logs a nasty looking stack trace for unhandled classpath URL [SPR-17417] #21950

Closed
spring-projects-issues opened this issue Oct 21, 2018 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

rsmckinney opened SPR-17417 and commented

Manifold adds a URL with custom protocol, manifoldclass: to the classpath, which is supported by URLClassLoader.  However, Spring assumes classpath URLs are file-based when it scans the classpath during SpringApplication.run()

If Spring encounters a URL that is not file-based, it throws a FileNotFoundException it subsequently catches and logs a warning.  But it still logs the stack trace to the console, which is alarming if not misleading.

Better:  omit the stack trace from the warning message. 

Best:  provide an API or convention to handle a non-file protocol, or exclude it from the scan.

Log

 :: Spring Boot ::        (v2.0.6.RELEASE) :: Spring Boot ::        (v2.0.6.RELEASE)
2018-10-20 11:48:01.252  INFO 18328 — [           main] com.example.demo.DemoApplication         : Starting DemoApplication on LAPTOP-1OGNGP8A with PID 18328 (C:\Temp\spring\demo\demo\target\classes started by scott in C:\Temp\spring\demo\demo)2018-10-20 11:48:01.258  INFO 18328 — [           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default2018-10-20 11:48:01.313  INFO 18328 — [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1f97cf0d: startup date [Sat Oct 20 11:48:01 PDT 2018]; root of context hierarchy2018-10-20 11:48:01.413  *WARN 18328 — [           main] .i.s.PathMatchingResourcePatternResolver : Cannot search for matching files underneath URL [manifoldclass://414493378/com/example/demo/] because it does not correspond to a directory in the file system*
java.io.FileNotFoundException: URL [manifoldclass://414493378/com/example/demo/] cannot be resolved to absolute file path because it does not reside in the file system: manifoldclass://414493378/com/example/demo/ at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:217) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:131) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.core.io.UrlResource.getFile(UrlResource.java:225) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:697) [spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:510) [spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:282) [spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1307) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.support.GenericApplicationContext.getResources(GenericApplicationContext.java:233) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:421) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:316) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:275) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:288) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:202) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:170) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:271) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:91) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:692) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:530) [spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:12) [classes/:na]
2018-10-20 11:48:01.931  INFO 18328 — [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup2018-10-20 11:48:01.944  INFO 18328 — [           main] com.example.demo.DemoApplication         : Started DemoApplication in 1.088 seconds (JVM running for 2.041)


Affects: 4.3.20, 5.0.10

Reference URL: manifold-systems/manifold#22

Backported to: 5.0.11, 4.3.21

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

A stacktrace is indeed not necessary there, and inconsistent with other log output in PathMatchingResourcePatternResolver where we just include Exception.toString() in the log message. Also, WARN level is arguably too high for a plain file-not-found case; INFO should be easily sufficient there, or even DEBUG in the 5.1 line's revised use of log levels. The only case for a higher log level is any other I/O exception coming out of getFile() at that point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants