简体   繁体   English

非法参数异常 - 在 Netbeans 上运行但不在 Tomcat 上作为 War 文件运行的项目

[英]illegalargumentexception - Project running on Netbeans but not on Tomcat as War file

I made a project on Netbeans on my local machine with JDK 1.7 (32-bit) On running the application (using tomcat 8.0 server on netbeans), it works perfectly on http://localhost:8080/WebApplication1 .我在本地机器上使用 JDK 1.7(32 位)在 Netbeans 上创建了一个项目 在运行应用程序时(在 netbeans 上使用 tomcat 8.0 服务器),它在http://localhost:8080/WebApplication1上完美运行。

I copied the war file from the dist directly and transferred it to my Windows VM server with tomcat 8.0 and jdk 1.8 installed (64-bit).我直接从 dist 复制了 war 文件,然后将其传输到安装了 tomcat 8.0 和 jdk 1.8(64 位)的 Windows VM 服务器。 Then the war file was uploaded through tomcat's manager web app.然后通过 tomcat 的管理器 Web 应用程序上传 war 文件。

Note: 'localhost:8080/' and 'localhost:8080/manager' ran without any issue.注意:'localhost:8080/' 和 'localhost:8080/manager' 运行没有任何问题。

However, when I go and run the application ( http://localhost:8080/WebApplication1 ) - it throws the following errors.但是,当我去运行应用程序( http://localhost:8080/WebApplication1 )时 - 它会引发以下错误。

org.apache.jasper.JasperException: Unable to compile class for JSP
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:579)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause根本原因

java.lang.IllegalArgumentException: Page directive: invalid value for import
    org.apache.jasper.compiler.Node$PageDirective.validateImport(Node.java:610)
    org.apache.jasper.compiler.Node$PageDirective.addImport(Node.java:593)
    org.apache.jasper.compiler.Parser.parsePageDirective(Parser.java:344)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:458)
    org.apache.jasper.compiler.Parser.parseFileDirectives(Parser.java:1782)
    org.apache.jasper.compiler.Parser.parse(Parser.java:136)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:227)
    org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:117)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:194)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

The <%page import %> I have in my JSPs are 'java.util.*' and 2 java classes which are part of my project.我的 JSP 中的<%page import %>是“java.util.*”和 2 个 java 类,它们是我的项目的一部分。 Rest my java classes import some 'java.'休息我的 java 类导入一些“java”。 packages包裹

Additional info:附加信息:

  • I have set 'Path' environment variable to 'C:\\Program Files\\Java\\jdk 1.8\\bin'我已将“路径”环境变量设置为“C:\\Program Files\\Java\\jdk 1.8\\bin”
  • I have tried including 'org.apache.jasper.jar' to my project (& war) too我也尝试将“org.apache.jasper.jar”包含到我的项目(和战争)中
  • jdbc4.jar is also imported in library jdbc4.jar 也在库中导入

What seems to be the problem?似乎是什么问题? I am unable to make out the source of the problem.我无法弄清楚问题的根源。 Is it because of 32-bit vs 64-bit?是因为 32 位还是 64 位? or jdk 1.7 vs 1.8?还是 jdk 1.7 与 1.8? or missing environment variable?或缺少环境变量? or problem in tomcat configuration?还是tomcat配置有问题? something else?还有什么?

Problem was in my import statement, which included:问题出在我的导入语句中,其中包括:

Original code原码

 <%@page contentType="text/html" pageEncoding="UTF-8" language="java" import="java.util.*,mypackage.one.*,mypackage.two.*;"%>

The issue was the ;问题是; at the end of the import statement!在导入语句的末尾!

Corrected code:更正的代码:

 <%@page contentType="text/html" pageEncoding="UTF-8" language="java" import="java.util.*,mypackage.one.*,mypackage.two.*"%>

使用 Tomcat 7.0.21 某些 tomcat 版本会出现此错误,我也遇到了与 7.0.59 版本相同的问题。

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

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