Trouble with JNI interface that use Microsoft COM object.

I try to call COM object from JNI code.

This is the C code:

void initializeComAPI()

{

if (!initialized)

{

OleInitialize(NULL);

// Create the RSS COM object and retrieve the default interface IID_IRSSComponent

hr = CoCreateInstance(__uuidof(RSSCOMObject), NULL, CLSCTX_ALL, IID_IRSSComponent, (void**)&pIRSSComp);

printf ("hr= %d, pIRSSComp= %d\n", hr, pIRSSComp);

if (hr != S_OK)

{

if (hr == REGDB_E_CLASSNOTREG)

{

printf ("A specified class is not registered in the registration database.\n");

}

elseif (hr == CLASS_E_NOAGGREGATION)

{

printf ("This class cannot be created as part of an aggregate.\n");

}

elseif (hr == E_NOINTERFACE)

{

printf ("The specified class does not implement the requested interface, or the controlling IUnknown does not expose the requested interface.\n");

}

}

else

{

}

// Query for the ConnectionPointContainer

//hr = pIRSSComp->QueryInterface(IID_IConnectionPointContainer,(LPVOID FAR*)&lpCPC);

// Find the event and advise

//hr = lpCPC->FindConnectionPoint(DIID__IRSSComponentEvents,&lpCPT);

//hr = lpCPT->Advise(&g_RSSEventDispatch,&dwEventCookie);

//SafeRelease(lpCPC);

}

}

JNIEXPORTvoid JNICALL Java_commons_symbology2525b_MS2525bSymbolBuilder_createSymbol

(

JNIEnv * env_p,

jclass class_p,

jstring code_p,

jstring destFilename_p)

{

if (!initialized)

{

initializeComAPI();

}

}

The java code is very simple:

publicclass MS2525bSymbolBuilder

{

static

{

System.loadLibrary("JNIRakuInteface");

}

publicstaticnativevoid createSymbol(String code_p, String filename_p);

}

We we launch this code with JDK1.4 and option -Xmx1024m, the COM object instance is well returned by the method CoCreateInstance.

If we test this code on JDK1.5 and 6.0, we can't set the option -Xmx1024m. The method CoCreateInstance returns REGDB_E_CLASSNOTREG. Without the option the COM object instance is created.

What can I do to increase the maximum JVM memory on this code.

thanks for your help !

[3818 byte] By [MFabiena] at [2007-11-27 0:14:39]
# 1

All I can suggest here is that you should probably investigate using this via a separate application rather than trying via JNI.

I base this on previous experience with COM and 1.4 where some of the COM methods would throw uncatchable system exceptions which would lead to the VM crashing.

Putting it in a separate app solved that problem. It also made it much easier to debug problems.

jschella at 2007-7-11 22:00:27 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

I have tested to call the COM interface from C code. There is not trouble. And moreover, with the jdk 1.4, the jni interface well works.

it is when I recompile the jni code and the java code with jdk1.5 or 6.0. There is no crash of JVM. The trouble is that the COM object can't be instanciated.

Thanks for your help.

MFabiena at 2007-7-11 22:00:27 > top of Java-index,Java HotSpot Virtual Machine,Specifications...