简体   繁体   English

Tomcat 7.0.73 不适用于 Java 9

[英]Tomcat 7.0.73 doesn't work with java 9

Unable to start tomcat based app with java 9 because of default "java.endorsed.dirs" option in catalina.sh.由于 catalina.sh 中的默认“java.endorsed.dirs”选项,无法使用 java 9 启动基于 tomcat 的应用程序。

-Djava.endorsed.dirs=/usr/local/share/tomcat/endorsed is not supported. Endorsed standards and standalone APIs in modular form will be supported via the concept of upgradeable modules. 
Error: Could not create the Java Virtual Machine. 
Error: A fatal exception has occurred. Program will exit.

Is there a work around for this?有解决办法吗?

You'll have to hack the script bin/catalina.sh to get this to work.您必须破解脚本bin/catalina.sh才能使其工作。

There are a bunch of lines like this in bin/catalina.sh : bin/catalina.sh有很多这样的行:

  exec "$_RUNJDB" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
    -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
    ...

Just remove the second of those lines (the one with -Djava.endorsed.dirs ) in each case and you should be back in business.只需在每种情况下删除这些行中的第二行(带有-Djava.endorsed.dirs ),您就应该重新开始工作。

I'm looking at improving those scripts so that -Djava.endorsed.dirs is not provided to the JVM when the value is empty (which should be the case if you are using Java 9).我正在考虑改进这些脚本,以便在值为空时不向 JVM 提供-Djava.endorsed.dirs (如果您使用的是 Java 9,情况应该如此)。

UPDATE 2017-11-06更新 2017-11-06

Looks liker1810284 should fix the endorsed.dirs problem.看起来r1810284应该可以修复endorsed.dirs.dirs问题。 Expect this fix to be included in Tomcat 7.0.83 (or whatever the next 7.0.x version passes voting).预计此修复程序将包含在 Tomcat 7.0.83(或下一个 7.0.x 版本通过投票的任何版本)中。

UPDATE 2018-03-07更新 2018-03-07

The first official release of Apache tomcat 7.0.x that includes this fix is Apache Tomcat 7.0.84, voted stable on 2018-01-24.包含此修复程序的 Apache tomcat 7.0.x 的第一个正式版本是 Apache Tomcat 7.0.84,于 2018 年 1 月 24 日投票为稳定版。

The above issue was fixed with the later releases of Eclipse but Unfortunately, it appeared again with the release of Java 10. Here is my research : Initially, I installed Java 10 and Eclipse Oxygen 3 which gave me the same error you mentioned in your question.上述问题在 Eclipse 的后续版本中得到了修复,但不幸的是,随着 Java 10 的发布,它再次出现。这是我的研究:最初,我安装了 Java 10 和 Eclipse Oxygen 3,这给了我你在问题中提到的相同错误. But, at the moment I installed Java 9 and pointed my Apache tomcat runtime server to it, the error was gone.但是,在我安装 Java 9 并将我的 Apache tomcat 运行时服务器指向它的那一刻,错误消失了。

To fix this bug, you need to install/update the Eclipse Web Tools Platform (WTP) to version 3.9.4 or later.要修复此错误,您需要将 Eclipse Web 工具平台 (WTP) 安装/更新到 3.9.4 或更高版本。

Select Help > Install new Software... Select or add following URL: http://download.eclipse.org/webtools/repository/oxygen Check Web Tools Platform (WTP) 3.9.4 Select "Next" and follow instructions选择帮助 > 安装新软件... 选择或添加以下 URL: http://download.eclipse.org/webtools/repository/oxygen检查 Web 工具平台 (WTP) 3.9.4 选择“下一步”并按照说明进行操作

Reconfigure the tomcat in eclipse.在eclipse中重新配置tomcat。

This symptom can come about if you have a Tomcat Runtime using a JRE earlier than Java 9 and create and run a server with that runtime.如果您有使用早于 Java 9 的 JRE 的 Tomcat 运行时并使用该运行时创建和运行服务器,则可能会出现此症状。 Then edit the Tomcat Runtime to use Java 9 and try to start the server.然后编辑 Tomcat Runtime 以使用 Java 9 并尝试启动服务器。 What happens is that a "-Djava.endorsed.dirs" argument gets added to the launch configuration when the server was run with the earlier JRE.当服务器使用早期的 JRE 运行时,“-Djava.endorsed.dirs”参数被添加到启动配置中。 When running the server after the switch to Java 9, the "-Djava.endorsed.dirs" argument is seen as a user added VM argument and kept, resulting in the error.在切换到 Java 9 后运行服务器时,“-Djava.endorsed.dirs”参数被视为用户添加的 VM 参数并保留,从而导致错误。

The simplest way to fix is to recreate the server.最简单的修复方法是重新创建服务器。 You can also right click on the server in the servers view and select Open.您也可以在服务器视图中右键单击服务器并选择打开。 In the window that opens, click the "Open launch configuration" link at the bottom of the General section.在打开的窗口中,单击常规部分底部的“打开启动配置”链接。 In the dialog that opens, switch to the Arguments tab and in the "VM arguments" section, edit out the "-Djava.endorsed.dirs" argument and click OK.在打开的对话框中,切换到 Arguments 选项卡,在“VM arguments”部分,编辑“-Djava.endorsed.dirs”参数并单击 OK。 You should be able to start the server now.您现在应该可以启动服务器了。

In my case, what I did to answer the problem of Tomcat not running was to set Tomcat (version 7) with a lower Java version (eg Java 8).就我而言,我为解决 Tomcat 未运行问题所做的工作是将 Tomcat(版本 7)设置为较低的 Java 版本(例如 Java 8)。

Then, in startup.sh , shutdown.sh and catalina.sh I added the following:然后,在startup.shshutdown.shcatalina.sh 中我添加了以下内容:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`;

In Run configurations -> Arguments -> VM arguments try removing在运行配置 -> 参数 -> VM 参数中尝试删除

-Djava.endorsed.dirs="C:\\Program Files\\Apache Software Foundation\\Tomcat 8.5\\endorsed" -Djava.endorsed.dirs="C:\\Program Files\\Apache Software Foundation\\Tomcat 8.5\\endorsed"

You have to remove -你必须删除 -

"-Djava.endorsed.dirs="/home/ttlaptop/Downloads/apache-tomcat-7.0.105/endorsed"

from run configurations, and then tomcat will start从运行配置,然后tomcat将启动

I can't be sure but ..我不能确定但是..

Step 1 -- > it worked for me, I just remove servers from eclipse第 1 步 --> 它对我有用,我只是从 Eclipse 中删除服务器

Step 2 --> restarted and add server again (tomcat 7) Tomcat v7.0 Server at localhost步骤 2 --> 重新启动并再次添加服务器(tomcat 7)Tomcat v7.0 Server at localhost

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM