无效的版本号:版本号可能为负数或大于255。

huangapple go评论92阅读模式
英文:

Invalid version number: Version number may be negative or greater than 255

问题

以下是翻译好的内容:

在我尝试访问应用程序中的一个页面时,出现了以下错误:

严重: 为jsp]提供的Servlet.service()抛出异常
java.lang.IllegalArgumentException: 无效的版本号:版本号可以是负数或大于255
	位于com.ibm.icu.util.VersionInfo.getInstance(VersionInfo.java:191)
	位于com.ibm.icu.impl.ICUDebug.getInstanceLenient(ICUDebug.java:65)
	位于com.ibm.icu.impl.ICUDebug.<clinit>(ICUDebug.java:69)

我认为这可能是由于某个版本不匹配导致的。我该如何追踪这个问题?该应用程序没有使用Maven构建,因此我不确定如何检查这个问题。至少,如果我知道是哪个jar文件引起了问题,那就好办了。

英文:

I am getting below error when I try to access a page in my application.

SEVERE: Servlet.service() for servlet [jsp] threw exception
java.lang.IllegalArgumentException: Invalid version number: Version number may be negative or greater than 255
	at com.ibm.icu.util.VersionInfo.getInstance(VersionInfo.java:191)
	at com.ibm.icu.impl.ICUDebug.getInstanceLenient(ICUDebug.java:65)
	at com.ibm.icu.impl.ICUDebug.&lt;clinit&gt;(ICUDebug.java:69)

I assume that it is due to some version mismatch. How can I trace the issue? The application is not mavenized and hence I am not sure how to check the issue. Atleast if I know which jarfile is giving issue then it will be good.

答案1

得分: 15

TLDR; 请将您的 icu4j.jar 文件替换为最新版本

这可能是因为您的类路径中存在较旧版本的ICU4J所致。VersionInfo 类的版本号被限制为2个字符,将版本号限制为255。由于Java 8现在是1.8.0_291,291超出了2个字符的限制,导致了ICU4J VersionInfo异常。

ICU-21219 在ICU4J:68.1中已修复。

英文:

TLDR; replace your icu4j.jar file with the latest version.

This is likely caused by an older version of ICU4J in your classpath. The VersionInfo class was limited to 2-character version numbers, setting a limit to 255. Since Java 8 is now at 1.8.0_291, the 291 exceeds the 2-character limit, causing the ICU4J VersionInfo exception.

ICU-21219 is fixed in ICU4J:68.1

答案2

得分: 10

问题已解决,因为我降级了我的Java版本。

英文:

The problem is resolved as I downgraded my java version.

答案3

得分: 2

如果您不想升级ICU,只需在调用ICU相关内容之前调用这个小辅助函数:

/**
 * 存在一个在旧版本ICU中的bug,当JDK的补丁版本大于255时(例如在jdk 1.8.0_261中),会阻止ICU正常工作。
 * 为了解决这个问题,我们会改变本地版本号,初始化ICU,然后再改回来。
 */
private void icuHack() {
    String javaVersion = System.getProperty("java.version");
    int idxOfUnderscore = javaVersion.indexOf('_');
    if (idxOfUnderscore == -1) {
        return;
    }
    int patchVersion = Integer.parseInt(javaVersion.substring(idxOfUnderscore + 1));
    if (patchVersion < 256) {
        return;
    }
    log.info("Java版本'" + javaVersion + "'包含补丁版本>255,需要进行ICU hack。");
    System.setProperty("java.version", "1.8.0_254");
    new com.ibm.icu.impl.ICUDebug();
    System.setProperty("java.version", javaVersion);
}

注意:本文中的代码部分已按照您的要求不进行翻译。

英文:

If you don't want to upgrade ICU just call this little helper function before the ICU stuff get's called:

/**
 * There is a bug in an old ICU version that stops ICU from working when the JDK patch version is larger than 
 * 255 (like in jdk 1.8.0_261). To work around that we change the local version number, init ICU and change it
 * back then.
 */
