嗨,当我运行一个线程时,我遇到了NoClassDefFoundError异常。
当我不使用线程执行此进程时,它可以正常运行,但是当我执行start方法时,在不同的语句中会出现这个错误。
线程是否可能有与主线程不同的类路径?
谢谢。
编辑以添加代码:
运行方法:
public void run(){
try{
boolean startAction = HeapThread.addAction(idCliente, idThread, Constants.ACTION_CREATE_TOPIC);
if (!startAction) {
synchronized (this){
this.wait();
}
}
createTopic();
}
catch(Exception ex){
log.error("Error", ex);
}
finally {
Long nextIdThread = HeapThread.getNextAction(idCliente, idThread, Constants.ACTION_CREATE_TOPIC);
if (nextIdThread > 0){
log.debug("Thread");
ThreadState thread = HeapThread.getState(nextIdThread);
synchronized (thread) {
thread.notify();
}
}
}
}
createTopic() 函数调用 searchBlog(),在这里我调用了 this。
try{
sessionId = SessionWS.createSession(url, false);
CrawlerSearch crawler = new CrawlerSearchAPIService(new URL(url + Constants.URL_CRAWLER), new QName(Constants.QNAME_CRAWLER, "CrawlerSearchAPIService")).getCrawlerSearchAPIPort();
// para cada topico obtnemos 10 blogs
for (Long idTopic : blogsTopics.keySet()) {
完整的异常信息如下:
java.lang.NoClassDefFoundError: com/befasoft/common/business/webservices/client/Session
at com.befasoft.common.business.webservices.client.SessionAPIService.getSessionAPIPort(SessionAPIService.java:56)
at com.befasoft.common.business.webservices.SessionWS.createSession(SessionWS.java:21)
at com.humanlike.web.tools.Crawler.searchBlogs(Crawler.java:50)
at com.humanlike.web.theads.CreateTopic.createTopic(CreateTopic.java:164)
at com.humanlike.web.theads.CreateTopic.run(CreateTopic.java:63)
ClassNotFoundException
而不是NoClassDefFoundError
。 - Marko Topolnik