0

I am working on an existing webapp where most of the beans are defined and discovered using xml config. There are a bunch of xml files defined and included in the contextConfigLocation param of the web.xml, thus creating the web-application context.

For some new code that I am writing I decided to use java config.

@Configuration
public class UserChannelConfiguration {

    @Autowired
    @Qualifier("deviceIOSDao")
    private DeviceIOSDao deviceIOSDao;

    @Bean
    public UserPayloadHandler defaultUserPayloadInstallationHandler() {
        return new DefaultUserPayloadInstallationHandler(deviceIOSDao);
    }
}

Since the webapp already uses xml based configuration I created a simple xml config file(ios-user-channel-service-beans.xml) which defines the above config as a bean

<bean name="userChannelConfiguration" class="com.fiberlink.mdm.ios.user_channel.UserChannelConfiguration"/>

I included this in the web.xml along with the others as mentioned at the start

 <context-param>
        <description>locations of the Spring configuration files</description>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:com/somethingelse/ios-action-service-beans.xml, <!-- contains xml definition of my bean 'deviceIOSDao' -->
            classpath:com/something/ios-user-channel-service-beans.xml <!-- contains my java config bean -->
        </param-value>
    </context-param>

Also my application-servlet.xml contains <context:annotation-config /> which is supposed to enable some spring component to process my @AutoWired annotations and inject deviceIOSDao from the web-application context.

But deviceIOSDao is not getting autowired and i get a null pointer exception when I access the same at runtime in my code.

What am I missing?

Abhijith Madhav
  • 2,748
  • 5
  • 33
  • 44

0 Answers0