3 Replies Latest reply on Apr 27, 2004 5:58 PM by Jon Barnett

    JNI, JCA and dlls.

    itchyoinker Newbie

      I'm considering using JBoss, but would need to run .dlls from our previously written applications. I've read through some other posts and now understand that there are two methods for connecting to .dlls:

      1).placing .dlls in bin directory and accessing directly via JNI.
      2).using JCA/CORBA to access the .dlls.

      My guess is that the first method would provide the best performance, but placing .dlls in the bin seems kind of sloppy. Another issue is portablity from JBoss to another app server, which might not support running .dlls this way.

      Can anyone give me some pros and cons for these two (or any other) methods?

      Also, as far as I know, I could use a standalone Tomcat for accessing dlls directly via JNI. Would the app server give me any benefits over standalone Tomcat?

      Thanks for any replies,

        • 1. Re: JNI, JCA and dlls.
          Jon Barnett Master

          As previously stated (in the other thread), JNI is frowned upon in the EJB spec.

          JNI has a nasty habit of blowing up (either due to memory leaks or poor interfacing to the dll/shared library) so keeping it outside of the JBoss JVM helps protects your application and application server from falling over. JCA-CORBA-RMI/JNI all work to accomplish that by placing isolating the native calls by varying degrees.

          The only problem with CORBA is that usually you need an ORB framework - omniOrb only runs in a Cygwin environment on Windows so you'll probably MICO I suppose. CORBA is usually such a lot of work even to build some simple wrappers but Java at least has the tools to generate the call stubs on the JBoss end of things.

          If you are comfortable with building RMI/JNI services or JCA services, that might be easier.

          Hopefully someone else has some better ideas.

          • 2. Re: JNI, JCA and dlls.
            itchyoinker Newbie


            I can use JNI directly from a servlet on a standalone Tomcat, which would perhaps be the best performance of all solutions. So I'm still trying to think of a reason why an app server would benefit me in this case.

            Do I need to buy a bridge solution like J-Integra for connecting to C++ dlls? Or does the JCA give me that functionality for free? We have old Fortran stuff too, but we'd probably have to wrap that in C++ anyway. I'm obviously clueless, but can't find any good explanations on the Internet. Everything concentrates on EIS connections.

            I have to say, this is a really difficult decision for me. Thanks again for the input.


            • 3. Re: JNI, JCA and dlls.
              Jon Barnett Master

              The JCA gives you a J2EE-compliant solution. Essentially, EJBs should obtain external resources through the container services - the container shields the EJB from the external environment and manages access to the external resources. This arrangement can also help prevent overtaxing resources and deal with issues such as when an EJB gets passivated and so on. Where you might have a large number of EJB instances, you don't necessarily want to have a resource lock per EJB instance.

              EJBs aren't going to be the solution to everything. However, I find them a useful solution for enforcing scalable implementations, and ensuring the development of centralised business rules (Business APIs to steal from SAP) for access to data. I've seen a few commercial e-business applications using only servlets, and they have had both load-bearing issues, and transactional and data inconsistencies. For implementing large and complex business systems, EJBs make sense. YMMV.