Discussions

Web tier: servlets, JSP, Web frameworks: Struts TagUtils.retrieveMessageResources

  1. Struts TagUtils.retrieveMessageResources (1 messages)

    I'm getting following error on JBoss:-
    =====================================================================
    00:26:27,474 ERROR [Engine] StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
            at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
            at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
            at java.lang.Thread.run(Thread.java:534)
    00:26:27,474 ERROR [Engine] ----- Root Cause -----
    java.lang.NullPointerException
            at org.apache.struts.taglib.TagUtils.retrieveMessageResources(TagUtils.java:1175)
            at org.apache.struts.taglib.TagUtils.message(TagUtils.java:1038)
            at org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:224)
            at org.apache.jsp.login_jsp._jspx_meth_bean_message_0(login_jsp.java:102)
            at org.apache.jsp.login_jsp._jspService(login_jsp.java:68)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
            at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
            at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
            at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
            at java.lang.Thread.run(Thread.java:534)

    =====================================================================

    I'm using following code:-

    1) struts-config.xml

    <?xml version="1.0" encoding="ISO-8859-1" ?>

    <!DOCTYPE struts-config PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
              "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">

    <struts-config>

        <global-exceptions>
            <exception
             key = "global.error.invalidlogin"
             path = "/login.jsp"
             scope = "request"
             type = "com.oreilly.struts.banking.service.InvalidLoginException"/>
        </global-exceptions>

        <global-forwards>
            <forward name = "SystemFailure" path = "/systemerror.jsp"/>
            <forward name = "SessionTimeOut" path = "/sessiontimeout.jsp"/>
        </global-forwards>

        <action
         path = "/login"
         type = "com.oreilly.struts.banking.action.LoginAction"
         scope = "request"
         name = "loginForm"
         validate = "true"
         input = "/login.jsp">
         <forward name = "Success" path = "/home.jsp" redirect = "true"/>
         <forward name = "Failure" path = "/login.jsp" redirect = "true"/>
        </action>

        <action
         path = "/logout"
         type = "com.oreilly.struts.banking.action.LogoutAction"
         scope = "reuest">
         <forward name = "Success" path = "/login.jsp" redirect = "true"/>
        </action>

        <form-beans>
            <form-bean
             name = "loginForm"
             type = "com.oreilly.struts.banking.form.LoginForm"/>
            <form-bean
              name = "accountInformationForm"
              type = "org.apache.struts.action.DynaActionForm">
              <form-property name = "accounts" type = "java.util.ArrayList"/>
            </form-bean>
            <form-bean
            name = "accountDetailForm"
            type = "org.apache.struts.action.DynaActionForm">
            <form-property name = "view" type = "com.oreilly.struts.banking.view.AccountDetailView"/>
            </form-bean>
        </form-beans>

        <message-resources parameter="BaseResources" null="false" scope="application"/>
    </struts-config>

    2)web.xml

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
        "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">

    <web-app>
        <servlet>
            <servlet-name>simpleloginapp</servlet-name>
            <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
            <init-param>
                <param-name>config</param-name>
                <param-value>/WEB-INF/struts-config.xml</param-value>
            </init-param>
            <init-param>
                <param-name>host</param-name>
                <param-value>localhost</param-value>
            </init-param>
            <init-param>
                <param-name>port</param-name>
                <param-value>7001</param-value>
            </init-param>
        </servlet>
        <servlet-mapping>
            <servlet-name>simpleloginapp</servlet-name>
            <url-pattern>*.do</url-pattern>
        </servlet-mapping>
        <taglib>
            <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
            <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
            <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
            <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
        </taglib>
    </web-app>

    3)login.jsp

    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>

    <html:html>
    <% System.out.println("Hello++++333++");%>
        <head>
            <title><bean:message key="title.login"/></title>
        </head>
    <% System.out.println("Hello---------------");%>
        <body>
        suneel
        </body>
    </html:html>

    4) BaseResources.properties

    title.login = Struts Online Banking

    I'm accessing login.jsp via http://localhost:8081/SimpleLoginApp/login.jsp


    Please help !

    Thanks,
    Suneel.
  2. request not ruest[ Go to top ]

    You have an error in your logout action, scope = "request" instead of "reuest".

    <action
         path = "/logout"
         type = "com.oreilly.struts.banking.action.LogoutAction"
         scope = "reuest">
         <forward name = "Success" path = "/login.jsp" redirect = "true"/>
        </action>