I can't get tomcat7 to compile jsps. It till run the example servlets just fine and the service is up and running. I am running oracle java 8.
我无法让tomcat7编译jsp。它一直运行示例servlet,并且服务已经启动并运行。我正在运行oracle java 8。
Can anyone point me in the right direction?
谁能给我指出正确的方向吗?
Here is the stacktrace:
这是加亮:
type Exception reportmessage Unable to compile class for JSP:description The server encountered an internal error that prevented it from fulfilling this request.exceptionorg.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 1 in the generated java fileThe type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class filesStacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:468) org.apache.jasper.compiler.Compiler.compile(Compiler.java:378) org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:728)note The full stack trace of the root cause is available in the Apache Tomcat/7.0.35 logs.
The code looks like this and it's the sample code from tomcat7 so my guess is that it's correct.
代码是这样的,它是tomcat7的示例代码,所以我猜它是正确的。
<%@ taglib prefix="mytag" uri="/WEB-INF/jsp2/jsp2-example-taglib.tld" %><html><head> <title>JSP 2.0 Examples - Hello World SimpleTag Handler</title></head><body><h1>JSP 2.0 Examples - Hello World SimpleTag Handler</h1><hr><p>This tag handler simply echos "Hello, World!" It's an example ofa very basic SimpleTag handler with no body.</p><br><b><u>Result:</u></b><mytag:helloWorld/></body></html>
11 个解决方案
#1
91
You must use a more recent version of tomcat which has support for JDK 8.
您必须使用较新的tomcat版本,该版本支持JDK 8。
I can confirm that apache-tomcat-7.0.35 does NOT have support for JDK8, I can also confirm that apache-tomcat-7.0.50 DOES have support for JDK8.
我可以确认apache-tomcat-7.0.35不支持JDK8,我也可以确认apache-tomcat-7.0.50确实支持JDK8。
#2
13
The class format of JDK8 has changed and thats the reason why Tomcat is not able to compile JSPs. Try to get a newer version of Tomcat.
JDK8的类格式已经改变,这就是为什么Tomcat不能编译jsp的原因。尝试获取Tomcat的更新版本。
I recently had the same problem. This is a bug in Tomcat, or rather, JDK 8 has a slightly different class file format than what prior-JDK8 versions had. This causes inconsistency and Tomcat is not able to compile JSPs in JDK8.
我最近遇到了同样的问题。这是Tomcat中的一个bug,或者更确切地说,JDK8的类文件格式与之前版本的JDK - jdk8稍有不同。这导致了不一致,而Tomcat无法在JDK8中编译jsp。
See following references:
看到以下引用:
- Compiling JSPs with JDK 1.8 in Tomcat 8
- 在Tomcat 8中使用JDK 1.8编译jsp
- compilation succeeds in java7 but fails in java8
- 编译在java7中成功,在java8中失败
#3
2
Because we are running on Ubuntu 12.04 LTS and the latest official supported tomcat7 package is 7.0.26 we are not easily able to update the whole tomcat.
因为我们运行的是Ubuntu 12.04 LTS,最新官方支持的tomcat7包是7.0.26,所以我们很难更新整个tomcat。
I order to test for with the jdk8, I was able to get resolve this issue by changing some jars against their latest 7.0.* version.
我命令使用jdk8进行测试,我通过将一些jar修改为最新的7.0来解决这个问题。*版本。
I switched jasper.jar, jasper-el and tomcat-util to the version 7.0.53 and added ecj-4.3.1.jar. That brings the application back online.
我换了碧玉。jar、jasper-el和tomcat-util添加到版本7.0.53,并添加了ecj-4.3.1.jar。这使得应用程序回到了在线。
BUT... also i changed packaged content with this, so maybe it would be better to download the whole tomcat and use it self installed as messing up packages. So please see this only as a very dirty quickhack or workaround.
但是…此外,我还对打包后的内容进行了修改,所以最好下载整个tomcat,然后使用它自己安装,把包弄乱。因此,请将此视为一个非常脏的quickhack或变通方法。
#4
2
If you are using maven then you can add the tomcat7-maven-plugin to your pom.xml and it shall run fine. This plugin will run the project on Tomcat servlet container version 7.0.47 which supports JDK 1.8.
如果您正在使用maven,那么您可以将tomcat7-maven-plugin添加到pom中。xml,运行良好。这个插件将在Tomcat servlet容器版本7.0.47上运行这个项目,该版本支持JDK 1.8。
<plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration><!-- Include context file for Datasource configuration --> <contextFile>./src/main/webapp/META-INF/context.xml</contextFile> <port>8080</port> </configuration> <dependencies><!-- Include jdbc driver dependency if using datasource (in my case oracle) --> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.2.0.4.0</version> </dependency> </dependencies> </plugin> </plugins>
Hope this is useful! Thanks
希望这是有用的!谢谢
#5
0
From the JIRA knowledge base:
来自JIRA知识库:
Symptoms
Workflow actions may be inaccessible
工作流操作可能不可访问
- JIRA may throw exceptions on screen
- JIRA可能会在屏幕上抛出异常
- One or both of the following conditions may exist:
- 可能存在下列一种或两种情况:
The following appears in the atlassian-jira.log:
以下内容出现在《大西洋月刊》上。
2007-12-06 10:55:05,327 http-8080-Processor20 ERROR [500ErrorPage] Exception caught in500 page Unable to compile class for JSP org.apache.jasper.JasperException: Unable to compile class for JSP at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:572) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
_
_
Cause:
The Tomcat container caches .java and .class files generated by the JSP parser they are used by the web application. Sometimes these get corrupted or cannot be found. This may occur after a patch or upgrade that contains modifications to JSPs.
Tomcat容器缓存web应用程序使用的JSP解析器生成的.java和.class文件。有时这些会被破坏或者找不到。这可能发生在包含对jsp的修改的补丁或升级之后。
Resolution
1.Delete the contents of the /work folder if using standalone JIRA or /work if using EAR/WAR installation . 2. Verify the user running the JIRA application process has Read/Write permission to the /work directory. 3. Restart the JIRA application container to rebuild the files.
1。如果使用独立的JIRA或使用EAR/WAR安装,则删除/work文件夹的内容。2。验证运行JIRA应用程序进程的用户对/work目录具有读/写权限。3所示。重新启动JIRA应用程序容器以重建文件。
#6
0
Add this import <%@page import="java.util.Map" %>
添加这个导入<%@page import="java.util "。地图”% >
This worked for me, but I also needed to add <%@ page import="java.util.HashMap" %>.It seems that the above answer is true, that if you have the newer tomcat you might not need to add these lines, but as I could not change my whole system, this worked.
Thank you
这对我来说是可行的,但是我还需要添加<%@页面导入="java.util "。HashMap " % >。上面的答案似乎是正确的,如果您有新的tomcat,那么您可能不需要添加这些行,但是由于我无法更改整个系统,所以这是有效的。谢谢你!
#7
0
Faced exactly the same issue while upgrading my application from java 6 to java 8 on tomcat 7.0.19.After upgrading the tomcat to 7.0.59, this issue is resolved.
在tomcat 7.0.19上将应用程序从java 6升级到java 8时,遇到了同样的问题。将tomcat升级到7.0.59之后,这个问题就解决了。
#8
0
Try and add <%@page import="java.util.Map.Entry"%>
to your jsp file
尝试添加<%@page import="java.util.Map "。在jsp文件中输入“%>”
#9
0
There are a lot of correct/same answers, but for future references:
有很多正确的答案,但对于未来的参考:
Same stands for Tomcat 7. Be aware that updating only your used frameworks' versions (as proposed in other similar questions) isn't enough.
Tomcat 7也是如此。请注意,仅更新您使用的框架的版本(如其他类似问题所建议的)是不够的。
You also have to update Tomcat plugin's version.What worked for me, using Java 7, was upgrading to version 2.2 of tomcat7-maven-plugin (= Tomcat 7.0.47).
您还必须更新Tomcat插件的版本。使用Java 7对我有用的是升级到版本2.2的tomcat7-maven-plugin (= Tomcat 7.0.47)。
#10
0
I recently get across the same issue. I was using IntelliJx64 with Tomcat7.0.32 with jdk.8.0.102. There was no issue then. I was able to directly access my deployment localhost:[port] without adding [mywebapp] or /ROOT.
我最近遇到了同样的问题。我用的是IntelliJx64和Tomcat7.0.32和jdk.8.0.102。那时没有问题。我可以直接访问部署localhost:[port],而无需添加[mywebapp]或/ROOT。
When I tried to migrate to eclipse neon, I came across the same bug that is discussed when I tried to set the path as empty string. When I enforced execution environment to Java7 and set modules to empty it did not solve toe issue. However, when I changed my tomcat installation to 7.072 and manually changed context path configuration to path="" the problem was solved in eclipse. (You can manipulate the path via double click server and switching to module tab too.)
当我试图迁移到eclipse neon时,我遇到了与我试图将路径设置为空字符串时相同的错误。当我将执行环境强制为Java7并将模块设置为empty时,这并没有解决toe问题。但是,当我将tomcat安装更改为7.072并将上下文路径配置手动更改为path=""时,问题在eclipse中得到了解决。(您可以通过双击服务器并切换到module选项卡来操作路径。)
My wonder is how come IntelliJ was not giving any issues with the same bug which was supposed to be related to tomcat installation version?
我的疑问是,为什么IntelliJ没有提供与tomcat安装版本相关的bug ?
There also seems to be a relation with the IDE in use.
在使用中,似乎也与IDE有关。
#11
0
I ran into this before, as others said: just upgrade jetty plugin
我以前遇到过这种情况,就像其他人说的:升级jetty插件
if you are using maven
如果您正在使用maven
go to jetty
plugin in pom.xml and update it to
到pom的jetty插件。xml并将其更新为
<plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.3.0.v20150612</version> <configuration> <scanIntervalSeconds>3</scanIntervalSeconds> <httpConnector> <port>${jetty.port}</port> <idleTimeout>60000</idleTimeout> </httpConnector> <stopKey>foo</stopKey> <stopPort>${jetty.stop.port}</stopPort> </configuration></plugin>
hope this help you
希望这有助于你
#1
91
You must use a more recent version of tomcat which has support for JDK 8.
您必须使用较新的tomcat版本,该版本支持JDK 8。
I can confirm that apache-tomcat-7.0.35 does NOT have support for JDK8, I can also confirm that apache-tomcat-7.0.50 DOES have support for JDK8.
我可以确认apache-tomcat-7.0.35不支持JDK8,我也可以确认apache-tomcat-7.0.50确实支持JDK8。
#2
13
The class format of JDK8 has changed and thats the reason why Tomcat is not able to compile JSPs. Try to get a newer version of Tomcat.
JDK8的类格式已经改变,这就是为什么Tomcat不能编译jsp的原因。尝试获取Tomcat的更新版本。
I recently had the same problem. This is a bug in Tomcat, or rather, JDK 8 has a slightly different class file format than what prior-JDK8 versions had. This causes inconsistency and Tomcat is not able to compile JSPs in JDK8.
我最近遇到了同样的问题。这是Tomcat中的一个bug,或者更确切地说,JDK8的类文件格式与之前版本的JDK - jdk8稍有不同。这导致了不一致,而Tomcat无法在JDK8中编译jsp。
See following references:
看到以下引用:
- Compiling JSPs with JDK 1.8 in Tomcat 8
- 在Tomcat 8中使用JDK 1.8编译jsp
- compilation succeeds in java7 but fails in java8
- 编译在java7中成功,在java8中失败
#3
2
Because we are running on Ubuntu 12.04 LTS and the latest official supported tomcat7 package is 7.0.26 we are not easily able to update the whole tomcat.
因为我们运行的是Ubuntu 12.04 LTS,最新官方支持的tomcat7包是7.0.26,所以我们很难更新整个tomcat。
I order to test for with the jdk8, I was able to get resolve this issue by changing some jars against their latest 7.0.* version.
我命令使用jdk8进行测试,我通过将一些jar修改为最新的7.0来解决这个问题。*版本。
I switched jasper.jar, jasper-el and tomcat-util to the version 7.0.53 and added ecj-4.3.1.jar. That brings the application back online.
我换了碧玉。jar、jasper-el和tomcat-util添加到版本7.0.53,并添加了ecj-4.3.1.jar。这使得应用程序回到了在线。
BUT... also i changed packaged content with this, so maybe it would be better to download the whole tomcat and use it self installed as messing up packages. So please see this only as a very dirty quickhack or workaround.
但是…此外,我还对打包后的内容进行了修改,所以最好下载整个tomcat,然后使用它自己安装,把包弄乱。因此,请将此视为一个非常脏的quickhack或变通方法。
#4
2
If you are using maven then you can add the tomcat7-maven-plugin to your pom.xml and it shall run fine. This plugin will run the project on Tomcat servlet container version 7.0.47 which supports JDK 1.8.
如果您正在使用maven,那么您可以将tomcat7-maven-plugin添加到pom中。xml,运行良好。这个插件将在Tomcat servlet容器版本7.0.47上运行这个项目,该版本支持JDK 1.8。
<plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration><!-- Include context file for Datasource configuration --> <contextFile>./src/main/webapp/META-INF/context.xml</contextFile> <port>8080</port> </configuration> <dependencies><!-- Include jdbc driver dependency if using datasource (in my case oracle) --> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.2.0.4.0</version> </dependency> </dependencies> </plugin> </plugins>
Hope this is useful! Thanks
希望这是有用的!谢谢
#5
0
From the JIRA knowledge base:
来自JIRA知识库:
Symptoms
Workflow actions may be inaccessible
工作流操作可能不可访问
- JIRA may throw exceptions on screen
- JIRA可能会在屏幕上抛出异常
- One or both of the following conditions may exist:
- 可能存在下列一种或两种情况:
The following appears in the atlassian-jira.log:
以下内容出现在《大西洋月刊》上。
2007-12-06 10:55:05,327 http-8080-Processor20 ERROR [500ErrorPage] Exception caught in500 page Unable to compile class for JSP org.apache.jasper.JasperException: Unable to compile class for JSP at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:572) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
_
_
Cause:
The Tomcat container caches .java and .class files generated by the JSP parser they are used by the web application. Sometimes these get corrupted or cannot be found. This may occur after a patch or upgrade that contains modifications to JSPs.
Tomcat容器缓存web应用程序使用的JSP解析器生成的.java和.class文件。有时这些会被破坏或者找不到。这可能发生在包含对jsp的修改的补丁或升级之后。
Resolution
1.Delete the contents of the /work folder if using standalone JIRA or /work if using EAR/WAR installation . 2. Verify the user running the JIRA application process has Read/Write permission to the /work directory. 3. Restart the JIRA application container to rebuild the files.
1。如果使用独立的JIRA或使用EAR/WAR安装,则删除/work文件夹的内容。2。验证运行JIRA应用程序进程的用户对/work目录具有读/写权限。3所示。重新启动JIRA应用程序容器以重建文件。
#6
0
Add this import <%@page import="java.util.Map" %>
添加这个导入<%@page import="java.util "。地图”% >
This worked for me, but I also needed to add <%@ page import="java.util.HashMap" %>.It seems that the above answer is true, that if you have the newer tomcat you might not need to add these lines, but as I could not change my whole system, this worked.
Thank you
这对我来说是可行的,但是我还需要添加<%@页面导入="java.util "。HashMap " % >。上面的答案似乎是正确的,如果您有新的tomcat,那么您可能不需要添加这些行,但是由于我无法更改整个系统,所以这是有效的。谢谢你!
#7
0
Faced exactly the same issue while upgrading my application from java 6 to java 8 on tomcat 7.0.19.After upgrading the tomcat to 7.0.59, this issue is resolved.
在tomcat 7.0.19上将应用程序从java 6升级到java 8时,遇到了同样的问题。将tomcat升级到7.0.59之后,这个问题就解决了。
#8
0
Try and add <%@page import="java.util.Map.Entry"%>
to your jsp file
尝试添加<%@page import="java.util.Map "。在jsp文件中输入“%>”
#9
0
There are a lot of correct/same answers, but for future references:
有很多正确的答案,但对于未来的参考:
Same stands for Tomcat 7. Be aware that updating only your used frameworks' versions (as proposed in other similar questions) isn't enough.
Tomcat 7也是如此。请注意,仅更新您使用的框架的版本(如其他类似问题所建议的)是不够的。
You also have to update Tomcat plugin's version.What worked for me, using Java 7, was upgrading to version 2.2 of tomcat7-maven-plugin (= Tomcat 7.0.47).
您还必须更新Tomcat插件的版本。使用Java 7对我有用的是升级到版本2.2的tomcat7-maven-plugin (= Tomcat 7.0.47)。
#10
0
I recently get across the same issue. I was using IntelliJx64 with Tomcat7.0.32 with jdk.8.0.102. There was no issue then. I was able to directly access my deployment localhost:[port] without adding [mywebapp] or /ROOT.
我最近遇到了同样的问题。我用的是IntelliJx64和Tomcat7.0.32和jdk.8.0.102。那时没有问题。我可以直接访问部署localhost:[port],而无需添加[mywebapp]或/ROOT。
When I tried to migrate to eclipse neon, I came across the same bug that is discussed when I tried to set the path as empty string. When I enforced execution environment to Java7 and set modules to empty it did not solve toe issue. However, when I changed my tomcat installation to 7.072 and manually changed context path configuration to path="" the problem was solved in eclipse. (You can manipulate the path via double click server and switching to module tab too.)
当我试图迁移到eclipse neon时,我遇到了与我试图将路径设置为空字符串时相同的错误。当我将执行环境强制为Java7并将模块设置为empty时,这并没有解决toe问题。但是,当我将tomcat安装更改为7.072并将上下文路径配置手动更改为path=""时,问题在eclipse中得到了解决。(您可以通过双击服务器并切换到module选项卡来操作路径。)
My wonder is how come IntelliJ was not giving any issues with the same bug which was supposed to be related to tomcat installation version?
我的疑问是,为什么IntelliJ没有提供与tomcat安装版本相关的bug ?
There also seems to be a relation with the IDE in use.
在使用中,似乎也与IDE有关。
#11
0
I ran into this before, as others said: just upgrade jetty plugin
我以前遇到过这种情况,就像其他人说的:升级jetty插件
if you are using maven
如果您正在使用maven
go to jetty
plugin in pom.xml and update it to
到pom的jetty插件。xml并将其更新为
<plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.3.0.v20150612</version> <configuration> <scanIntervalSeconds>3</scanIntervalSeconds> <httpConnector> <port>${jetty.port}</port> <idleTimeout>60000</idleTimeout> </httpConnector> <stopKey>foo</stopKey> <stopPort>${jetty.stop.port}</stopPort> </configuration></plugin>
hope this help you
希望这有助于你