標籤:style http io ar color os 使用 sp for
今天在使用jetty做容器運行一個java web app時卻給出了這樣的錯誤:
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")at java.security.AccessControlContext.checkPermission(Unknown Source)at java.security.AccessController.checkPermission(Unknown Source)at org.eclipse.jetty.server.handler.ContextHandler$Context.getClassLoader(ContextHandler.java:2390)at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:210)at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:250)at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:106)at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:103)at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:106)at org.eclipse.jetty.annotations.ServletContainerInitializerListener.doStart(ServletContainerInitializerListener.java:107)at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:81)at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:96)at org.eclipse.jetty.server.handler.ScopedHandler.doStart(ScopedHandler.java:115)at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:763)at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)at org.eclipse.jetty.server.Server.doStart(Server.java:282)at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedAdapter.start(JettyEmbeddedAdapter.java:67)at net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.launch(AbstractJettyLauncherMain.java:85)at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedLauncherMain.main(JettyEmbeddedLauncherMain.java:42)
在網上搜尋一番後,找到瞭解決辦法:
1. 查看工程使用的哪個JRE
2. 在這個目錄下的【?security?】檔案夾下找到【java.policy】檔案:
3. 用記事本或者notepad++開啟它,並在grant中增加下面的兩行,並儲存。
4. 重啟Jetty,錯誤消失,結果正常。
至於為什麼這樣可以解決,網上還搜到相關說明。我暫時也沒時間去深究,等以後有時間再說吧。
Access denied (java.lang.RuntimePermission getClas