PRB: NoClassDefFoundError Accessing a COM Object Through JavaID: Q178560
|
When executing a Java Application that calls a COM object like an ATL Server, you may sometimes get the following error message on the COM object:
The error occurs on the line where you create a new COM object in the Java Class.error: java.lang.NoClassDefFoundError:
One reason why you may get this error could be related to missing parameter attributes for the methods in the COM object's IDL file.
Check your methods in the IDL file so that they have the right attributes like [in],[out],[retval] and so on. Once modifying the IDL file, rebuild your COM Server, and rerun JavaTLB or JACTIVEX on the COM Object's Type Library so that the changes gets reflected.
This behavior is by design.
........
interface ITest : IDispatch
{
[id(1), helpstring("Hello")] HRESULT TestMethod(BSTR* strGUID);
};
..........
.............
public:
STDMETHOD(TestMethod)(BSTR* a);
Following are its implementation:
// Test.cpp : Implementation of CTes
..................
STDMETHODIMP CTest::TestMethod(BSTR* a)
{
USES_CONVERSION;
*a = SysAllocString(T2OLE("This is a test!"));
return S_OK;
}
import atlserv.*; //This is your ATl Server Object
//created in Step 1.
public class Main
{
public static void main(String args[])
{
ITest a = (ITest) new Test();
String result[]=new String[1];
a.TestMethod(result);
System.out.println(result[0]);
}
}
interface ITest : IDispatch
{
[id(1), helpstring("Hello")] HRESULT TestMethod([out]BSTR*
strGUID);
};
For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java,
please see the following pages on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/
http://support.microsoft.com/support/java/
Additional query words: NoClassDefFoundError atl server com
Keywords : kbSDKJava300 kbSDKJava310 JCOM kbSDKJava320
Version : WINDOWS:1.0,1.1,2.0,2.01,2.02,3.0,3.1,3.2
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: July 13, 1999