-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Component scanning does not find sub-packages in EAR on Weblogic 12.2.x [SPR-14187] #18758
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
Comments
Juergen Hoeller commented Could it be that you have several jars containing |
Robson Vargas Farias commented Hi, yes, I have some jars containing same base package-base. I've just tried: <context:component-scan base-package="classpath*:com.test.beans" /> but, didn´t works. I've checked that the content from the variable resolvableDependencies (on DefaultListableBeanFactory class) does not contains the instances loaded. |
Robson Vargas Farias commented honestly, I strip my application (other jars with same package, removed third-part jars, removed all other spring configs, etc.) and keep only the enough files (MDB and the injectable bean) to run it and still doesnt work. |
Juergen Hoeller commented The problem is not in |
Robson Vargas Farias commented
I found the problem but not sure about the solution yet, see: for this class.method: PatchMatchingResourcePatternResolver.findAllClassPathResources weblogic is returning a weblogic.utils.classloaders.ResourceEnumeration value from its class loader (weblogic.utils.classloaders.GenericClassLoader) and this one is not able to load the path "com/test/beans/", hence there is no elements in resourceUrls variable (i.e. resourceUrls.hasMoreElements() = false). is this helpful ? |
Juergen Hoeller commented If that is the case, then WebLogic's |
Robson Vargas Farias commented I did several tests and I can confirm that the problem is with the Weblogic's 12c ClassLoader, also, I did a test using a +local code+ (which uses sun.misc.CompoundEnumeration enumeration from LauncherAPP ClassLoader and it works fine once I have some resources into subdirectories( I'll open a SR on Oracle Metalink in order to get them a clarification about this issue and keep you in touch. |
Robson Vargas Farias commented btw, I've here another important input: if I put the below code on my "onMessage" method from my MDB, it result in a good enumeration with elements. Enumeration<URL> resourceUrls = Thread.currentThread().getContextClassLoader().getResources("com/test/beans/");
while (resourceUrls.hasMoreElements()) {
URL url = resourceUrls.nextElement();
System.out.println(new UrlResource(url));
} but, the spring side code, which uses ClassLoader *from org.springframework.context.support.ClassPathXmlApplicationContext *in PatchMatchingResourcePatternResolver via getClassLoader method does not working (resourceUrls.hasMoreElements() = false): protected Resource[] findAllClassPathResources(String location) throws IOException {
String path = location;
if (path.startsWith("/")) {
path = path.substring(1);
}
ClassLoader cl = getClassLoader();
Enumeration<URL> resourceUrls = (cl != null ? cl.getResources(path) : ClassLoader.getSystemResources(path));
Set<Resource> result = new LinkedHashSet<Resource>(16);
while (resourceUrls.hasMoreElements()) {
URL url = resourceUrls.nextElement();
result.add(convertClassLoaderURL(url));
}
return result.toArray(new Resource[result.size()]);
} for both the same ClassLoader is loaded.. weblogic.utils.classloaders.GenericClassLoader@xpto finder: weblogic.utils.classloaders.CodeGenClassFinder@xpto annotation: TestAPP@ |
Lorenzo Gatti commented Any update for this issue? Is there any workaround? |
Lorenzo Gatti commented For others with the same problem: put a java class (simple, not a spring bean) in the root package permits to the classloader to retrieve the jar. |
Bulk closing outdated, unresolved issues. Please, reopen if still relevant. |
Robson Vargas Farias opened SPR-14187 and commented
I've an EAR application which contains a simple message-driven bean that receive data from a queue on weblogic; this MDB is intercepted by SpringBeanAutowiringInterceptor in order to inject a
@Autowired
bean, but, I'm receiving an exception:Caused By: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.test.beans.bo.SampleBO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {
@org
.springframework.beans.factory.annotation.Autowired(required=true)}My configuration is:
The strange is: if I change the base package to the exactly package where my bean is on it works fine. Sample:
Suggesting that the issue is related to the sub-packages scanning.
my ref context:
my app config:
Tested on: Weblogic version: 12.2.x and lastest versions of Spring 4.x and 5.x (as shared libraries)
Affects: 4.1.7
Issue Links:
1 votes, 4 watchers
The text was updated successfully, but these errors were encountered: