Hello, I have been asked to make calls from EJBs to native c/c++ libraries using JNI. I have read that this is a bad idea but I don't know enough about how the two technologies would interact to be able to defend the notion of NOT doing this or proposing alternate solutions. Can anyone help me out with this? What I need are: -- Reasons why making JNI calls from an EJB are a bad idea. (Things like threading, transactions, etc. in detail on why its bad/dangerous) -- Possible work-arounds or other solutions. I've heard that using a separate RMI server to make the JNI calls might work....but I'm worried about scaleability and performance.
Jeff Wisard<br />Sun Certified Java Programmer (Java 2)<br />Sun Certified Web Component Developer
I don't see any problem with an EJB calling a C function via JNI. I'm actually doing something similar at the moment. I use SAP JCO, which is a Java API that wraps JNI calls to an SAP system, and we are using the adapter from our EJB code, so essentially we are making JNI calles. I would not make direct JNI calls from you EJB code. Create a wrapper or adapter that performs the JNI work, so it's easier to replace with anohter component in the future because I'm assuming that you are attempting to access a legacy system using this JNI code, right? You may run across a JCA adapter in the future, so swapping out the JNI code for the JCA adapter would be easier. Hope it helps, Raffi