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

AnnotationSessionFactoryBean.scanPackages() creates scanning pattern incorrectly [SPR-5324] #9997

Closed
spring-projects-issues opened this issue Nov 26, 2008 · 2 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 26, 2008

Jeremy Haile opened SPR-5324 and commented

The "scanPackages" property requires the package name to have a trailing "." which is inconsistent with the component-scan. This feature was adding by #9415

ClassPathScanningCandidateComponentProvider (used by component-scan) constructs the scanning pattern like this:
String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resolveBasePackage(basePackage) + "/" + this.resourcePattern;

AnnotationSessionFactoryBean constructs the scanning pattern like this:
String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(pkg) + RESOURCE_PATTERN;

Notice the missing "/" in the hibernate class. This means that the resource pattern is constructed like classpath*:myPackage**/.class instead of classpath:myPackage/**/*.class

This works when all persistence classes are in the package to be scanned, but fails to scan subclasses. AnnotationSessionFactoryBean should be changed to construct its pattern like component-scan does.

A workaround is to append a trailing "." onto the end of your package name.


Affects: 2.5.6

Issue Links:

Referenced from: commits 71df72d

@spring-projects-issues
Copy link
Collaborator Author

Jeremy Haile commented

I meant "fails to scan subpackages", not "fails to scan subclasses"

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Indeed - thanks for pointing this out!

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants