mauro antonaci created WW-4723:
----------------------------------
Summary: s:url incompatible with JDK 1.5
Key: WW-4723
URL: https://issues.apache.org/jira/browse/WW-4723
Project: Struts 2
Issue Type: Bug
Components: Core, Core Tags
Affects Versions: 2.3.31, 2.3.30, 2.3.29, 2.3.28
Environment: JBoss 4.3 on JDK 1.5
Reporter: mauro antonaci
Priority: Blocker
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:
{noformat}
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)
...
{noformat}
The code is:
{code:java}
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);
}
{code}
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.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)