package com.igate.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
public class TestController extends HttpServlet {
private static final long serialVersionUID = 1L;
public TestController() {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
String action= request.getParameter("action");
System.out.println(action);
if(action.equals("proceed"))
{
String pf =request.getParameter("pf");
String app =request.getParameter("app");
String bw =request.getParameter("b");
PropertiesConfiguration config =null;
try {
config = new PropertiesConfiguration("D:/SCT_WRK/projectOne/framework.properties");
config.setProperty("PLATFORM",pf);
config.setProperty("APP_TYPE",app);
config.setProperty("BROWSER",bw);
config.save();
} catch (ConfigurationException e) {
e.printStackTrace();
}
}
}
}
实际上
I want to write data in property file that data comes from jsp file(user entered data). but above code is not working.
我需要 - -1。在属性文件中写入用户输入数据而不影响属性文件的先前数据。
但它提出了一些问题 -
1 - 。 EXCEPTION:javax.servlet.ServletException:实例化servlet类com.igate.controller.TestController时出错 2。 java.lang.NoClassDefFoundError:org / apache / commons / configuration / ConfigurationException 3。 java.lang.ClassNotFoundException:org.apache.commons.configuration.ConfigurationException
这是完整的堆栈跟踪。
这是完整的堆栈跟踪.. HTTP状态500 -
输入例外报告
消息
description服务器遇到内部错误(),导致无法完成此请求。
exception javax.servlet.ServletException: Error instantiating servlet class com.igate.controller.TestController
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
root cause java.lang.NoClassDefFoundError: org/apache/commons/configuration/ConfigurationException java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
java.lang.Class.getConstructor0(Unknown Source)
java.lang.Class.newInstance(Unknow Source)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
root cause java.lang.ClassNotFoundException: org.apache.commons.configuration.ConfigurationException
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1672)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1517)
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
java.lang.Class.getConstructor0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
Apache Tomcat/7.0.4
答案 0 :(得分:0)
这是jar问题,
http://commons.apache.org/logging/download_logging.cgi
并复制到您的lib文件夹。 清理项目和tomcat。 重新启动服务器并尝试。