Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.NoSuchMethodError: <init> when running in a Thread

843829Jun 8 2006
I have a Java class that calls a C++ function (JNI) and the return of that function is a Java object:

There�s the problematic C++ code:
jclass taskDescriptorClass = env->FindClass("a/b/TaskDescriptor");
if (taskDescriptorClass == NULL) {
	//Class cannot be found
	return NULL;
}

jmethodID constructorMID = env->GetMethodID(taskDescriptorClass, "<init>", "void(V)");
if (constructorMID == NULL) {
	return NULL;
}
This code as always behaved as expected, running in a JUnit test. But now I�m calling the code inside a thread (new Thread(new Runnable() { public void run() { ...NATIVE CALL...), but now I�m getting an exception:
Exception in thread "thrd1" java.lang.NoSuchMethodError: <init>
	at a.b.JTLs.createTask(Native Method)
	at a.b.GrammarBuilder.build(GrammarBuilder.java:216)
	at a.b.GrammarManager.getModel(GrammarManager.java:230)
	at a.b.GrammarManager.getModel(GrammarManager.java:146)
	at a.b.TestGrammarManager$1.run(TestGrammarManager.java:58)
	at java.lang.Thread.run(Thread.java:595) 
I�m using J2SE 5 update 06
Does anyone know why is this happening?
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 6 2006
Added on Jun 8 2006
0 comments
523 views