我们在Tomcat 7服务器中托管了一个JSP应用程序。作为构建过程的一部分,我们运行了一些自动化测试,通过HtmlUnit调用这些JSP页面。 当一些测试试图访问JSP文件时,我们注意到间歇性的JSP编译错误。这似乎与任何特定测试无关。
我们最后的编译错误是:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: [1] in the generated java file: [/tmp/myproject/work/Tomcat/localhost/_/org/apache/jsp/WEB_002dINF/jsp/admin/home_jsp.java]
Syntax error on tokens, delete these tokens
An error occurred at line: [97] in the generated java file: [/tmp/myproject/work/Tomcat/localhost/_/org/apache/jsp/WEB_002dINF/jsp/admin/home_jsp.java]
Syntax error on token(s), misplaced construct(s)
An error occurred at line: 1 in the jsp file: /WEB-INF/jspf/taglibs.jspf
Syntax error on tokens, delete these tokens
1: <%@ taglib uri="http://www.springframework.org/security/tags" prefix="authz" %>
2: <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
3: <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
4: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
An error occurred at line: 1 in the jsp file: /WEB-INF/jspf/taglibs.jspf
Syntax error on token "}", delete this token
1: <%@ taglib uri="http://www.springframework.org/security/tags" prefix="authz" %>
2: <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
3: <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
4: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
An error occurred at line: 1 in the jsp file: /WEB-INF/jspf/taglibs.jspf
Syntax error on token "(", ; expected
1: <%@ taglib uri="http://www.springframework.org/security/tags" prefix="authz" %>
2: <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
3: <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
4: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
An error occurred at line: 1 in the jsp file: /WEB-INF/jspf/taglibs.jspf
Syntax error on token(s), misplaced construct(s)
1: <%@ taglib uri="http://www.springframework.org/security/tags" prefix="authz" %>
2: <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
3: <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
4: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
An error occurred at line: 1 in the jsp file: /WEB-INF/jspf/taglibs.jspf
Syntax error on token(s), misplaced construct(s)
1: <%@ taglib uri="http://www.springframework.org/security/tags" prefix="authz" %>
2: <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
3: <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
4: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
An error occurred at line: 1 in the jsp file: /WEB-INF/jspf/taglibs.jspf
Syntax error on token "throws", throw expected
1: <%@ taglib uri="http://www.springframework.org/security/tags" prefix="authz" %>
2: <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
3: <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
4: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
An error occurred at line: 1 in the jsp file: /WEB-INF/jsp/admin/home.jsp
Syntax error on token "}", delete this token
1: <%@ include file="/WEB-INF/jspf/taglibs.jspf" %>
2: <html>
3: <head>
4: <title>Administrator Home</title>
我们在本地环境中以及在负责运行这些系统测试的环境之外的任何其他环境中都没有看到这些错误,是的,我们使用相同的代码库。
这些错误似乎只发生在第一次访问JSP文件时,因为我可以在Tomcat jsp工作目录中看到有一个home_jsp.java和一个home_jsp.class,这意味着jsp文件已被正确翻译进入一个servlet类,然后在以后正确编译。另外,我查看了home_jsp.java文件,看不到与JSP编译器报告的编译错误相对应的任何明显错误。
感谢任何有关此问题的建议/建议。
干杯, 奥利弗
答案 0 :(得分:0)
我们不知道我们有2个Tomcat实例实际使用相同的JSP工作目录。
我们已对此进行了更改,以便每个实例都使用自己的工作文件夹,因此我们再也没有看到此问题。
这并没有给我们实际的根本原因,但至少它已经解决了我们的问题。