Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4723

s:url incompatible with JDK 1.5

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Not A Problem
    • 2.3.28, 2.3.29, 2.3.30, 2.3.31
    • 6.0.0
    • Core, Core Tags
    • None
    • JBoss 4.3 on JDK 1.5

    Description

      problem: s:url tag on an application server running on JDK 1.5 (ex. JBoss 4.3) fails in some cases due to an incompatibility with JDK in class org.apache.struts2.util.tomcat.buf.UDecoder. Here an error stracktrace:

      ava.lang.NoSuchMethodError: java.lang.String.getBytes(Ljava/nio/charset/Charset;)[B
      at org.apache.struts2.util.tomcat.buf.UDecoder.URLDecode(UDecoder.java:328)
      at org.apache.struts2.util.tomcat.buf.UDecoder.URLDecode(UDecoder.java:302)
      at org.apache.struts2.util.URLDecoderUtil.decode(URLDecoderUtil.java:19)
      at org.apache.struts2.views.util.DefaultUrlHelper.decode(DefaultUrlHelper.java:286)
      at org.apache.struts2.views.util.DefaultUrlHelper.parseQueryString(DefaultUrlHelper.java:311)
      at org.apache.struts2.components.ServletUrlRenderer.includeGetParameters(ServletUrlRenderer.java:288)
      at org.apache.struts2.components.ServletUrlRenderer.beforeRenderUrl(ServletUrlRenderer.java:261)
      at org.apache.struts2.components.PortletUrlRenderer.beforeRenderUrl(PortletUrlRenderer.java:204)
      at org.apache.struts2.components.URL.start(URL.java:142)
      at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54)
      at org.apache.jsp.jsp.cpRicercaPercorso_jsp._jspx_meth_s_005furl_005f0(cpRicercaPercorso_jsp.java:1848)
      ...
      

      The code is:

      public static String URLDecode(String str, String enc, boolean isQuery) {
              if (str == null)
                  return (null);
      
              // use the specified encoding to extract bytes out of the
              // given string so that the encoding is not lost. If an
              // encoding is not specified, use ISO-8859-1
              byte[] bytes = null;
              try {
                  if (enc == null) {
                      bytes = str.getBytes("ISO-8859-1");
                  } else {
                      bytes = str.getBytes(B2CConverter.getCharset(enc));
                  }
              } catch (UnsupportedEncodingException uee) {
                  if (log.isDebugEnabled()) {
                      log.debug("Unable to URL decode the specified input since the encoding "+ enc + " is not supported.", uee);
                  }
              }
      
              return URLDecode(bytes, enc, isQuery);
      
          }
      

      Struts2 (ex. v. 2.3.31) is compiled with target JDK 1.5 but, method getBytes(Charset) is only available since JDK 1.6.

      I suppose that this should be considered a bug because I suppose that Struts2 2.3.31, being compiled with target 1.5, should be considered compatible with JDK 1.5... but maybe this is a wrong assumption. I didn't find any explicit compatibility matrix on docs...

      The problem was not present in v. 2.3.24.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mauroant mauro antonaci
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: