1

我正在通过 Eclipse 在本地运行 Google Apps。我连接到http://localhost:8888/,有时 Eclipse 会从 AccessControlContext.class 中的第 374 行抛出异常:

    throw new AccessControlException("access denied "+perm, perm);

这是堆栈跟踪:

Thread [299085@qtp-12256262-2] (Suspended (exception AccessControlException))   

AccessControlContext.checkPermission(Permission) line: 374  
AccessController.checkPermission(Permission) line: 546  
DevAppServerFactory$CustomSecurityManager(SecurityManager).checkPermission(Permission) line: 532    
DevAppServerFactory$CustomSecurityManager.checkPermission(Permission) line: 289 
DevAppServerFactory$CustomSecurityManager(SecurityManager).checkPackageAccess(String) line: 1512    
Launcher$AppClassLoader.loadClass(String, boolean) line: 298    
Launcher$AppClassLoader(ClassLoader).loadClass(String) line: 247    
ResourceBundle$RBClassLoader.loadClass(String) line: 435    
ResourceBundle$Control.newBundle(String, Locale, String, ClassLoader, boolean) line: 2289   
ResourceBundle.loadBundle(CacheKey, List<String>, Control, boolean) line: 1364  
ResourceBundle.findBundle(CacheKey, List<Locale>, List<String>, int, Control, ResourceBundle) line: 1328    
ResourceBundle.findBundle(CacheKey, List<Locale>, List<String>, int, Control, ResourceBundle) line: 1282    
ResourceBundle.findBundle(CacheKey, List<Locale>, List<String>, int, Control, ResourceBundle) line: 1282    
ResourceBundle.getBundleImpl(String, Locale, ClassLoader, ResourceBundle$Control) line: 1224    
ResourceBundle.getBundle(String) line: 705  
Level.getLocalizedName() line: 223  
SimpleFormatter.format(LogRecord) line: 64  
ConsoleHandler(StreamHandler).publish(LogRecord) line: 179  
ConsoleHandler.publish(LogRecord) line: 88  
Logger.log(LogRecord) line: 478 
Logger.doLog(LogRecord) line: 500   
Logger.log(Level, String) line: 523 
Logger.warning(String) line: 1026   

我只是这样称呼:

    log.warning("string");

并且日志被初始化如下:

    private static final Logger log = Logger.getLogger(MyServletName.class.getName());

什么是破?

4

1 回答 1

0

尝试改用这条线。在编写 GAE 代码时,我通常使用类似于以下行的内容:

private static final Logger log = Logger.getLogger(MyServletName.class.getSimpleName());

因此,使用getSimpleName()而不是getName(). 阅读getName()getSimpleName()上的 java.lang.Class javadoc 。前者可能会在类类型名称的末尾附加一个“L”字符,而后者不具备这种(在您的情况下是不受欢迎的)行为。

另外,考虑对类的 Logger 对象使用Guice 注入

于 2012-10-22T03:31:50.500 回答