尝试部署为Tomcat编写的应用程序4.4 J2SE 1.4使用Tomcat 9

发布于 2025-02-12 01:38:56 字数 2370 浏览 0 评论 0 原文

我尝试部署仅在非常古老的版本Tomcat 4.4中使用的应用程序。该软件确实使用JDK 1.4.2_16。这很老。 由于我无法获得WebApp的最新版本,因此我仍然想在tomcat9中使用JRE 1.8.0_201的WebApp(JSP-Files)。 到目前为止,我已经安装了Tomcat9服务器,并首先尝试将应用程序部署到WebApps文件夹,但是尝试通过Web浏览器访问该应用程序最终会失败,因为该语法自JDK 1.4自JDK 1.4上的Java 8甚至OpenJDK 11上发生了很大变化。 我现在的想法是下载旧的JDK 1.4.2_16,使用Javac编译器来编译.jspp文件以兼容(通过已经编译的旧jdk的字体模式生成兼容的字节码)。 因此,我在Web.xml中添加了这些条目:

        <init-param>
        <param-name>compiler</param-name>
        <param-value>javac1.4</param-value>
        </init-param>
        <init-param>
        <param-name>executable</param-name>
        <param-value>C:/j2sdk1.4.2_16/bin/javac.exe</param-value>
        </init-param>
        <init-param>
        <param-name>compilerSourceVM</param-name>
        <param-value>1.4</param-value>
        </init-param>
        <init-param>
        <param-name>compilerTargetVM</param-name>
        <param-value>1.4</param-value>
        </init-param>
        <init-param>

但是,这在部署软件并通过Web浏览器访问该软件后会产生很多错误。正如我到目前为止所看到的,他的确确实使用JDK 1.4.2_16的Javac编译器。但是出现的错误(HTTP状态500-内部服务器错误)对我来说没有任何意义。

错误就像

An error occurred at line: [-1] in the generated java file: [C:\Program Files\Apache Software Foundation\Tomcat 9.0\work\Catalina\localhost\x44\org\apache\jsp\web\onefile.java]
    [javac] C:/Program Files/Apache Software Foundation/Tomcat 9.0/work/Catalina/localhost/x44/org/apache/jsp/web/onefile.java:84: <identifier> expected
    [javac]   private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
    [javac]                               ^


An error occurred at line: [-1] in the generated java file: [C:\Program Files\Apache Software Foundation\Tomcat 9.0\work\Catalina\localhost\x44\org\apache\jsp\web\onefile.java]
    [javac] C:/Program Files/Apache Software Foundation/Tomcat 9.0/work/Catalina/localhost/x44/org/apache/jsp/web/onefile.java:87: '(' or '[' expected
    [javac]     _jspx_dependants = new java.util.HashMap<java.lang.String,java.lang.Long>(1);

我真的不明白这个错误是如何发生的。 1.4的Javac编译器的生成代码不应有任何问题。而且,即使是JRE 1.8也抱怨它。 Java 8与较旧的Java版本不兼容吗?因此,我不明白为什么这不起作用。

如果有人有主意,请现在让我。我 do 知道您不应该使用旧的JDK,i do 知道,过时的软件最好是独自一人,但即使在理论上,我仍然很感兴趣有兼容性吗?

I try to deploy an App that i only have in an very old version, tomcat 4.4. this software does use jdk 1.4.2_16. this is very old.
since i can't get an more recent version of the webapp, i still want to use this webapp (jsp-files) in tomcat9 with JRE 1.8.0_201.
so far so good, i installed a tomcat9 server and first tried to deploy the application to webapps folder, but trying to access the application via web browser fails ultimately since the syntax has changed a lot since jdk 1.4 on java 8 or even OpenJDK 11.
my idea now was to download the old jdk 1.4.2_16, use the javac compiler for compiling the .jspp files in order to be compatible (producing compatible bytecode through already compiled bytecode cause of the old jdk).
so i added in my web.xml these entries:

        <init-param>
        <param-name>compiler</param-name>
        <param-value>javac1.4</param-value>
        </init-param>
        <init-param>
        <param-name>executable</param-name>
        <param-value>C:/j2sdk1.4.2_16/bin/javac.exe</param-value>
        </init-param>
        <init-param>
        <param-name>compilerSourceVM</param-name>
        <param-value>1.4</param-value>
        </init-param>
        <init-param>
        <param-name>compilerTargetVM</param-name>
        <param-value>1.4</param-value>
        </init-param>
        <init-param>

however, this creates a lot of errors after deploying the software and accessing it via web browser. as i see so far he indeed does use the javac compiler of jdk 1.4.2_16. but the errors that appear (HTTP Status 500 - internal server error) does not make any sense to me.

The errors were like

An error occurred at line: [-1] in the generated java file: [C:\Program Files\Apache Software Foundation\Tomcat 9.0\work\Catalina\localhost\x44\org\apache\jsp\web\onefile.java]
    [javac] C:/Program Files/Apache Software Foundation/Tomcat 9.0/work/Catalina/localhost/x44/org/apache/jsp/web/onefile.java:84: <identifier> expected
    [javac]   private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
    [javac]                               ^


An error occurred at line: [-1] in the generated java file: [C:\Program Files\Apache Software Foundation\Tomcat 9.0\work\Catalina\localhost\x44\org\apache\jsp\web\onefile.java]
    [javac] C:/Program Files/Apache Software Foundation/Tomcat 9.0/work/Catalina/localhost/x44/org/apache/jsp/web/onefile.java:87: '(' or '[' expected
    [javac]     _jspx_dependants = new java.util.HashMap<java.lang.String,java.lang.Long>(1);

i really dont understand how this error occurs. the javac compiler of 1.4 should not have any problems with his own generated code. and, even if it is the jre 1.8 that complains about it. isn't java 8 bytecompatible to older java versions? so i don't get the point why this doesn't work.

if anyone have an idea, please let me now. i do know that you shouldn't use old JDKs, i do know that outdated software is best left alone but still, even in theory, i'm interested how much room is there for compatibility.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2025-02-19 01:38:56

与Tomcat 4.4相比,Tomcat 9将产生JSP的不同Java代码。 Tomcat 9将为最小匹配所需的JDK生成 - 因此,您将不幸地使用旧的JDK编译器编译Tomcat 8代码。其中,显然:仿制药。其中Java 1.4知道 MAP ,新版本知道 map&lt; string,long&gt;

JSP无非是用于从JSP生成Java Servlet的编译器的输入,然后将其交给所讨论的Java编译器。

如果您的代码仅由JSP组成 ,则最好不要修复JSP。否则,请考虑重新编译整个应用程序:您现在也采用了较新的Servlet规范,可能会错过一些必需的东西。我并不100%相信它们都是真正的二进制倒数兼容。

tomcat 9 use

Tomcat 9 will generate different Java code from a JSP than Tomcat 4.4 would. And Tomcat 9 will generate for the JDK that it requires as minimal match - so you'll be out of luck with compiling the Tomcat 8 code with an old JDK compiler. Among it, obviously: Generics. Where Java 1.4 knew of Map, newer versions know of Map<String,Long>.

JSPs are nothing else than input for a compiler that generates Java Servlets from the JSP, and in turn hands it to the Java compiler in question.

If your code is only made up of JSPs, you're better off fixing the JSPs. Otherwise, consider recompiling the whole application: You're now also on a newer servlet specification and might miss some required things. I'm not 100% confident that they're all truly binary backward-compatible.

Tomcat 9 uses:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文