Skip to Content

ClassCastException: SpringLocalizationContext cannot be cast to String

We're in the process of upgrading from SAP Commerce 1808 to 1905, and we're getting the following exception whenever we connect to the main page localhost:9002/US/en:

java.lang.ClassCastException: class org.springframework.web.servlet.support.JstlUtils$SpringLocalizationContext cannot be cast to class java.lang.String

Has anyone seen this, or have an idea as to the cause? Or any other suggestions?

I found a previous similar question, but no answer: https://answers.sap.com/questions/12767329/javalangclasscastexception-cannot-cast-class-orgsp.html

Complete stack trace below, with company name replaced with abc or Abc:

Oct 17, 2019 4:35:52 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [] threw exception [An exception occurred processing JSP page [/WEB-INF/views/desktop/pages/layout/globalHomePageTemplate.jsp] at line [7] 4: <%@ taglib prefix="common" tagdir="/WEB-INF/tags/desktop/common" %> 5: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 6: 7: 8: 9: 10:


INFO | jvm 1 | main | 2019/10/17 16:35:52.523 | Oct 17, 2019 4:35:52 PM org.apache.catalina.core.StandardWrapperValve invoke INFO | jvm 1 | main | 2019/10/17 16:35:52.523 | SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [] threw exception [An exception occurred processing JSP page [/WEB-INF/views/desktop/pages/layout/globalHomePageTemplate.jsp] at line [7] INFO | jvm 1 | main | 2019/10/17 16:35:52.523 | INFO | jvm 1 | main | 2019/10/17 16:35:52.523 | 4: <%@ taglib prefix="common" tagdir="/WEB-INF/tags/desktop/common" %> INFO | jvm 1 | main | 2019/10/17 16:35:52.523 | 5: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> INFO | jvm 1 | main | 2019/10/17 16:35:52.523 | 6: INFO | jvm 1 | main | 2019/10/17 16:35:52.523 | 7: INFO | jvm 1 | main | 2019/10/17 16:35:52.523 | 8: INFO | jvm 1 | main | 2019/10/17 16:35:52.523 | 9: INFO | jvm 1 | main | 2019/10/17 16:35:52.523 | 10:

INFO | jvm 1 | main | 2019/10/17 16:35:52.523 | INFO | jvm 1 | main | 2019/10/17 16:35:52.523 |

org.springframework.web.servlet.support.JstlUtils$SpringLocalizationContext cannot be cast to class java.lang.String Oct 17, 2019 5:03:57 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [] threw exception [javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.servlet.jsp.JspException: java.lang.ClassCastException: class org.springframework.web.servlet.support.JstlUtils$SpringLocalizationContext cannot be cast to class java.lang.String (org.springframework.web.servlet.support.JstlUtils$SpringLocalizationContext is in unnamed module of loader de.hybris.bootstrap.loader.PlatformInPlaceClassLoader @649f82a4; java.lang.String is in module java.base of loader 'bootstrap')] with root cause java.lang.ClassCastException: class org.springframework.web.servlet.support.JstlUtils$SpringLocalizationContext cannot be cast to class java.lang.String (org.springframework.web.servlet.support.JstlUtils$SpringLocalizationContext is in unnamed module of loader de.hybris.bootstrap.loader.PlatformInPlaceClassLoader @649f82a4; java.lang.String is in module java.base of loader 'bootstrap') at org.apache.taglibs.standard.tag.common.fmt.BundleSupport.getLocalizationContext(BundleSupport.java:174) at org.apache.taglibs.standard.tag.common.fmt.SetLocaleSupport.getFormattingLocale(SetLocaleSupport.java:316) at org.apache.taglibs.standard.tag.common.fmt.FormatNumberSupport.doEndTag(FormatNumberSupport.java:205) at org.apache.jsp.tag.web.desktop.common.header.header_tag._jspx_meth_fmt_005fformatNumber_005f0(header_tag.java:7131) at org.apache.jsp.tag.web.desktop.common.header.header_tag.doTag(header_tag.java:695) at org.apache.jsp.tag.web.desktop.template.page_tag._jspx_meth_header_005fheader_005f0(page_tag.java:496) at org.apache.jsp.tag.web.desktop.template.page_tag.access$3(page_tag.java:483) at org.apache.jsp.tag.web.desktop.template.page_tag$Helper.invoke4(page_tag.java:1259) at org.apache.jsp.tag.web.desktop.template.page_tag$Helper.invoke(page_tag.java:1306) at org.apache.jsp.tag.web.desktop.template.master_tag.doTag(master_tag.java:476) at org.apache.jsp.tag.web.desktop.template.page_tag._jspx_meth_template_005fmaster_005f0(page_tag.java:460) at org.apache.jsp.tag.web.desktop.template.page_tag.doTag(page_tag.java:231) at org.apache.jsp.WEB_002dINF.views.desktop.pages.layout.globalHomePageTemplate_jsp._jspx_meth_template_005fpage_005f0(globalHomePageTemplate_jsp.java:221) at org.apache.jsp.WEB_002dINF.views.desktop.pages.layout.globalHomePageTemplate_jsp._jspService(globalHomePageTemplate_jsp.java:182) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:470) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:395) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:316) at org.springframework.security.web.header.HeaderWriterFilter$HeaderWriterRequestDispatcher.forward(HeaderWriterFilter.java:143) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:170) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1370) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1116) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1055) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:329) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$StatisticsGatewayFilter.doFilter(AbstractPlatformFilterChain.java:417) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:299) at com.hybris.abc.storefront.filters.asm.AbcAssistedServiceFilter.doFilterInternal(AbcAssistedServiceFilter.java:186) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:299) at com.hybris.abc.storefront.filters.CartRestorationFilter.doFilterInternal(CartRestorationFilter.java:126) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:299) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:157) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:299) at com.hybris.abc.storefront.filters.UrlEncoderFilter.doFilterInternal(UrlEncoderFilter.java:118) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:299) at com.hybris.abc.storefront.filters.StorefrontFilter.doFilter(StorefrontFilter.java:210) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:299) at com.hybris.abc.storefront.filters.cms.CMSSiteFilter.doFilterInternal(CMSSiteFilter.java:210) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:299) at com.hybris.abc.storefront.filters.AcceleratorAddOnFilter.doFilter(AcceleratorAddOnFilter.java:90) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:299) at de.hybris.platform.servicelayer.web.SessionFilter.doFilter(SessionFilter.java:96) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:299) at de.hybris.platform.servicelayer.web.Log4JFilter.doFilter(Log4JFilter.java:44) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:299) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain.processStandardFilterChain(AbstractPlatformFilterChain.java:207) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain.doFilterInternal(AbstractPlatformFilterChain.java:184) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.hybris.abc.storefront.filters.AcceleratorAddOnFilter.doFilter(AcceleratorAddOnFilter.java:90) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at de.hybris.platform.servicelayer.web.XSSFilter.processPatternsAndDoFilter(XSSFilter.java:358) at de.hybris.platform.servicelayer.web.XSSFilter.doFilter(XSSFilter.java:306) at com.hybris.abc.storefront.filters.asm.AbcXSSFilter.doFilter(AbcXSSFilter.java:63) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:834)

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 25, 2019 at 09:00 AM

    Please try the following copy spring-webmvc-5.1.6.RELEASE.jar to your storefronts /web/webroot/WEB-INF/lib folder. This solved the problem in one of our projects. I'm currently investigating if there is a cleaner solution.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 22, 2019 at 12:46 PM

    Hi,

    can you check if you have different version of jstl.jar or spring in your project/classpath.

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Cristoph, thanks for the response. Here are all the jars in my installation with JSTL in their names:

      jstl-1.2.jar

      jstl-api-1.2.jar

      jstl-impl-1.2.jar

      javax.servlet.jsp.jstl-1.2.5.jar

      There are multiple copies of each (except the api which occurs only once)... but I've used md5 to confirm that all the jstl-1.2.jar files are identical; all the jstl-api-1.2.jar are identical; etc. The 1.2.5 in the last file looks suspicious to me, as it's close-but-different to the 1.2 in the other versions. It smells like there could be some incompatibility between the 1.2.5 file and the 1.2.0 files. However, all of these files come from the 1905 download file CXCOMM190500P_5-70004140.ZIP, not from any custom code we've added.

      Over on the spring side of things... looking through the jar I see a lot of 5.1.3 jars, some 5.1.4 and 5.1.6 as well. Again, this is all found in SAP's CXCOMM190500P_5-70004140.ZIP file. I haven't found any conflicting versions of the same specific lib. That is, no files with identical names except the numeric version. But, it's hard to tell what all is supposed to match up. Specifically, if I look for jar files that contain a SpringLocalizationContext class or java file (the one named in the error message, org.springframework.web.servlet.support.JstlUtils$SpringLocalizationContext), it's only found in one file:

      spring-webmvc-5.1.6.RELEASE.jar

      Which, again, is from the dependencies SAP bundled for us in the 1905 zip file.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.