非法访问:此 Web 应用程序实例已停止
2022-09-01 13:43:43
我有一个类,它有一个用xml定义的初始化方法
<bean id="appStarter" class="com.myapp.myClass" init-method="init" destroy-method="destroy"/>
我的类:
public class myClass{
private Thread t;
public void init() {
t = new Thread() {
@Override
public void run() {
while (true)
try {
doStuff();
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
}
};
t.start();
}
public void destroy() {
t.interrupt();
}
}
当应用程序启动时,这些线程运行良好,一切正常,过了一段时间,我得到以下异常。
INFO: Illegal access: this web application instance has been stopped already. Could not load com.sun.mail.imap.IMAPStore. 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:1273)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at javax.mail.Session.getService(Session.java:755)
at javax.mail.Session.getStore(Session.java:569)
at javax.mail.Session.getStore(Session.java:531)
at javax.mail.Session.getStore(Session.java:510)
在 doStuff 方法中:
public void doStuff(){
Session sessioned = Session.getDefaultInstance(System.getProperties(),
null);
Store store = sessioned.getStore("imap");
store.connect(hostName, userName, password);
.
.
.
}
我不知道为什么,有什么想法吗?