private void icuHack() {
	String javaVersion = System.getProperty(&quot;java.version&quot;);
	int idxOfUnderscore = javaVersion.indexOf(&#39;_&#39;);
	if( idxOfUnderscore == -1 ) {
		return;
	}
	int patchVersion = Integer.parseInt(javaVersion.substring(idxOfUnderscore+1));
	if( patchVersion &lt; 256 ) {
		return;
	}
	log.info(&quot;Java version &#39;&quot;+javaVersion+&quot;&#39; contains patch version &gt;255, need to do ICU hack.&quot;);
	System.setProperty(&quot;java.version&quot;, &quot;1.8.0_254&quot;);
	new com.ibm.icu.impl.ICUDebug();
	System.setProperty(&quot;java.version&quot;, javaVersion);
}

答案4

得分: 1

我知道这是一个不太正规的方法,但将“java.version”属性设置为一个不包含大于255的数字的版本对我起了作用:

System.setProperty("java.version", "1.8.0_254");

只需要在类被加载(首次访问)之前设置它,然后在恢复原始值。并且向库的作者报告一个错误,因为这只是一个权宜之计。

英文:

Well, I know it is a dirty hack but setting the "java.version" property to a version that doesn't contain numbers >255 worked for me:

System.setProperty(&quot;java.version&quot;, &quot;1.8.0_254&quot;);

Just set it before the class is loaded (first access) and restore the original value afterwards. And file a bug to the author of the library since this is just a workaround.

答案5

得分: 1

我通过排除旧的icu4j包来解决了这个问题,例如:

<dependency>
    <groupId>jaxen</groupId>
    <artifactId>jaxen</artifactId>
    <version>1.1.6</version>
    <exclusions>
        <exclusion>
            <groupId>com.ibm.icu</groupId>
            <artifactId>icu4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>

然后引用最新的icu4j包:

<dependency>
    <groupId>com.ibm.icu</groupId>
    <artifactId>icu4j</artifactId>
    <version>68.2</version>
</dependency>
英文:

I solved this problem by excluding old icu4j package,eg:

    &lt;dependency&gt;
        &lt;groupId&gt;jaxen&lt;/groupId&gt;
        &lt;artifactId&gt;jaxen&lt;/artifactId&gt;
        &lt;version&gt;1.1.6&lt;/version&gt;
        &lt;exclusions&gt;
            &lt;exclusion&gt;
                &lt;groupId&gt;com.ibm.icu&lt;/groupId&gt;
                &lt;artifactId&gt;icu4j&lt;/artifactId&gt;
            &lt;/exclusion&gt;
        &lt;/exclusions&gt;
    &lt;/dependency&gt;

then refer to the latest icu4j package:

    &lt;dependency&gt;
        &lt;groupId&gt;com.ibm.icu&lt;/groupId&gt;
        &lt;artifactId&gt;icu4j&lt;/artifactId&gt;
        &lt;version&gt;68.2&lt;/version&gt;
    &lt;/dependency&gt;

答案6

得分: 0

我通过从8.0.0.0更新到9.1.0.0来解决了这个问题。

<dependency>
  <groupId>com.ibm.ctg</groupId>
  <artifactId>ctgclient</artifactId>
  <version>9.1.0.0</version>
</dependency>
英文:

I solved the problem by updating from 8.0.0.0 to 9.1.0.0

&lt;dependency&gt;
  &lt;groupId&gt;com.ibm.ctg&lt;/groupId&gt;
  &lt;artifactId&gt;ctgclient&lt;/artifactId&gt;
  &lt;version&gt;9.1.0.0&lt;/version&gt;
&lt;/dependency&gt;

答案7

得分: 0

以下是翻译好的部分:

https://academy.jahia.com/training-kb/knowledge-base/invalid-version-number-version-number-may-be-negative-or-greater-than-255 上发布的内容:

原因
在重新启动之前,您的 JDK 很有可能已经升级到大于 255 的版本,导致库 icu4J 中的一个已知错误(详见内部工单 QA-13064)。

解决方案
如果您无法升级到 OpenJDK 11,请按照以下步骤对每个节点执行:

  1. 停止节点
  2. 重命名库
    TOMCAT_HOME/webapps/ROOT/WEB-INF/lib/icu4j-4.0.1.jar 为 .bak 后缀
  3. 在相同的文件夹中,添加库 icu4j-67.1.jar
  4. 启动节点

如果您只是升级 Java 子版本,这也适用。例如,从 1.8.0_211 升级到 1.8.0_311

英文:

As posted on https://academy.jahia.com/training-kb/knowledge-base/invalid-version-number-version-number-may-be-negative-or-greater-than-255

Cause
There is a very high probability that before the restart, your JDK has been upgraded to a version greater than 255, leading to a known bug in the library icu4J (cf internal ticket QA-13064).

Solution
If you're unable to upgrade to the OpenJDK 11, please follow these steps for each node:

  1. Stop your node
  2. Rename the library
    TOMCAT_HOME/webapps/ROOT/WEB-INF/lib/icu4j-4.0.1.jar with the suffix
    .bak
  3. In the same folder, add the library icu4j-67.1.jar
  4. Start your node

This also works if you are just upgrading Java sub version. For example from 1.8.0_211 to 1.8.0_311

答案8

得分: 0

我能够通过切换到与Jenkins兼容的Java版本来解决这个问题。请注意,以下步骤只适用于您的系统上安装了多个Java版本。所采取的步骤如下:

  1. 使用以下命令检查其他Java版本:
    sudo update-alternatives --config java

  2. 选择兼容的Java版本

  3. 重新启动Jenkins

希望能有所帮助!如果您需要进一步的解释,请随时让我知道。

英文:

I was able to solve it by switching to Java version compatible with Jenkins. Please note that below steps will only work if you have multiple Java versions installed on your system. Following are the steps taken :

  1. Check other Java version using below command:
    sudo update-alternatives --config java

  2. Select the compatible java version

  3. Restart jenkins

Hope it helps! Please let me know if you need further clarifications.

huangapple
  • 本文由 发表于 2020年9月24日 13:50:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/64040255.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定