aspose file tools*
The moose likes Spring and the fly likes no WebApplicationContext found: no ContextLoaderListener registered? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "no WebApplicationContext found: no ContextLoaderListener registered?" Watch "no WebApplicationContext found: no ContextLoaderListener registered?" New topic
Author

no WebApplicationContext found: no ContextLoaderListener registered?

fabian verbeek
Ranch Hand

Joined: Oct 20, 2012
Posts: 52
Hi everybody,

I'm learning spring and now i want to use a form but when i come in my page that contain the form i've this :

org.apache.jasper.JasperException: An exception occurred processing JSP page /user/createUser.jsp at line 36

here is my createUser.jsp:


My web.xml


my creationUser-context.xml:
[code=xml<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan base-package="com.starterSpring.controller.user" />
<mvc:annotation-driven />

<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/user/" />
<property name="suffix" value=".jsp" />
</bean>

</beans>][/code]

My class USer:


and my controller

finally my log trace:


i'm disapointed with this issue thanks for your help
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Not sure, because there is parts in the stack trace missing from earlier in your log.

1) I noticed no @Controller on your Controller class
So it will not be instantiated as a bean

not related to your issue, but I have issue with 2) You Controller class name is bad. User isn't a Controller.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
fabian verbeek
Ranch Hand

Joined: Oct 20, 2012
Posts: 52
thanks for your advice but i've still the same error.

i've a page index.jsp that contain an iframe.
when i click on my link, i submit a form with the url : user/createUser.jsp (that's the src of my iframe)

my index.jsp


here is my web.xml


and my controller:


that's the complete log trace:


Thanks for your help
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1649
    
    7

Sounds to me like your missing something in your web.xml


[How To Ask Questions][Read before you PM me]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Yeah. I thought he wouldn't need it based on what was posted. But reading the log, there is a lot that was not posted. There was a lot more to the configurations, classes, etc. And since it wasn't posted that he had Services and other beans that would be needed in other Controllers etc, I assumed what he posted was all that was in his app.

But, if you look at the log line right above the stack trace, like line 120, it says

GRAVE: No WebApplicationContext found: no ContextLoaderListener registered?

Mark
fabian verbeek
Ranch Hand

Joined: Oct 20, 2012
Posts: 52
thanks for your replies.
but what is the difference whit <listener-class> and my <servlet-class> ? where do i put the tag listener?
Here is my complete web.xml



thanks again for your help to a noob ;-)
fabian verbeek
Ranch Hand

Joined: Oct 20, 2012
Posts: 52
Someone has an idea to help me?
maybe it comes from my url-pattern in web.xml but as i'm new, i've a lot of difficult to map correctly.

Is it correct this to intercept the url from my index.jsp that submit a form


And someone has a good tutorial to learn spring and form with sample that works to understand better.
here is the 2 samples i used but it doesn't work.

http://www.roseindia.net/tutorial/spring/spring3/web/spring-3-mvc-form-example.html
http://www.giantflyingsaucer.com/blog/?p=2395

thanks
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

"<listener-class> and my <servlet-class>"

Difference is two different ApplicationContexts created. One to store your middle tier beans, and one for your web tier beans. The servlet-class is for your web-tier beans. Controllers, ViewResolvers. the listener class creates an ApplicationContext for your middle tier beans and gets stored in the ServletContext for all Servlets to get access to it, including all your web tier beans.

In your web.xml you have a servlet-class to create an ApplicationContext for your middle tier beans that won't be accessable by your two other DispatcherServlet. That one should be with the listener-class ContextLoaderListener.

On another note. this is one web application. So you only need one DispatcherServlet in the web.xml and servlet mapping to all URLs for your application. The more specific distinct URLs are then mapped to Controller methods with your @RequestMapping in your Controllers.

Mark
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

I recommend you pick up a copy of Spring In Action 3rd edition, or the Spring documentation. Be careful of tutorials/blog posts because they tend to show bad practices, use older styles and are sometimes just wrong.

Good Luck

Mark
fabian verbeek
Ranch Hand

Joined: Oct 20, 2012
Posts: 52
thanks for your help, i downloaded the pdf spring in action 3rd edition.

So i change my code but i've an error404 with this log error:


Here is the link i call :


my web.xml:


my creationUser.xml


and my controller:


my class User

and finally my mapge createUser.jsp that is under user/


i suppose it's a silly mistake but i can't find.

thanks to unblock me
fabian verbeek
Ranch Hand

Joined: Oct 20, 2012
Posts: 52
I can do a sample that work and my mistake was the value of my @RequestMapping (my file is under the directory user.
it works with an hyperlink to the address /user/createUser.jsp but how can i do with a frame (createUSer.sjp) include in my index.jsp

thanks
 
 
subject: no WebApplicationContext found: no ContextLoaderListener registered?