我是java web开发的新手。我试图运行这个servlet文件。我收到一个错误,因为java.lang.IllegalStateException无法加载com.mysql.jdbc.ProfilerEventHandlerFactory。
这是我的Servlet代码:
@WebServlet("/Sendf")
public class Sendf extends HttpServlet {
private static final long serialVersionUID = 1L;
Statement stmt;
ResultSet rs;
HttpSession ses=null;
/**
* @see HttpServlet#HttpServlet()
*/
public Sendf() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
// TODO Auto-generated method stub
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ocp2","root", "");
stmt=con.createStatement();
RequestDispatcher rd;
ses=req.getSession();
String s0=(String)ses.getAttribute("suserid");
String s1=req.getParameter("uname");
String s2=req.getParameter("course");
String s3=req.getParameter("suggestions");
java.sql.Date s4=rs.getDate(5);
//String s4=req.getParameter("day");
// String s5=req.getParameter("month");
//String s6=req.getParameter("year");
//String s7=s4+'-'+s5+'-'+s6;
String s8="sent";
int p=0;
String cid="";
ResultSet rs=stmt.executeQuery("select courseid from course");
int xx=0;
while(rs.next())
{
cid=rs.getString(1);
if(s2.equals(cid))
{
xx=1;
}
}
if(xx==1)
{
String qry="insert into feedback values('"+s0+"','"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s8+"',feed.NextVal)";
stmt.executeUpdate(qry);
con.commit();
rd=req.getRequestDispatcher("feedsuc.html");
rd.forward(req,res);
}
else
{
rd=req.getRequestDispatcher("feedfail.html");
rd.forward(req,res);
}
}
catch(ClassNotFoundException e)
{
pw.println("exception"+e);
}
catch(SQLException e)
{
pw.println("exception"+e);
}
catch(Exception e)
{
pw.println("can't load driver"+e.getMessage());
}
}
我的错误信息是:
Jul 23, 2014 3:00:23 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:first' did not find a matching property.
Jul 23, 2014 3:00:24 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jul 23, 2014 3:00:24 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 3:00:24 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 557 ms
Jul 23, 2014 3:00:24 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 23, 2014 3:00:24 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Jul 23, 2014 3:00:24 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [190] milliseconds.
Jul 23, 2014 3:00:25 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jul 23, 2014 3:00:25 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 3:00:25 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1148 ms
Jul 23, 2014 3:02:45 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/first] has started
Jul 23, 2014 3:02:45 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/first] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Jul 23, 2014 3:02:46 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/first] is completed
Jul 23, 2014 3:08:36 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/first] has started
Jul 23, 2014 3:08:36 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/first] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Jul 23, 2014 3:08:36 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.Could not load com.mysql.jdbc.ProfilerEventHandlerFactory. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
Jul 23, 2014 3:13:58 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.Could not load com.mysql.jdbc.ProfilerEventHandlerFactory. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1588)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4346)
at com.mysql.jdbc.ConnectionImpl.cleanup(ConnectionImpl.java:1348)
at com.mysql.jdbc.ConnectionImpl.finalize(ConnectionImpl.java:2679)
at java.lang.System$2.invokeFinalize(Unknown Source)
at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
at java.lang.ref.Finalizer.access$100(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
Jul 23, 2014 3:13:58 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/first] is completed
任何建议或解决方案将不胜感激。 提前致谢。