Possible thread issues when calling java from C++/Delphi/C#
843829Oct 10 2008 — edited Nov 10 2008Hi,
We have a java API for one of our applications. This API has wrapper API's in C++, Delphi and C#. There are two main top level classes in te API - Client and Receiver. Both haave a receive() method.
We used to ship JRE1.3 with the API installation - this was needed to suport the user applications. Recently we haev moved to java 1.4 as the least suported version.
We have two ways of using the java API in our wrapper API's.
Method one, we instantiate the client, and call client.receive(). There are no threads etc involved here. This is working fine.
In the second method, we set a callback on the client, which starts a thread (in C++/Delphi or C#) which calls receiver.receive() and tries to get the message. This is failing.
It fails at a line which simply says "DocumentBuilderFactory.newInstance()".
This call has already been made when connecting the client and it is successful because we can see the client connected.
Whether we do client.receive() or receiver.receive() in a thread, the code passes through this line.But is throwing the exception only when we come to it through a thread.
Any ideas on what I need to watch out for when calling methods on a JVM from a thread in C++/Delphi or C#?
Thanks
Hari
PS: I know we are using some really old versions, but thats needed and out of my control.