I am using jsf and spring together in web application. I have configured datasource and session factory in one configuration class which uses annotations like @Configuration, @ComponentScan
etc. I don't have any applicationContext.xml file in my project as I am handling every entry of context xml in Configuration class. The test case works successfully but when I deploy my web application, it gives me error
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
Now if I give listener class in web.xml,
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
it gives me error,
/WEB-INF/applicationContext.xml not found
As per the document of ContextLoaderListener
, it's true that if I don't give contextConfigLocation
param in web.xml
explicitly, it will search for the default spring context file named applicationContext.xml
in web.xml
. Now, what should I do if I don't want to use spring context file and do all the configuration with annotations? How should I register listener class ContextLoaderListener
so that without use of xml file and using annotations only, I be able to run my web application with spring and jsf?