2013-08-02 419 views
0

我正在開發使用Apache Tomcat 7.0和MySQL數據庫的Web應用程序,以及後期我得到我的所有網頁中一個奇怪的例外....無法初始化類com.mysql.jdbc.StringUtils

當我開始Tomcat和調用任何servlet,一個異常堆棧跟蹤首先出現,其是如下 -

Aug 02, 2013 1:19:08 PM org.apache.catalina.core.StandardWrapperValve invoke 
SEVERE: Servlet.service() for servlet [GenerateMiniStatement] in context with path [/IndianNationalBank] threw exception [null] with root cause 
java.security.AccessControlException: access denied ("java.util.PropertyPermission"  "file.encoding" "read") 
at java.security.AccessControlContext.checkPermission(Unknown Source) 
at java.security.AccessController.checkPermission(Unknown Source) 
at java.lang.SecurityManager.checkPermission(Unknown Source) 
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source) 
at java.lang.System.getProperty(Unknown Source) 
at com.mysql.jdbc.StringUtils.<clinit>(StringUtils.java:70) 
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327) 
at java.sql.DriverManager.getConnection(Unknown Source) 
at java.sql.DriverManager.getConnection(Unknown Source) 
at in.inb.MiniStatement.GenerateMiniStatement.doPost(GenerateMiniStatement.java:64) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:277) 
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274) 
at java.security.AccessController.doPrivileged(Native Method) 
at javax.security.auth.Subject.doAsPrivileged(Unknown Source) 
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:309) 
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:169) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:299) 
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:57) 
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:193) 
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:189) 
at java.security.AccessController.doPrivileged(Native Method) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) 
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) 
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) 
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
at java.lang.Thread.run(Unknown Source) 

第一執行後,當我嘗試調用任何servlet所述第二時間,將出現不同的異常堆棧跟蹤,如下 -

Aug 02, 2013 10:54:49 AM org.apache.catalina.core.StandardWrapperValve invoke 
SEVERE: Servlet.service() for servlet [in.inb.Login.LoginServlet] in context with path  [/SomeCompany] threw exception [Could not initialize class  com.mysql.jdbc.StringUtils] with root cause 
java.lang.NoClassDefFoundError: Could not initialize class com.mysql.jdbc.StringUtils 
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327) 
at java.sql.DriverManager.getConnection(Unknown Source) 
at java.sql.DriverManager.getConnection(Unknown Source) 
at in.inb.Login.LoginServlet.doPost(LoginServlet.java:44) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:277) 
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274) 
at java.security.AccessController.doPrivileged(Native Method) 
at javax.security.auth.Subject.doAsPrivileged(Unknown Source) 
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:309) 
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:169) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:299) 
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:57) 
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:193) 
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:189) 
at java.security.AccessController.doPrivileged(Native Method) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) 
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) 
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) 
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
at java.lang.Thread.run(Unknown Source) 

我的猜測是,StringUtils類沒有獲得對file.encoding系統屬性的訪問權限,並且因爲該JVM無法正確加載該類。

我的猜測是對的嗎? 我已經嘗試了很多,但無法獲得答案。我無法弄清楚問題出在哪裏。請幫助我..

Thankyou非常提前。

+0

消息'無法初始化類...'意味着JVM已經嘗試過並且無法加載指定的類。如果您重新啓動Tomcat,並嘗試再次重現此錯誤,這是您獲得的第一個錯誤,還是會得到不同的錯誤?如果您收到其他錯誤,請修改您的問題以包含此錯誤。 –

+0

@ LukeWoodward-謝謝你的提示。編輯了這個問題。 – plutonium1991

回答

1

檢查MySQL連接器JAR是否位於Web應用程序的WEB-INF/lib文件夾中,它實際上包含異常說明無法加載的類(com.mysql.jdbc.StringUtils)。

相關問題