问题
We are migrating application from weblogic to jboss,
In this Spring Myfaces applications, in jboss, while loading xhtml page managed bean defined in spring and faces config xmls are not creating the beans which results in null pointer exception while application is trying to load xhtml page.
In spring applicationcontext config xml, following entry is there to scan the packages
<context:component-scan base-package="com.thehartford.pi.sales.web.controller.auto.*" >
<context:include-filter type="annotation" expression="com.thehartford.pi.sales.web.common.annotations.Controller"/>
</context:component-scan>
<context:component-scan base-package="com.thehartford.pi.sales.web.controller.home.*" >
<context:include-filter type="annotation" expression="com.thehartford.pi.sales.web.common.annotations.Controller"/>
</context:component-scan>
com.thehartford.pi.sales.web.common.annotations.Controller => This controller has following annotations
@Component
@Scope("request")
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface Controller {
public static final String EMPTY_STRING = "";
String value() default EMPTY_STRING;
}
In Weblogic, this include is helping to create beans required by myfaces config xml available in following packages
<context:include-filter type="annotation" expression="com.thehartford.pi.sales.web.common.annotations.Controller"/>
whereas in jboss these annotations are not getting ingested to controller available in those packages causing null pointer exception. This is getting resolved on explicitly including these annotations in all class defined in those packages.
Please help me understand why following filter is not working in jboss
<context:include-filter type="annotation" expression="com.thehartford.pi.sales.web.common.annotations.Controller"/>
来源:https://stackoverflow.com/questions/53947922/spring-beans-not-getting-created-as-required-by-myfaces