Reputation: 403
Hi I got a exception NoClassDefFoundError when I run a thread. This process runs well when i execute without threads, but when I execute the start method, I got this error in different statements
Is it possible that threads got a different class path that the main thread?
thanks edit to add code
Run method:
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() function calls searchBlog() and there I call 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()) {
...
and full exception is:
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)
Upvotes: 4
Views: 412
Reputation: 403
Solver, I just have to especify the thread class loader with that
ct.setContextClassLoader(ClassLoader.getSystemClassLoader());
Thx Anantha Sharma for guide me
Upvotes: 1
Reputation: 26180
My guess is that com.befasoft.common.business.webservices.client.Session
had previously failed with ExceptionInInitializerError
. This gives NoClassDefFoundError
for subsequent calls. Check the log from beginning.
Upvotes: 1