vysh
vysh

Reputation: 166

javax.servlet.jsp.JspTagException: No message found under code 'errors.contact.sysadmin.msg' for locale 'en_US'.]

I have configured my message resources like this:

tradelc-servlet.xml

<bean id="messageSource"
          class="org.springframework.context.support.ResourceBundleMessageSource">
          <property name="basename" value="WEB-INF/classes/resources/application" />
   </bean>

I also tried

<bean id="messageSource"
              class="org.springframework.context.support.ResourceBundleMessageSource">
              <property name="basename" value="resources.resources.application" />
       </bean>

I initially did not have application_en.properties.xml at all. But I followed this input and created one in tomcat classes folder, src and target folders.

But still I am getting the same error.

org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [tradelc] in context with path [/tradelc] threw exception [javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'errors.contact.sysadmin.msg' for locale 'en_US'.] with root cause
javax.servlet.jsp.JspTagException: No message found under code 'errors.contact.sysadmin.msg' for locale 'en_US'.
       at org.springframework.web.servlet.tags.MessageTag.doEndTag(MessageTag.java:202)
       at org.apache.jsp.WEB_002dINF.jsp.errors.general_jsp._jspx_meth_spring_005fmessage_005f0(general_jsp.java:141)
       at org.apache.jsp.WEB_002dINF.jsp.errors.general_jsp._jspService(general_jsp.java:89)
       at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
       at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
       at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
       at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
       at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:746)
       at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
       at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:868)
       at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
       at org.apache.jsp.WEB_002dINF.jsp.menu_jsp._jspService(menu_jsp.java:296)
       at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
       at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
       at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
       at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
       at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:209)
       at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:266)
       at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1225)
       at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1012)
       at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
       at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
       at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931)
       at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:822)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
       at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
       at com.bankofny.inx.omx.lc.web.action.CharsetFilter.doFilter(CharsetFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
       at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
       at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
       at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)

Kindly help

Upvotes: 4

Views: 22924

Answers (4)

mohamad syed
mohamad syed

Reputation: 29

I actually solved the same problem in my java config class by simply setting the basename as follows

messageSource. setBasename("WEB-INF/classes/resources/messages"); where resources is the package under which lies my properties files named messages.properties and messages_es.properties.

Upvotes: -1

ArifMustafa
ArifMustafa

Reputation: 4965

Suppose my messages.properties class is inside the src/main/resources, which is a maven defined directory.

properties_file_located_inside_maven_mvc_project

messages.properties contains values like following:

person.name=Person Name
person.age=Person Age
person.address=Person Address

so, I have created the messageSource bean inside DispatcherServlet configuration file like below said using property schema xmlns:p="http://www.springframework.org/schema/p":

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" p:basename="messages"/>

and I will fetch the properties values in jsp file using spring taglib like:

jsp declaration above html tag:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

body content will like:

<form:form commandName="person">
    <table>
        <tr>
            <td><spring:message code="person.name" /></td>
            <td><form:input path="personName"/></td>
        </tr>

        <tr>
            <td><spring:message code="person.age" /></td>
            <td><form:input path="age"/></td>
        </tr>

        <tr>
            <td><spring:message code="person.address" /></td>
            <td><form:input path="address"/>
            </td>
        </tr>

        <tr>
            <td  colspan="2">
                <input type="submit" value="Set Person Details"/>
            </td>
        </tr>
    </table>
</form:form>

and by performing these steps, I am pretty sure, your javax.servlet.jsp.JspTagException have resolved.

Upvotes: 3

Dila Gurung
Dila Gurung

Reputation: 1774

The simple solution, will be to add property file under
"src/main/resource" directory and to access it simply configure    "DispatcherServlet-context.xml" file like this

<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="name_of_the_resource_file" />
</bean>

Upvotes: 0

Alexander
Alexander

Reputation: 3035

You have to provide the basename naming conventions (http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/support/ResourceBundleMessageSource.html#setBasename-java.lang.String- and http://docs.oracle.com/javase/8/docs/api/java/util/ResourceBundle.html), you'll see that the basename is wrong - you neither should provide the WEB-INF/- part, nor the resources part.

Let's assume that your ResourceBundle is a PropertyResourceBundle and consists of the two files

  • src/main/resources/application.properties and
  • src/main/resources/application_en.properties

If your project is packed by maven and if the files lands in the directory <webapp-dir>/WEB-INF/classes/, the your basename should merely be application, because WEB-INF/classes is where the Classloader finds its classes (kind of it's root dir).

BTW: You should not name a properties file .XML when it isn't an XML file. Did you really call the file application_en.properties.xml??

Upvotes: 1

Related Questions