Jca  and  jni

I hope some one can answer this question , as there is no much to read about JCA
my J2EE application needs to inetgerate with some C libraries, after some investigations , I found that calling native APIs direct from the EJBs might crash the EJB container when the JNI fails, as a better solution the JCA can be used as an intermediate layer, regarding the JCA-JNI communication I have 2 questions:
1- Is this setup EJB->JCA->JNI->C failsafe against the failure in the JNI->C part?
2- can the JNI wrapper be hosted on a remote server other than the application server or will I need to install the application server on the same machine as the C libraries

1) If you mean, does the app server continue running if your native code coredumps, the answer is no - This is the tradeoff you pay for speed.
2) Yes, but you're no longer going JCA->JNI. Rather, you're going JCA->X->JNI where X is some remotable protocol.
JCA is no magic layer - It's just a Java API between application servers and whatever library you intend to expose to your app server clients.
God bless
-Toby Reyelts

Similar Messages

  • Swing GUI and JNI

    Hello
    I am facing a problem related to Swing and JNI. Actually I have to call a native function on the action of a button, so I am using Swing to develop GUI. When I use Jframe and Jbuttons and on the action event of JButton when I call the native function of a different class, then the function works fine but suddenly program gets terminated. Program does not get terminated when I click on other buttons but when I click on the button containing native method, after clicking, the whole GUI frame gets removed and the program terminates. While debugging it does not give any error, infact the function works perfectly fine and the only thing that I came to know is that the application gets terminated and it displays "terminated, exit value : - 1073741819"
    Please help me out and reply as soon as possible.

    I imagine it depends on what's in the JNI code. Is this a JNI that you've created? Is it a large program? Can you post the code? Are you sure that you're compiling the C/C++ code with the correct parameters? (you may need to ask some of this in the JNI forum) Is it thread-safe? Are you calling its methods on the EDT?

  • Generating the .CAP, .JCA and .EXP files.

    Hello;
    I have downloaded the java_card_kit-2_1_2 to ‘C:\java_card_kit-2_2_1", and I tried to compile HelloWorld application that shipped with its distribution. I was successfully able to compile the file HelloWorld.java, but I am having lots of problems in generating the .CAP, .JCA and .EXP files.
    I tried to follow the instructions in jcdk2.2.1 user guide, but of no use.
    This is what I am basically doing:
    _Step1) Setting my Environment Variables as follows:_
    *set JC_HOME=C:\java_card_kit-2_2_1*
    *set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_16*
    *set PATH=.;%JC_HOME%\bin;%JAVA_HOME%\bin;%PATH%*
    _Step2) Compile the java file_
    The package of HelloWorld.java is : src.com.sun.javacard.samples.HelloWorld, so to compile I use the following command line:
    *javac -g -target 1.1 -source 1.3 -classpath .\classes;..\lib\api.jar;..\lib\installer.jar src\com\sun\javacard\samples\HelloWorld\*.java*
    _Step3) Converting_
    I have the class file generated in the package folder: src.com.sun.javacard.samples.HelloWorld, I generated an .opt file as follows:
    +-out EXP JCA CAP+
    +-exportpath .+
    +-debug+
    +-applet 0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x1:0x1 src.com.sun.javacard.samples.HelloWorld.HelloWorld+
    +src.com.sun.javacard.samples.HelloWorld 0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x1 1.0+
    Finally, the command line for conversion is:
    *set _CLASSES=%JC_HOME%\lib\apduio.jar;%JC_HOME%\lib\apdutool.jar;%JC_HOME%\lib\jcwde.jar;%JC_HOME%\lib\converter.jar;%JC_HOME%\lib\scriptgen.jar;%JC_HOME%\lib\offcardverifier.jar;%JC_HOME%\lib\api.jar;%JC_HOME%\lib\installer.jar;%JC_HOME%\lib\capdump.jar;%JC_HOME%\samples\classes;%CLASSPATH%;*
    *"%JAVA_HOME%\bin\java" -classpath %_CLASSES% com.sun.javacard.converter.Converter -config src\com\sun\javacard\samples\HelloWorld\HelloWorld.opt*
    After successfully executing all these lines, I get the following error:
    Java Card 2.2.1 Class File Converter, Version 1.3
    Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
    *+error: class HelloWorld does not belong to package src.com.sun.javacard.samples.HelloWorld.+*
    conversion completed with 1 errors and 0 warnings.
    PLEASE HELP! I also tried adding -classdir to the opt file, but still did not work.
    The whole point behind this exercise is to import a javacard framework of version 1.0
    Really appreciate anyone's help! Thanks in advance.

    Thank you Shane, but my claSs file is indeed saved in "C:\java_card_kit-2_2_1\samples\src\com\sun\javacard\samples\HelloWorld"
    Now since I am running my command lines from C:\java_card_kit-2_2_1\samples, so I guess that the class directory is:
    src.com.sun.javacard.samples.HelloWorld
    Right?

  • Difference between JNA and JNI ?

    Hi All ,
    I am very new to both of JNA and JNI . Could you please help me to find out the differences between them.
    Thanks and Regards,
    Allwyn

    Google ( [jni jna|http://www.google.com/search?q=java+jni+jna] ).

  • Difference between JCA and Jco.

    Hi Guys,
    I am a little confused between JCA and JCo, I am currently working with SAP Portal 6.0 according to its specifications JCo is a depricated and suggests the usage of JCA. On the other hand when I was reading about connecting to an SAP system using java, it suggests the usage of JCo. My knowledge with regard to JCo is limited, so I was wondering if anyone could throw some light here as to what is the difference in using either of them or rather which is the prefered way about going about it.
    Thanks in advance..
    Rajitha

    I think lancea is definitely on the right track.
    Jco is typically described as the way to use SAP from Java code and to use Java code from SAP. It is a specific API for allowing SAP and external Java code to call each other.
    JCA (J2EE Connector Architecture) is a general-purpose archiecture and API for allowing external systems and J2EE apps running in an app server to work together. To get a J2EE app working with SAP would require the use of an SAP connector, written to the JCA specs. More than likely, such a connector would itself use Jco. But the J2EE application code would use the connector, not the Jco code directly.
    I hope that helps.
    - Tim (Sun Microsystems)

  • Connect to SAP R/3 using JCA and SLD

    I have read a number of articles and code samples regarding back-end connections, but none of them provided the answer which is suitable for my situation.
    I want to build a portal application which calls a simple BAPI in a SAP R/3 system.
    The only requirements are that the application has to be set up according to the MVC pattern and the model will be exposed as a webservice.
    I am using web dynpro to create the views and tie the view, the controller and the model together. The model should connect to a SAP R/3 system accessing it via single sign on.
    I want the connection properties to be easily ajustable to make the application portable to another landscape, therefore I chose JCA to set up the connection.
    FYI: The SAP back-end systems are defined in the portal system landscape and also in the system landscape directory on the XI server.
    Does anyone know a good code sample/tutorial/how-to for setting up a flexible, easy manageable connection to a SAP back-end system?

    thanks, I can get the data from SAP R/3 to crystal report.
    but still dont know how to do the second question mentioned in previous message:
    once the table I want to get the data from is a cluster, and have found the mapping data dictionary of this data cluster, which displayed in crystal report connection as well, however, the data is not what I wanted.

  • JCA and global transactions

    First of all, I do apologize but I can't find a JCA topic, so I'm positng my question here
    In my application I want to use XA transaction across the resource adapter. I read an article on the Sun forum (Connector-interest archives section) about an association between XAResource and ManagedConnection instances. Anyway, let's say for Oracle JDBC driver you already have OracleXAConnection which will give you a variable of XAResource, the similar approach is used in the JMS (XAQueueConnection, XATopicConnection). My question is what is the strategy is used for the generic resource adapter (not nessessarily JDBC-specific) to implement XAConnection in other words from my client code I want to be able to do something like this:
    ConnectionFactory ccf = (ConnectionFactory)ctx.lookup("eis/mysampleRA");
    XAConnection xaconn = ccf.getXAConnection();
    XAResource xaRes = xaconn.getXAResource();
    Connection conn = xaconn.getConnection();

    Hi,
    You would have to go through an instance of ManagedConnection.
    These instances are internal in the pooling of the appserver, but you can get
    a new instance from the adapter by calling createManagedConnection.
    Best,
    Guy
    http://www.atomikos.com -- Insure your data with TransactionsJTA

  • How can I maintain a single connection between Forms 9i and JNI?

    I am creating a JNI interface into a legacy application written in Pro C. Currently this legacy system is accessed from Forms 6i through userexits. Under this setup the Pro C application is able to share the connection to the DB established by forms. I want to mimic this functionality over the web using JNI as the link between my web components and the legacy application.
    ie. I want to share the DB connection established by my web components with my Pro C application.
    Thus far I have been unable to find any documentation on how to do this.
    Any ideas would be very helpful.
    Information about how Oracle Forms shares its connection with userexits would also be helpful.

    The Pro*C application is linked in to Forms, and runs in the same process space, which is how the session is shared.
    You can't share the Forms session outside of Forms. So it's not possible to do what you want.
    Regards,
    Robin Zimmermann
    Forms Product Management

  • Invocation JVM and JNI library communication

    How do I communicate between my application that creates a VM, and the JNI libraries (with native functions) loaded by classes within the invoked VM?

    -Global variablesI doubt global variables inside the C app can be >accessed from JNI native methods.Whoops! Correct.
    -Primitives passed as argumentsSure, but there is an whole API in C I wan't to make
    available in Java.
    -Primitives as attributes in a classExplain? Attributes in class?Basically the same as the previous one. So probably no more useful.
    -C/C++ pointers passed as arguments or as class
    attributes using a java long to hold it.Yes, this is probably the way!You will probably find this is best.
    -Function callbacks.Presumably you control the code base for both sides of this. A JNI shared library can have normal shared library method calls in it. So use normal shared library protocols to access it. (I haven't tried it so there might be some interesting problems with initially resolving the thunks or there might not.)

  • Servlets And JNI.. real urgent help.

    Hi all,
    I have the JNI code integrated to the servlet .The servlet works fine at first time.but when i modified some source code of servlet (not native library) and redeploy it,then reload the same servlet in web browser ,i get "Native library already loaded in another classloader java.lang.UnsatisfiedLinkError" error.
    Any solution to this ???
    Thanks
    jetdvk

    Have you fixed this?
    I presume you are hot deploying the servlet ? if so then i also presume that you have either some static code or some run once code that loads your native code when your class is used for the first time.
    This code is being ran again as the class is being reloaded, therefore you have two choices,
    1) wrap the call loading the native library, and just ignore the exception. Then call a check method in the native code to make sure that the library was loaded.
    2) Move the code that loads the native library out to another class that is not hot deployed. Your servlet can call this when it is first accessed, and the other class will know whether it has already loaded the dll and will not attempt to load it again.

  • Servlets and JNI

    Hi,
    We have a C library which does financial computations and some of our customers have expressed the need to access our library from their servlets.
    This is why we have developed a JNI wrapper which encapsulates all functionality of our library.
    Now, do the specs allow using JNI in conjunction with servlets? I've studied the Java EE, JSP and servlet specs but JNI isn't mentioned anywhere...
    I've also found this thread with a quite similar question but without a clear answer whether it's allowed or not.
    -- Vincent

    yes, if the server's security policy allows it. In a basic server environment you can do just about anything you can do in a regular java application.

  • Map the XCreateWindow to Frame or window in C and JNI

    I am having a window which is created in C++ using 'XcreateWindow' function
    I am using JNI as a interface
    How do i get the Window Id / handle to java frame.
    If I am giving any actionlistener to my frame that has to be reflected in C window
    Anybody can send me the full source code too.

    Linux_Java wrote:
    How do i get the Window Id / handle to java frame.You can't get it from within Java, that much I know, and in fact since it is an OS construct it is meaningless in java. If you are working with MS Windows, I'm guessing that your best bet is to play with some of the functions in the User32 library, such as enumerateWindows and such, and by doing this you'll find out how to get a handle on the JFrame. If it's unix/linux (and given your name, that is a reasonable assumption) then I have no idea.
    If I am giving any actionlistener to my frame that has to be reflected in C windowNo idea what you mean here.
    Anybody can send me the full source code too.Doesn't this kind of go against the philosophy of these forums?
    Also, consider posting this sort of question in the JNI forum where you will have a much better chance of getting a JNI guru who actually knows what he's talking about instead of, well, me.

  • SAX and JNI

    I'm having problems using Java classes from C. I've managed to trace the problem as far as the SAX parser, but I have no idea why there's a problem at all.
    With the -verbose:jni option on, there's a message: "Unable to read from file" and then the JVM stops (crashes actually.)
    I create a VM as follows:
            JavaVM* jvm;
         JNIEnv* env;
         JavaVMInitArgs args;
         JavaVMOption options[3];
         int ret;
         args.version = JNI_VERSION_1_4;
         args.nOptions = 3;
         options[0].optionString = classPath;
         options[1].optionString = "-verbose:jni";
         options[2].optionString = "-Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl";
         args.options = options;
         args.ignoreUnrecognized = JNI_TRUE;
         if ((ret = JNI_CreateJavaVM(&jvm, (void **)&env, &args)) < 0) {
                /* error */
            }classPath is just a char* that lists all the Jars the project uses. I wrote a Java main() to test my code and when you run it with the exact same classpath, it works.
    The Java code that creates and starts the SAX parser looks like:
         XMLHandler handler = new XMLHandler ();
         SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser saxParser = factory.newSAXParser();
            try {
                 saxParser.parse(f, handler);
            } catch (java.io.IOException e) {
                 e.printStackTrace ();
            } catch (Exception e) {
                 e.printStackTrace ();
            }Is there something about JNI that SAX stuff won't work with it?
    Any help is greatly appreciated.

    D'oh!
    The java test code that "worked" actually used the wrong file name so the file didn't exist so it didn't actually execute the broken code.
    When I hard-code the absolute path to the file, I still get "Unable to read from file". So I guess the problem isn't with the JNI but somewhere else in my code.
    Thanks.

  • Static libraries and JNI / recursive libraries

    Hi @all,
    I've built and linked the C++ code, that's called via JNI by my Java application as a so (shared lib). This lib however, links with other libs, that are not shared but static. When I run my java application it can't resolve symbols from those libs.
    What can I do to make my Java program find those symbols?
    Thx

    That is non-sensical.
    Static linkage means it is in the dll itself. There is no way for them to not be available.
    As a guess the linkage is not static.

  • JCA and the common client interface

    Hi.
    (I may have posted this question in the wrong forum but, this seems to be the most active and more likely to atract the opinion of a few experienced developers)
    I wanted to ask the opinion of some of the more experienced developers... preferably those who have had experience integrating heterogeneous EIS/data sources into a common portal.
    This concerns Sun's JCA specification (available at: http://java.sun.com/j2ee/connector/index.jsp), particularly the CCI (common client interface) - chapter 15 - which defines a set of interfaces which EIS providers should support.
    Has anyone made any effort to upcast SAP interfaces to these 'standardised' interfaces?
    If so... are there any limitations/additional complication which other developers need to consider if they wish to employ this practice?
    If Not... Does this not defeat the objective of the JCA?

    Asalman,
    I'm quite happy the JDeveloper behaves the way it does. Why? Because in most of my scenarios I don't want to be driven in a particular direction of development. This my choice of development and I don't like tools that dictate this to me.
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for