Results 1 to 4 of 4

Thread: No WebApplicationContext found: who can help me with it

  1. #1
    Join Date
    May 2005
    Posts
    1

    Default No WebApplicationContext found: who can help me with it

    when i deploy this page there is one error.

    java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
    org.springframework.web.servlet.support.RequestCon textUtils.getWebApplicationContext(RequestContextU tils.java:82)
    org.springframework.web.servlet.support.RequestCon text.initContext(RequestContext.java:203)
    org.springframework.web.servlet.support.JspAwareRe questContext.initContext(JspAwareRequestContext.ja va:74)
    org.springframework.web.servlet.support.JspAwareRe questContext.<init>(JspAwareRequestContext.java:48 )
    org.springframework.web.servlet.tags.RequestContex tAwareTag.doStartTag(RequestContextAwareTag.java:6 5)
    org.apache.jsp.register_jsp._jspService(register_j sp.java:80)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:298)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:810)

    i am a fresh man to spring,who can tell me what is it?thank you!!

    register.jsp

    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
    <%@ page pageEncoding="gb2312" contentType="text/html;charset=gb2312"%>
    <html>
    <head>
    <title>用户注册</title>
    </head>
    <body style="text-align: center">
    <form method="POST" action="/register.do">
    <spring:bind path="command.*">
    <font color="#FF0000">
    <c:forEach items="${status.errorMessages}" var="error">
    错误: <c:out value="${error}"/><br>
    </c:forEach>
    </font>
    </spring:bind>
    ....... </form>
    </body>
    </html>

  2. #2
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    Did you correctly define ContextLoaderListener or ContextLoaderServlet in your web.xml? Check the JavaDoc of those classes for details.

    Erwin

  3. #3
    Join Date
    Feb 2008
    Posts
    2

    Default Problem in Struts+spring+aop

    Hi,
    I am using spring+struts application and want to apply advice on struts action classes.
    As you know there are two ways to integrate spring with struts. Either include ContextLoaderPlugIn
    in struts-config.xml or use spring Action classes.
    I am using Spring Action classes. I have given entry in web.xml as shown below:

    web.xml(either ContextLoaderListener or ContextLoaderServlet)

    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListe ner
    </listener-class>
    </listener>

    OR
    <servlet>
    <servlet-name>context</servlet-name>
    <servlet-class>
    org.springframework.web.context.ContextLoaderServl et
    </servlet-class>

    </servlet>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/beans.xml</param-value>
    </context-param>

    This is my action class:

    public class SearchSubmit extends ActionSupport {


    public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {

    DynaActionForm searchForm = (DynaActionForm) form;
    String isbn = (String) searchForm.get("isbn");

    //the old fashion way
    //BookService bookService = new BookServiceImpl();
    //ServletContext sc = getServletContext();
    ApplicationContext ctx = getWebApplicationContext();
    //ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicati onContext(sc);
    BookService bookService = (BookService) ctx.getBean("bookService");

    Book book = bookService.read(isbn.trim());
    ....
    ....

    beans.xml::

    ....
    <aop:config>
    <aop:aspect ref="LoggingAspect">
    <!-- <aopointcut id="myCutLogging" expression="execution(* ca.nexcel.books.actions.SearchSubmit.execute(..))"/> -->
    <!-- expression="execution(* ca.nexcel.books.business.BookService*.*(..))" /> -->
    <aopointcut id="myCutLogging" expression="execution(* ca.nexcel.books.business.BookService*.*(..))"/>

    <aop:around pointcut-ref="myCutLogging" method="log" />
    </aop:aspect>
    </aop:config>
    ...

    Error::

    java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
    org.springframework.web.context.support.WebApplica tionContextUtils.getRequiredWebApplicationContext( WebApplicationContextUtils.java:83)
    org.springframework.web.struts.ActionSupport.initW ebApplicationContext(ActionSupport.java:102)
    org.springframework.web.struts.ActionSupport.setSe rvlet(ActionSupport.java:78)
    org.apache.struts.action.RequestProcessor.processA ctionCreate(RequestProcessor.java:297)
    org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:220)
    org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1164)
    org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:415)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


    When i am using ContextLoaderListner then when i start the tomcat, i am getting Error Listener start
    and when i use ContextLoaderServlet, tomcat starts successfully but when i navigate in application, it throws
    excetion that WebApplicationContext is not found.Is ContextLoaderListner registered?

    Please help me to solve this issue.


    Thanks in advance.

    Mukesh

  4. #4

    Smile No WebApplicationContext found: no ContextLoaderListener registered?

    Hi all

    Please check your applicationContext.xml file .

    1. your hiperlink should be like this <a href='register.htm'.>register</a>

    2. As you click on the hiperlink ( register) your control will be redirected to applicationContext.xml file

    3. The bean configuration for register.htm in applicationContext.xml is

    <bean name="/register.htm" class="com.abcbs.icdassist.controller.UserReqister Controller">
    <property name="formView" value="personalinfo" />
    <property name="validator">
    <bean class="com.abcbs.icdassist.validator.RegisterUserV alidator"></bean>
    </property>

    </bean>

    4. The property <property name='formView" value="personalinfo"> is a jsp page in WEB-INF/jsp/personalinfo.jsp page which has the Spring validations.


    With this configuration i have solved the problem of No WebApplicationContext found: no ContextLoaderListener registered?



    I think this will help you.

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. Replies: 4
    Last Post: Aug 17th, 2005, 04:42 AM
  5. Replies: 1
    Last Post: Apr 13th, 2005, 10:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •