You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AnnotationDrivenBeanDefinitionParser uses static fields to store result of presence check for jackson, rome, jsr303 and jaxb.
Consider changing that approach to either use non-static fields or running the check when needed. Behavior of statics will be unpredictable in OSGi environment. Also consider using classloader of bean factory vs. classloader that loaded the AnnotationDrivenBeanDefinitionParser.
In what sense is this unpredictable in an OSGi environment? I would still expect those classes to be properly linked at the time of static field initialization, resolving the optional third-party dependencies if they are present. We need to use the corresponding Spring module's ClassLoader here since this is what we load our support classes with - the classes which actually depend on those third-party libraries - referenced directly in AnnotationDrivenBeanDefinitionParser itself.
Pardon my comment about statics. Was made in haste.
I did a bit more digging and here is what I see:
Class loader of AnnotationDrivenBeanDefinitionParser
KernelBundleClassLoader: [bundle=org.springframework.web.servlet_3.0.2.RELEASE]
ClassUtils.isPresent(type, classLoader) raises this exception:
Exception: ex = {com.springsource.kernel.osgi.framework.ExtendedClassNotFoundException@9099}"com.springsource.kernel.osgi.framework.ExtendedClassNotFoundException: javax.validation.Validator in KernelBundleClassLoader: [bundle=org.springframework.web.servlet_3.0.2.RELEASE]"
org.springframework.web.servlet does not import joda, javax.validation or javax.xml.bind. It does import rome and jackson.
I confirmed that jackson is resolved to "true" as I have those bundles deployed.
TCCL at the time of isPresent call is:
getDefaultClassLoader() = {com.springsource.osgi.webcontainer.tomcat.internal.loading.BundleWebappClassLoader@9066}
I have not drilled down into TCCL but I would assume that it "knows" about joda, jsr303 etc as all those packages are imported in my web-app bundle and I don't see CNF during runtime.
I guess switching to ClassUtils.isPresent(className) solves this.
Not sure if optionally importing dependencies of supporting classes in web.servlet bundle would be a better choice. It could be as manifest provides an accounting of third party dependencies that can potentially be used by web.servlet.
Dmitry Sklyut opened SPR-7291 and commented
AnnotationDrivenBeanDefinitionParser uses static fields to store result of presence check for jackson, rome, jsr303 and jaxb.
Consider changing that approach to either use non-static fields or running the check when needed. Behavior of statics will be unpredictable in OSGi environment. Also consider using classloader of bean factory vs. classloader that loaded the AnnotationDrivenBeanDefinitionParser.
Affects: 3.0.2
Referenced from: commits 89fadb9
The text was updated successfully, but these errors were encountered: