无法为JSP编译类.的Tomcat 7.0.82 [英] Unable to Compile class for JSP. Tomcat 7.0.82

查看:149
本文介绍了无法为JSP编译类.的Tomcat 7.0.82的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从Eclipse中的Java Web项目创建了war文件.它非常正确地在WEB-INF目录中创建了classeslib文件夹,其中包含已编译的源代码和引用的库.当我在Apache Tomcat 7.0.82上部署此项目时,除Main2.jsp处出现以下异常

I have created a war file from a Java web project within Eclipse. It very rightly created a classes and lib folders in WEB-INF directory containing compiled sources and referenced libraries. When I deployed this project on Apache Tomcat 7.0.82, it runs fine for most of the pages except Main2.jsp where I get the following exception

类型异常报告

type Exception report

消息无法为JSP编译类

message Unable to compile class for JSP

说明服务器遇到内部错误,阻止了它 满足此请求.

description The server encountered an internal error that prevented it from fulfilling this request.

例外

org.apache.jasper.JasperException:无法为JSP编译类 org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:675) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

org.apache.jasper.JasperException: Unable to compile class for JSP org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:675) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Main.jsp的代码如下

<%@page import="assemble_xml.*"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%> 
<%@page import="org.json.JSONObject"%>
<%@page import="org.json.*;"%>
<%
System.out.println("\n*** Inside Main2.jsp");
String data1 = request.getParameter("data");
String sourceApiId = request.getParameter("sourceApiId");
String bpFile = request.getParameter("bpFile");
String context = getServletContext().getRealPath("/");
//data1 = "{000:{name:mkyong.com,messages:[msg 1,msg 2,msg 3],age:100},001:{name:mkyong.com,messages:[msg 1,msg 2,msg 3],age:100}}";
JSONObject jsonObject = new JSONObject(data1);

System.out.println("\n*** Inside Main2.jsp: jsonObject"  + data1);

Operation op1 = new Operation ("");

HashMap<String, Operation> hm_xml_att  = op1.readOpAttribFromXML2(context+bpFile, jsonObject);
op1.writeXML(hm_xml_att,context + "auth_refine_output" + File.separatorChar + sourceApiId);

//BP bp = new BP(context,context + "\\auth_refine_output\\Mappings.txt",context + "\\auth_refine_output\\" + sourceApiId,context + "\\auth_refine_output\\OFBiz_Process.xml");

//response.setContentType("text/html"); 
//response.getWriter().write("Dataflow file (" +context + "\\auth_refine_output\\OFBiz_Process.xml) generated successfully");  
//System.out.println("\n*** Inside Main2.jsp: Dataflow file (" +context + "\\auth_refine_output\\OFBiz_Process.xml" + ") generated successfully");
%> 

我非常确定问题是由于以下两次进口引起的

I am pretty sure that the problem is due to the following two imports

<%@page import="org.json.JSONObject"%>
<%@page import="org.json.*;"%>

因为,当我删除它们时,错误仍然相同,但是现在是由于未将JsonObject解析为一种类型.具有讽刺意味的是,我在WEB-INF\lib文件夹中有三个以上的文件,似乎都包含JsonOject.这些文件是json-20090211.jarjson-20160810.jarjson-lib-2.4-jdk15.jar.

because, when I remove them, the error remains the same but now it's due to not resolving JsonObject to a type. Ironically, I have more than three files in WEB-INF\lib folder that seem like containing JsonOject. Those files are json-20090211.jar, json-20160810.jar and json-lib-2.4-jdk15.jar.

这三个文件也都在eclipse项目中存在,但是它在eclipse中运行得很好.我不是该项目的作者,也不是Java专业人士.因此,我想知道为什么为什么要包含三个仅作为JSON的文件作为dep?以及为什么它在eclipse中可以正常运行,但不能在Apache Tomcat 7中运行呢?

All three files are also present in eclipse project but it runs flawlessly in eclipse. I am not the author of this project and not a Java pro anyway. So, I wonder why do we have three files included as dep just for JSON? and why it works fine in eclipse but not from Apache Tomcat 7?

推荐答案

上次导入的分号是问题所在.从

Semicolon in the last import was the problem. Changing the line from

<%@page import="org.json.*;"%>

<%@page import="org.json.*"%>

解决了问题

这篇关于无法为JSP编译类.的Tomcat 7.0.82的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