|
|
No WebApplicationContext found: no ContextLoaderListener registered?
Heya guys!
I've seen this question posted here a couple of times, though no matter how hard I've tried, I can't seem to solve it.
Basically, I'm trying to create a DB object and insert it into a Derby-database.
As far as I can see I've identified the problem to the transaction-manager (following rows)
lt;filtergt; lt;filter-namegt;transactionFilterlt;/filter-namegt; lt;filter-classgt;org..web.filter.DelegatingFil terProxylt;/filter-classgt; lt;/filtergt;
lt;filter-mappinggt; lt;filter-namegt;transactionFilterlt;/filter-namegt; lt;servlet-namegt;news-servicelt;/servlet-namegt; lt;/filter-mappinggt;
If i remove these lines, everything works fine and I can yet again access the form page (where i input the data to be added to the database).
Though with these rows I can't even access the form-page.
Is there anyone that can help me?
Cheers, and keep up the great work everyone!
Are you perchance trying to use a DelegatingFilterProxy without even defining a Spring application context for your web app? Because that's what it looks like from your config and exception...if that's the case, I strongly suggest spending some more time on learning what Spring is and how to use it properly.
If it's not the case, then post your configuration (full web.xml and applicationContext.xml) and we'll figure out what's wrong.
I have added this to my web.xml, but it doesnt seem to work anyways. And yes, I am a novice when it comes to spring.
I'm not really sure if it is my quot;news-service-servletquot; that is to be specified as lt;param-valuegt;.lt;context-paramgt;
lt;param-namegt;contextConfigLocationlt;/param-namegt;
lt;param-valuegt;WEB-INF/news-service-servlet.xmllt;/param-valuegt;
lt;/context-paramgt;
lt;listenergt;
lt;listener-classgt;org..web.context.ContextLoade rListenerlt;/listener-classgt;
lt;/listenergt;
lt;listenergt;
lt;listener-classgt;org..web.context.request.Requ estContextListenerlt;/listener-classgt;
lt;/listenergt;
Code:
lt;filter-classgt;org..web.filter.DelegatingFil terProxylt;/filter-classgt;
As the package specifies, DelegatingFilterProxy is conceived to be used with and only with Spring Web MVC (aka controllers, annotated or not). It can't be used with plain servlet-jsps, as it seems you are trying to do. So to make it work you need:
- 1 application context loaded through listener pretty much like you've done(if you call the file applicationContext.xml and put it in /WEB-INF, you don't even need to specify its location with a context param):
Code:
lt;listenergt;
lt;listener-classgt;org..web.context.ContextLoaderListenerlt;/listener-classgt;
lt;/listenergt;
- 1 Spring web mvc's DispatcherServlet defined in web xml, loaded at startup, and mapped to take care of all ucls for your web application. This servlet will define its own servlet context (so you will need another xml file):
Code: lt;servletgt;
lt;servlet-namegt;springlt;/servlet-namegt;
lt;servlet-classgt;org..web.servlet.DispatcherServletlt;/servlet-classgt;
lt;init-paramgt; lt;param-namegt;contextConfigLocationlt;/param-namegt; lt;param-valuegt;WEB-INF//yourapp-servlet.xmllt;/param-valuegt;
lt;/init-paramgt;
lt;load-on-startupgt;1lt;/load-on-startupgt; lt;/servletgt;
- The dispatcher-servlet context will be child of the application context and thus it will be able to access all its beans. In the dispatcher-servlet context you will define everything related to Spring web MVC (lt;mvc:annotation-driven/gt;, interceptors, view resolvers, exception resolvers, context:component-scan for controllers package, aop that you want applied to controllers, etc.);
- In the main application context you will define all that's non-mvc related (for example your persistence configuration, scanning for services and dao packages etc.).
Once you've properly configured Spring and Spring web MVC following my instructions, you must learn to use Spring web MVC properly (annotations, form tags, ucl mappings etc.) and THEN you can use DelegatingFilterProxy properly...
Heya mate, thanks for all your input, I finally solved the problem
Once again, thanks! |
|