12 Replies Latest reply on Apr 25, 2008 11:13 AM by peterj

    how to call native library

    xps2nini2000

      I want to call a .so file from my ejb application.Please tell me how to do that.

        • 1. Re: how to call native library
          peterj

          Are you looking for the Java code necessary to call into a .so, or are you wondering how to configure jbossas to locate the .so when your code invokes it?

          • 2. Re: how to call native library
            xps2nini2000

            yes my java code is calling a .so library .I want to know how to configure that path in jboss.

            • 3. Re: how to call native library
              peterj

              By default, the JVM sets the java.library.path system property, which is uses to locate shared objects, to the LD_LIBRARY_PATH. So as long as the LD_LIBRARY_PATH references the directory containing the .so file, you should be set.

              If you install JBoss Native, check the run.sh script because at one time it set java.library.path to $JBOSS_HOME/bin/native. If that is still the case, you need to set java.library.path to $LD_LIBRARY_PATH:$JBOSS_HOME/bin/native.

              • 4. Re: how to call native library
                xps2nini2000

                hi
                I have set my LD_LIBRARY_PATH .do you mean I shud create a folder named native in jboss_home/bin.And put my .so file over there???

                • 5. Re: how to call native library
                  peterj

                   

                  "xps2nini2000" wrote:
                  do you mean I shud create a folder named native in jboss_home/bin.And put my .so file over there???


                  No, that is not what I meant. I was merely giving you a warning on what could go wrong if you installed JBoss Native. If you have not installed JBoss Native, you can ignore that warning.

                  You can put your .so anywhere you like.

                  • 6. Re: how to call native library
                    xps2nini2000

                    I dnt 9 which version of jboss is this?? how to check whteher it is native or nor?

                    • 7. Re: how to call native library
                      peterj

                      JBoss Application Server (which you have) and JBoss Native are two different things and are two different downloads. If you did not download and install JBoss Native from http://www.jboss.org/jbossweb/downloads/jboss-native/?action=a&windowstate=maximized, then you do not have it.

                      • 8. Re: how to call native library
                        xps2nini2000

                        I am not having jboss-native. I have set my LD_LIBRARY_PATH.Still its not working.Please tell me what shud i do.

                        • 9. Re: how to call native library
                          xps2nini2000

                          its giving the following exception

                          Unexpected Error in method: public abstract java.util.ArrayList tr.TrRemote.loadText(java.lang.StringBuffer,java.lang.String,java.lang.String,java.lang.String,java.lang.String) throws java.rmi.RemoteException
                          java.lang.UnsatisfiedLinkError: tr.Wrapper.execute(Ljava/lang/String;)V
                          at tr.Wrapper.execute(Native Method)
                          at tr.Wrapper.nativeCall(SMTWrapper.java:26)

                          where tr bean is stateful ejb
                          tr remote is remote interface
                          Wrapper is class in which that library is called

                          I think library loaded exception is in calling the method

                          • 10. Re: how to call native library
                            peterj

                            Try running ldd against your .so to see if all of the libraries it needs are also in the library path. If any of them is missing your .so will not load.

                            Are you sure your .so if built correctly and is exporting the correct entry points? Can you load the .so from a simple Java application?

                            • 11. Re: how to call native library
                              xps2nini2000

                              As a standalone its running fine.I am just setting the path of .So file But this .So file is in turn using some perl scripts and one ini file.I have to use somebody else code.What shud i do.Please tell me.Thanx in advance

                              • 12. Re: how to call native library
                                peterj

                                Try adding the -verbose:jni to the JVM command line.

                                Do this for both the simple Java application that works, and for jbossas. Compare the output, that might give you some idea as to what the problem is.

                                Also, what did the ldd utility tell you?