大家好 我有一類在XML定義非法訪問:該Web應用程序實例已停止已
<bean id="appStarter" class="com.myapp.myClass" init-method="init" destroy-method="destroy"/>
myClass的一個初始化方法:
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);
.
.
.
}
我不知道爲什麼,任何想法?
正確的,它發生在取消部署後,我不殺這個線程,如何做到這一點,請指教? – 2011-02-09 13:12:03
確定一些搜索後,我對代碼進行了一些更改,但仍然出現相同的錯誤,您能否看到上面代碼中的更改? – 2011-02-09 13:20:56