我想在会话终止时删除文件,但是,当尝试从文件系统修改文件时,出现Notes安全异常。
这是我尝试过的:
File f = getSourceFile();
f.delete(); // java.lang.SecurityException: Zugriff auf die Datei {0} bzw. diese zu ändern ist nicht zulässig (Accessing or modifiying this File is prohibited)
FileUtils.clearFile(f); // java.lang.IllegalStateException: NotesContext is not initialized for the Thread
这是我检索文件的方式:
public File getSourceFile() {
return new File(this.absolutePath);
}
我也尝试使用doPrivileged,但这导致了相同的IllegalStateException:
AccessController.doPrivileged(new PrivilegedAction() { // java.lang.IllegalStateException: NotesContext is not initialized for the Thread
public Object run() {
File f = getSourceFile();
if(f.exists()){
FileUtil.deleteFile(f);
}
}
});
我想可以以某种方式重新初始化NotesContext,但是我认为这不是一个很好的解决方案。
堆栈跟踪:
(非法国家)
java.lang.IllegalStateException: NotesContext not initialized for the thread
at com.ibm.domino.xsp.module.nsf.NotesContext.getCurrent(NotesContext.java:123)
at com.ibm.domino.xsp.module.nsf.ModuleClassLoader$DynamicClassLoader.findClass(ModuleClassLoader.java:438)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:924)
at java.lang.ClassLoader.loadClass(ClassLoader.java:869)
at com.ibm.domino.xsp.module.nsf.ModuleClassLoader$DynamicClassLoader.loadClass(ModuleClassLoader.java:403)
at java.lang.ClassLoader.loadClass(ClassLoader.java:852)
at de.iV.beans.ticket.file.FileWrapper.clear(FileWrapper.java:90)
at de.iV.beans.ticket.Ticket.clearFiles(Ticket.java:155)
at de.iV.session.CustomSessionListener.sessionDestroyed(CustomSessionListener.java:46)
at com.ibm.xsp.application.ApplicationSessionListener.sessionDestroyed(ApplicationSessionListener.java:53)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.notifySessionRemoved(ComponentModule.java:370)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.checkSessionTimeout(ComponentModule.java:239)
at com.ibm.domino.xsp.module.nsf.NSFComponentModule.checkTimeout(NSFComponentModule.java:213)
at com.ibm.domino.xsp.module.nsf.NSFService.checkTimeout(NSFService.java:281)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.checkTimeout(LCDEnvironment.java:247)
at com.ibm.designer.runtime.domino.bootstrap.BootstrapEnvironment.tellCommand(BootstrapEnvironment.java:388)
at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.tell(XspCmdManager.java:92
(安全性)
java.lang.SecurityException: Zugriff auf die Datei {0} bzw. diese zu ändern ist nicht zulässig
at lotus.notes.AgentSecurityManager.checkDelete(Unknown Source)
at java.io.File.delete(File.java:1047)
at de.iV.beans.ticket.file.FileWrapper.clear(FileWrapper.java:94)
at de.iV.beans.ticket.Ticket.clearFiles(Ticket.java:155)
at de.iV.session.CustomSessionListener.sessionDestroyed(CustomSessionListener.java:46)
at com.ibm.xsp.application.ApplicationSessionListener.sessionDestroyed(ApplicationSessionListener.java:53)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.notifySessionRemoved(ComponentModule.java:370)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.checkSessionTimeout(ComponentModule.java:239)
at com.ibm.domino.xsp.module.nsf.NSFComponentModule.checkTimeout(NSFComponentModule.java:213)
at com.ibm.domino.xsp.module.nsf.NSFService.checkTimeout(NSFService.java:281)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.checkTimeout(LCDEnvironment.java:247)
at com.ibm.designer.runtime.domino.bootstrap.BootstrapEnvironment.tellCommand(BootstrapEnvironment.java:388)
at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.tell(XspCmdManager.java:92)
我无法找出解决方法。
答案 0 :(得分:1)
您有2个选择:
稍后:它并不像听起来那样可怕。您的插件将位于updatesite.nsf
中检查this deck以获得入门信息。
答案 1 :(得分:1)
我进行了快速测试,一切正常。 ND9和ND10。
会话侦听器,“会话已销毁”事件中的文件删除,未修改java.policy。
编辑: 知道了它与文件删除无关。从“会话已销毁”事件访问NSF中的类时,这是ClassLoader问题。