Problem in loading Native libraries

While trying to load native libraries I'm getting the following error message
java.lang.UnsatisfiedLinkError: /XXX/XXX/libMySharedObj.so: ld.so.1: <JAVA_HOME>/bin/sparcv9/java: fatal: libskgxp10.so: open failed: No such file or directory
At which place the 'libskgxp10.so' file should present and from where I can get a copy of the same?
I'm using webLogic 8.15 on a solaris(5.8) box. The JVM has been started in 64bit mode with the options JAVA_VM="-server" and JAVA_OPTIONS="-d64" in the 'startWebLogic.sh' script.
Any idea to fix this issue?

Suspecting the same, I've tried to run the application in the same machine where the shared object has been created.
This time I got the error message as
java.lang.UnsatisfiedLinkError: /XXX/XXX/libMySharedObj.so: ld.so.1: <JAVA_HOME>/bin/java: fatal: /XXX/XXX/libMySharedObj.so: wrong ELF class: ELFCLASS64.
I have created the native library 'libMySharedObj.so' by the following way
gcc -c xxx.c
gcc -c yyy.c
gcc -c zzz.c
ld -G xxx.o yyy.o zzz.o -o libMySharedObj.so -lm -lc -lpthreadPlease advice if I'm taking the wrong track somewhere or with any alternative approach.

Similar Messages

  • Loading native libraries

    Hi,
    The other day a came across an UnsatisfiedLinkError with the message "... already loaded in another classloader". I saw the JNI specification states a native library is only permitted to be loaded by a single classloader. My question is why is this the case? What if I have two indipendent applications running on the same JVM instance, and both rely on the same native library? the problem with these native libraries is that there is no classloader delegation architecture when loading one(as there is with java classes), the library will always be loaded by the calling classes' classloader. So what can a developer do? What is the idea behind this behavior?
    Any help is appreciated....

    Thanks for your answers,
    The thing is -
    1) I don't really want to load the library again, I
    simply wish there will be no exception if I attempt to
    load it again from a different classloader. After all,
    what does it matter from which classloader i try to
    load the library? If it is the same classloader the
    method will simply return as if it loaded the lib
    succesfully(even though it didn't since it detected
    it's already loaded), why should there be any
    difference if it's not the same classloader? the
    library is already loaded anyway, all classes in the
    JVM instance will have access to it anyway....Write the code so that it checks for the already loaded exception.
    2) What if I one of my applications is a "third party"
    app in which I cannot change the code to load the
    library through my "library loader"?You are probably out of luck.
    Although I would question why you would want a third party library used by mutliple applications to be individually loaded. In J2EE containers the database drivers are loaded outside the class loaders probably for similar reasons.

  • Standalone OC4J 9.0.4 - Loading Native Libraries - Unsatisfied Link Error

    Hello,
    I incidentally happen to have a similar problem as has been described in several posts in this forum. The problem is that of loading Native libraries in OC4J.
    The scenario is
    1) Environment is Standalone OC4J 9.0.4, Windows 2000, JDK 1.4.2
    2) A Java wrapper loads DLL1 which internally loads DLL2.
    (To be more specific the DLL1 is a SAPSSOEXT.DLL and the DLL2 is SAPSECU.DLL. These are used for establishing SSO with SAP portal)
    The phase-1 of Java wrapper loading DLL1 is achieved by setting either the PATH or the java.library.path variables.
    The phase-2 of DLL1 loading DLL2 is what is failing with an Unsatisfied Link Error.
    Since I am using a standalone version and not a OC4J app-server, the OPMN related configuration for specified PATH variables will not be relevant here. Is there any other place where I can configure these.
    regards
    Shivaram

    A small correction to my observation above.
    The call to load DLL1 via System.loadLibrary() is successful. However when I attempt to call any method on it it fails with UnsatisfiedLinkError.
    Contrary to what was written above the error occured even before DLL1 attempted to load DLL2.
    So why is it that the call to loadLibrary is successful but the call to actual function is failing? (This works flawlessly on the command line)
    Is this a path problem, if so how do I configure it in OC4J standalone. Variables PATH, java.library.path, LD_LIBRARY_PATH none of them seem to have any effect on this.
    I tried debugging using a windows file monitor. The library DLL1 is being read from the correct path and is being opened successfully.
    Any suggestions will be greatly appreciated.

  • Problems with loading native library/missing methods: no ttJdbcCS1121

    Hi guys,
    Im getting this problem in glassfish 2.1, but in glassfish 3 or in tomcat, i dont get this problem. (Windows)
    Any thoughts?
    java.sql.SQLException: Problems with loading native library/missing methods: no ttJdbcCS1121 in java.library.path
    at com.timesten.jdbc.JdbcOdbcConnection.connect(JdbcOdbcConnection.java:1750)
    at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:305)
    at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:161)
    at java.sql.DriverManager.getConnection(DriverManager.java:525)
    at java.sql.DriverManager.getConnection(DriverManager.java:193)
    at com.summitinvt.mdaq.db.handler.DBConnector.getConnection(DBConnector.java:108)
    at com.summitinvt.mdaq.db.handler.DBConnector.initiateConnection(DBConnector.java:101)
    at com.summitinvt.mdaq.db.handler.DBConnector.<init>(DBConnector.java:34)
    at com.summitinvt.mdaq.db.handler.DBConnector.<init>(DBConnector.java:14)
    at com.summitinvt.mdaq.db.handler.DBConnector$DBConnectorUtil.<clinit>(DBConnector.java:24)
    at com.summitinvt.mdaq.db.handler.DBConnector.getInstance(DBConnector.java:28)
    at com.summitinvt.mdaq.rats.server.CommunicatorImpl.getPnLByCurrency(CommunicatorImpl.java:1074)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:592)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:207)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:243)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:291)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:666)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:597)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:872)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
    at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:382)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:264)
    at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    regards
    John

    A similar problem was reported before on this Forum - see
    Re: not able create connection to timesten
    checking the Release Notes I can see 11.2.1.8.0 has been tested against Glassfish 3 but I
    can't see any mention about Glassfish 2 in the v7 or v11 Release Notes (albeit only on a quick
    search).
    In my full install on XP, ttJdbcCS1121.dll is in C:\TimesTen\tt1121_32\bin

  • Problems with loading native library/missing methods:no ttJdbcCS in java.li

    Iam facing one problem while connecting the timesten client to the server The SQL Exception which Iam getting is pasted below:-
    Problems with loading native library/missing methods: no ttJdbcCS in java.library.path
    I am working with MAC OS X 10.7.2 and my timesten client version is 11.2.1.0
    I have also changed the Java Preferences from 64-bit to 32-bit but still whenever i tried to connect with the SQL Developer it gives me the above error.

    I just tried this out. My environment is OS X 10.7.4, Timesten (32-bit) client 11.2.1.9.0, SQL Developer 3.1.07, Oracle Java 1.7.0_04.
    The key things you need to be sure to do (in a terminal window) are:
    1. Be sure to . in the TimesTen environment script <tt_install_dir>/bin/ttenv.sh to set the full TT environment.
    2. Change directory to SQLDeveloper.app/Contents/Resources/sqldeveloper
    3. Run 'sh sqldeveloper.sh -J-d32'
    and all should be fine.
    Note that if you are using Java7 as I am then there is a step 1a. Change the CLASSPATH environment variable to specify ttjdbc6.jar not ttjdbc5.jar. For some reason running the app directly from Finder does not work even if you add -J-d32 into the sqldeveloper launch script. I'm still looking into that.
    Chris

  • Problems with loading native library missing methods ttJdbc1122.dll

    Problems with loading native library/missing methods: C:\TimesTen\tt1122_64\bin\ttJdbc1122.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform
    Hi,
    I have installed TimesTen 11.2.2 64-bit version on 64-bit windows 7.
    I have TimesTen 7 64-bit as well installed on my machice
    When trying to connect to TimesTen (Direct connection) using jdbc from eclipse, I get the following error "Problems with loading native library/missing methods: C:\TimesTen\tt1122_64\bin\ttJdbc1122.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform".
    The JDK version is 1.6.25 - 64 bit version.
    Please help me resolving this error.
    Thanks in Advance,
    Balamurugan

    Are you using SQL Developer?
    There is or used to be a restriction of only being able to using 32 bit. A suggestion might be to try the 32 bit client.

  • Problem with loading native library in java version "1.5.0_05"

    My application uses a native coded drawing. With java version 1.4.xx it was working just fine but with java 1.5.xx it gives the following error at the time of loading native library:
    java.lang.UnsatisfiedLinkError: /home/abyzov/tmp/friend32-1.6.02/libfriend.so:
    /home/abyzov/tmp/friend32-1.6.02/libfriend.so: undefined symbol: XtWindowToWidget
    I assumed that java loads all necessary X-libraries at start up but it seems to be not true for version 1.5.xx. Does anybody now about this kind of problems? Should I report it as a bug?

    I have this exact same problem. I developed an application all along using 1.4.2_08 to be exact no problems. I was forced to switch to 1.5.0_06, now when I try to run the app I get:
    java.lang.UnsatisfiedLinkError: <path to library>/libcomlib.so: <path to library>/libcomlib.so: undefined symbol: yp_get_default_domain
    I have tried compiling it in both 1.4.2_8 and 1.5.0_06 and it compiles perfectly but when I run with 1.5.0_06 it messes up.
    If you found the problem with this or anyone else has any advice please let me know.

  • Problems with loading native library/missing methods: no ttJdbc1121 in java

    Hi,
    Can anyone help me? I keep getting this error when trying to start my jboss server. I have no problem with this when i run my standalone java application. My jboss version is 4.2 and my timesten version is 11.2.1.6.1 . My oracle version is 10G express edition. Any ideas?
    Thank you very much.

    The TimesTen JDBC driver is not a pure Java driver. It requires to load several native code libraries. Most appservers have to be told what directories to search for those libraries (a bit like the O/S LD_LIBRARY_PATH variable). This error occures when you have not told the appserver where to look to find hte native code libraries (<tt_install_dir>/lib).
    I'm not a JBOSS expert so I can't advise you on this; you need to consult the JBOSS documentation to find out what parameter/setting you need to modify to fix this.
    Chris

  • Using native libraries in web application (weblogic on linux)

    I have a problem with loading native libraries for use with my web application. Where do I have to put them in order for the server to see them? The same app on windows runs perfectly fine, because it has no problems finding the dll files.
              So far I have tried modifying the weblogic startup scripts, to include the library in LD_LIBRARY_PATH environment variable. I've also tried modifying the security policy just in case, but I don't think it's the case, because like I said, the app ran fine on windows without messing with the policies. So, any ideas, how I could load the libraries?
              The system is a WebLogic 8.1SP4 installed on Linux i386 using JRockit JVM, the native library in question is JAI 1.1.3-alpha native acceleration library.
              PS. if it's in the wrong group, please direct me to the correct one.

    <p>Fukiku,</p>
              <p>Did you get this working?</p>
              <p>You can also try setting the environment variable java.library.path.</p>
              <p>Please post your stack trace to the forum as well.</p>
              <p>
              Hussein Badakhchani</br>
              </p>

  • Native libraries in ABAP runtime

    Hello
    I have a question. Im developing application which is doing lots of XML processing (quite complicated and time consuming). Since XML support in ABAP itself its very poor we decided to use Java libraries on external server. Comunication between java and abap is done via Jco. But ... the best solution could be if we could use native libraries (java or C JNI wrapper to java) in ABAP. Is there a method or approach to expose interface in ABAP OO and then code implementation to use native library. How to deploy such library in R3.
    I saw that all classes from iXML are connected somehow to native runtime.
    Does anybody know how to do that, or just can point me to any documentation or example ?
    Best regards
    Marcin

    Can you make sure this native library is in the PATH(Windows) or LD_LIBRARY_PATH
    (UNIX)?
    Cameron Purdy wrote:
    That has nothing to do with it being an EJB. It just means it can't find the
    code to call.
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Clustering Weblogic? You're either using Coherence, or you should be!
    Download a Tangosol Coherence eval today at http://www.tangosol.com/
    "marc claeys" <[email protected]> wrote in message
    news:3cd7e60a$[email protected]..
    Everywhere I read not to use (load) native libraries in a bean.
    However I couldn't find a reason for not doing so I tried.
    The loading of the lib. is successful but when trying to call
    a function of it I receive:
    java.lang.UnsatisfiedLinkError: beanHelloWorld
    Could someone explain why this happens?
    Thanks in advance
    Marc
    Rajesh Mirchandani
    Developer Relations Engineer
    BEA Support

  • Native Libraries

    What is the effect of loading native libraries into a WLS instance? Is this
    forbidden/frowned upon/ok ?
    One effect we have seen is that may be related is that if a native library
    is not properly unloaded - either via WLS crash or just poor programming,
    restarting the WLS instance is not possible as it belives that the port is
    still in use (by another process) What is the relationship here?
    thanks,
    g

    Loading native libraries is not recommended, however, not forbidden.
    Writing a stable native code is not easy, if your native code screws up
    (such as memory leak), in most cases, weblogic will screw up too.
    For restarting, if you restart weblogic, weblogic can use its port. Once
    weblogic is killed, OS will release its port for reuse.
    My 2 cents.
    Cheers - Wei
    Garrick Evans <[email protected]> wrote in message
    news:8itojp$b0j$[email protected]..
    What is the effect of loading native libraries into a WLS instance? Isthis
    forbidden/frowned upon/ok ?
    One effect we have seen is that may be related is that if a native library
    is not properly unloaded - either via WLS crash or just poor programming,
    restarting the WLS instance is not possible as it belives that the port is
    still in use (by another process) What is the relationship here?
    thanks,
    g

  • Error 0(Native: listNetInterfaces:[3]) and error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory

    Hi Gurus,
    I'm trying to upgrade my test 9.2.0.8 rac to 10.1 rac. I cannot upgrade to 10.2 because of RAM limitations on my test RAC. 10.1 Clusterware software was successfully installed and the daemons are up with OCR and voting disk created. Then during the installation of RAC software at the end, root.sh needs to be run. When I run root.sh, it gave the error: while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory. I have libpthread.so.0 in /lib. I looked up on metalink and found Doc ID: 414163.1 . I unset the LD_ASSUME_KERNEL in vipca (unsetting of LD_ASSUME_KERNEL was not required in srvctl because there was no LD_ASSUME_KERNEL in srvctl). Then I tried to run vipca manually. I receive the following error: Error 0(Native: listNetInterfaces:[3]). I'm able to see xclock and xeyes. So its not a problem with x.
    OS: OEL5 32 bit
    oifcfg iflist
    eth0 192.168.2.0
    eth1 10.0.0.0
    oifcfg getif
    eth1 10.0.0.0 global cluster_interconnect
    eth1 10.1.1.0 global cluster_interconnect
    eth0 192.168.2.0 global public
    cat /etc/hosts
    192.168.2.3 sunny1pub.ezhome.com sunny1pub
    192.168.2.4 sunny2pub.ezhome.com sunny2pub
    192.168.2.33 sunny1vip.ezhome.com sunny1vip
    192.168.2.44 sunny2vip.ezhome.com sunny2vip
    10.1.1.1 sunny1prv.ezhome.com sunny1prv
    10.1.1.2 sunny2prv.ezhome.com sunny2prv
    My questions are:
    should ping on sunny1vip and sunny2vip be already working? As of now they dont work.
    if you look at oifcfg getif, I initially had eth1 10.0.0.0 global cluster_interconnect,eth0 192.168.2.0 global public then I created eth1 10.1.1.0 global cluster_interconnect with setif. Should it be 10.1.1.0 or 10.0.0.0. I looked at the subnet calculator and it says for 10.1.1.1, 10.0.0.0 is the subnet. In metalink they had used 10.10.10.0 and hence I used 10.1.1.0
    Any ideas on resolving this issue would be very much appreciated. I had been searching on oracle forums, google, metalink but all of them refer to DOC Id 414163.1 but it does n't seem to work. Please help. Thanks in advance.
    Edited by: ayyappa on Aug 20, 2009 10:13 AM
    Edited by: ayyappa on Aug 20, 2009 10:14 AM
    Edited by: ayyappa on Aug 20, 2009 10:15 AM

    a step forward towards resolution but i need some help from the gurus.
    root# cat /etc/hosts
    127.0.0.1 localhost.localdomain localhost
    ::1 localhost6.localdomain6 localhost6
    192.168.2.3 sunny1pub.ezhome.com sunny1pub
    192.168.2.4 sunny2pub.ezhome.com sunny2pub
    10.1.1.1 sunny1prv.ezhome.com sunny1prv
    10.1.1.2 sunny2prv.ezhome.com sunny2prv
    192.168.2.33 sunny1vip.ezhome.com sunny1vip
    192.168.2.44 sunny2vip.ezhome.com sunny2vip
    root# /u01/app/oracle/product/crs/bin/oifcfg iflist
    eth1 10.0.0.0
    eth0 192.168.2.0
    root# /u01/app/oracle/product/crs/bin/oifcfg getif
    eth1 10.0.0.0 global cluster_interconnect
    eth0 191.168.2.0 global public
    root# /u01/app/oracle/product/10.1.0/Db_1/bin/srvctl config nodeapps -n sunny1pub -a
    ****ORACLE_HOME environment variable not set!
    ORACLE_HOME should be set to the main directory that contain oracle products. set and export ORACLE_HOME, then re-run.
    root# export ORACLE_BASE=/u01/app/oracle
    root# export ORACLE_HOME=/u01/app/oracle/product/10.1.0/Db_1
    root# export ORA_CRS_HOME=/u01/app/oracle/product/crs
    root# export PATH=$PATH:$ORACLE_HOME/bin
    root# /u01/app/oracle/product/10.1.0/Db_1/bin/srvctl config nodeapps -n sunny1pub -a
    VIP does not exist.
    root# /u01/app/oracle/product/10.1.0/Db_1/bin/srvctl add nodeapps -n sunny1pub -o $ORACLE_HOME -A 192.168.2.33/255.255.255.0
    root# /u01/app/oracle/product/10.1.0/Db_1/bin/srvctl add nodeapps -n sunny2pub -o $ORACLE_HOME -A 192.168.2.44/255.255.255.0
    root# /u01/app/oracle/product/10.1.0/Db_1/bin/srvctl config nodeapps -n sunny1pub -a
    VIP exists.: sunny1vip.ezhome.com/192.168.2.33/255.255.255.0
    root# /u01/app/oracle/product/10.1.0/Db_1/bin/srvctl config nodeapps -n sunny2pub -a
    VIP exists.: sunny2vip.ezhome.com/192.168.2.44/255.255.255.0
    Once I execute the add nodeapps command as root on node 1, I was able to get vip exists for config nodeapps on node 2. The above 2 statements resulted me with same values on both nodes. After this I executed root.sh on both nodes, I did not receive any errors. It said CRS resources are already configured.
    My questions to the gurus are as follows:
    Should ping on vip work? It does not work now.
    srvctl status nodeapps -n sunny1pub(same result for sunny2pub)
    VIP is not running on node: sunny1pub
    GSD is not running on node: sunny1pub
    PRKO-2016 : Error in checking condition of listener on node: sunny1pub
    ONS daemon is not running on node: sunny1pub
    [root@sunny1pub ~]# /u01/app/oracle/product/crs/bin/crs_stat -t
    Name Type Target State Host
    ora....pub.gsd application OFFLINE OFFLINE
    ora....pub.ons application OFFLINE OFFLINE
    ora....pub.vip application OFFLINE OFFLINE
    ora....pub.gsd application OFFLINE OFFLINE
    ora....pub.ons application OFFLINE OFFLINE
    ora....pub.vip application OFFLINE OFFLINE
    Will crs_stat and srvctl status nodeapps -n sunny1pub work after I upgrade my database or should they be working now already? I just choose to install 10.1.0.3 software and after running root.sh on both nodes, I clicked ok and then the End of installation screen appeared. Under installed products, I see 9i home, 10g home, crs home. Under 10g home and crs home, I see cluster nodes(sunny1pub and sunny2pub) So it looks like the 10g software is installed.

  • Diagnostic Problem: Native Libraries FOUND!!

    Hello All,
    I would like some help installing JMF2.1.1e.
    I'm using Windows XP. I installed it using the InstallShield, and my classpath & path were set to the relevant directory... however I get the following error when running the JMF diagnostic...
    JMF Version... 2.1.1e
    Win32 Build
    Native Libraries Found
    Can somebody please shed some light...
    Many thanks...

    That is not an error.
    That is what it should say.

  • The struggle of creating a Custom ClassLoader for Native libraries

    Hello Everyone,
    I'm having a really hard time writing and using my own ClassLoader in a Java Applet.
    Context :
    As the this link shows - http://codethesis.com/tutorial.php?id=1 - loading and especially unloading native libraries through Java requires defining our own ClassLoader, and use it to instantiate a class loading a library. When the class using native libraries has finished execution, setting all references to the classloader and calling the garbage collector will cause the native library to be unloaded. The class to load within the custom classloader is thus read byte after byte from the jar and defined using the Classloader.defineClass(..) function. So that's what I did. But I've got two problems.
    Problem 1 :
    On one single machine over 15 tested, the magic number of a given class read from the Jar using Applet.class.getResourceAsStream(classname) takes a value different from CAFEBABE and the defineClass function then throws an "Incompatible magic value" exception (see below). The workaround I found is to force the first 4 bytes of the byte array read from the class with CAFEBABE. But I still would like to understand why it takes a different value on this machine.
    Exception in thread "thread applet-MyApplet.class-1" java.lang.ClassFormatError: Incompatible magic value 409165630 in class file Reader
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at NativeClassLoader.findClass(Unknown Source)
    Problem 2 :
    On windows, the NativeClassLoader works perfectly, but on Linux, I'm getting a java.lang.VerifyError (see below).
    Code is compiled with java 1.6.0_06 on windows XP. I tried to remove everything related to native code (remove .so load), the same error is raised.
    java.lang.VerifyError: (class: Reader, method: <clinit> signature: ()V) Illegal instruction found at offset 1
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.newInstance0(Class.java:326)
    at java.lang.Class.newInstance(Class.java:308)
    Code :
    NativeClassReader (custom) :
    public class NativeClassLoader extends ClassLoader {
        //the unique instance of the NativeClassLoader
        private static NativeClassLoader instance;
        private NativeClassLoader () {
            super(NativeClassLoader.class.getClassLoader());
         * Get the Singleton instance of the class
        public static NativeClassLoader getInstance () {
            if (instance == null)
                instance = new NativeClassLoader();
            return instance;
        public static void dispose () {
            instance = null;
         * Load a class using its full java name (prefixed with package)
        public Class findClass (String theName) {
            byte[] b = null;
            try {
                b = loadClassDataFromJar(theName);
                Class clazz = defineClass(theName, b, 0, b.length);
                resolveClass(clazz);
                return clazz;
            } catch (Exception e) {
                return null;
         * Gets the bytes of a class file stored in the current jar using
         * its full class name
        public byte[] loadClassDataFromJar (String theName)
                                     throws Exception {
            String filename = "/" + theName.replace('.', '/') + ".class";
            InputStream is = SawsApplet.class.getResourceAsStream(filename);
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            //compute file size
            Vector vChars = new Vector();
            int c;
            while ((c = br.read()) != -1)
                vChars.add(new Byte((byte) c));
            //fill in byte array with chars read from the buffer
            byte[] buff = new byte[vChars.size()];
            //workaround for a bug on one (some) Vista machine(s)
            //force magic number to CAFEBABE instead of 18635F3E
            if (vChars.size() > 3) {
                buff[0] = (byte) 0xCA;
                buff[1] = (byte) 0xFE;
                buff[2] = (byte) 0xBA;
                buff[3] = (byte) 0xBE;
            for (int i = 4; i < vChars.size(); ++i)
                buff[i] = ((Byte) vChars.get(i)).byteValue();
            return buff;
    }Reader (loading native libary) :
    public class Reader {
       static {
         System.loadLibrary("myLib");
        public static native String getData();
    }Main :
        NativeClassLoader cLoader = NativeClassLoader.getInstance();
        Class clazz = cLoader.findClass("Reader"); // ClassFormatError thrown here
        Object reader = clazz.newInstance(); // VerifyError thrown here
        Method m = clazz.getMethod("getData");
        String s = m.invoke(reader);
        print(s);
        s = null;
        m = null;
        reader = null;
        clazz = null;
        cLoader = null;
        NativeClassLoader.dispose();
        System.gcAny ideas would be really appreciated :-)
    Guillaume

    Are you using the executable exe file and the filename as a parameter in the custom task?
    Andreas Baumgarten | H&D International Group

  • JMF with Native Libraries as Signed Applet

    Hello
    After spending a few days hunting through forums, digging into JMF source code and hacking in the dark I'm about to give up, but thought I'd start yet another thread on this. It's a long, sad story...
    Problem: Deploying a JMF based program that relies on native libraries (in this case the FOBS4JMF bindings) as an applet: how to get jmf.properties and the native libraries loaded properly.
    Partial Solution: the native libraries packaged in a signed jar file, added to the applet's archive property, extracted using getResourceAsStream(), and loaded using System.load(). This is how FOBS4JMF loads it's native library anyway (via the com.moesol.NativeLibraryFinder):
    Class classInApplet; // name of a class loaded by the applet
    File outputFile; // location for extracted library
    InputStream is = classInApplet.getResourceAsStream(resource);
    copyStream(is, outputFile);
    System.load(outputFile.getAbsolutePath());Why this doesn't really work:
    (a) JMF (com.media.util.Registry) only searches for jmf.properties (which contains the instructions to use the FOBS4JMF plugin) in real folders (i.e. not jars) on the classpath of the local machine. I could extract the jmf.properties to a folder on the local machine, but have no way of making sure that folder would be on the classpath. Calls to "System.getProperty("java.class.path") give varying results - including an empty string on FF/OSX. Even if i could get the classpath somehow, chances are that it wouldn't contain any folders writable under Vista's UAC, which would leave me out of luck.
    JMF also looks for a file called ".jmfdir" in various platform specific locations, and appends the contents of this file to the classpath, so if i could write to that file i'd be golden. This seems like it would work on non windows platforms, because JMF looks for that in "user.home"). However, from what i can tell, on windows, JMF uses a native call to a function called nGetUserHome() to determine where to find .jmfdir - which leads to the second problem...
    (b) the JMF native libraries are loaded through calls to System.loadLibrary(), not System.load(), which means that they have to be on the "java.library.path" in order to be found - and again, I have no way of extracting the libraries to a directory on that path (at least not one writable under Vista UAC). This wouldn't be a problem, as I could pre-load the libraries myself with System.load(), except that JMF throws an exception if it can't find one, and stops trying to do whatever it thinks it needs the library for. Again, not a problem if I use only the FOBS4JMF native code (though i would like to use the DirectAudio renderer on windows) - except that the nGetUserHome() function described above is in a native library (jmutil.dll). So, when com.media.util.Registry.getJMFDir() tries to find ".jmfdir" it first tries to load "jmutil.dll" using System.loadLibrary(). This throws an exception inf "jmutil.dll" is not on the "java.library.path", and com.media.util.Registry.getJMFDir() returns null. Here's the relevant code from com.media.util.Registry.getJMFDir() - with my annotations
    All of these problems are fixable by relatively minor tweaks to the JMF source - but I don't think that's allowed under the SCSL. So if anyone has any, i mean ANY other suggestions, please BRING 'EM ON.
    thanks
    -chris
    EDIT: just for kicks, i checked to see where JMF expects to find .jmfdir on windows - ie the result of nGetUserHome(). At least on XP this seems to be c:\WINDOWS. if it's the same on Vista, then fixing the loadLibrary problem won't help bc I still won't be able to write to this file.
    Edited by: wodenx on May 7, 2010 9:46 AM

    Hi-
    Thanks for responding so quickly.
    As far as the natives go, you might try using the new JNLP embedded applet ability in the plugin2 architecture.I was going to look into that, but decided it wasn't necessary since I can get the FOBS native code to link properly. It's really the registry that's the problem, since without solving that I can't get JMF to USE the FOBS code.
    Can you get it all to work if the JMF installer is invoked? If so, perhaps if you add an installer-desc that calls the normal JMF setup.exe (though that final warning to reboot is both unnecessary and odious).I don't think it would work even with the JMF installer, bc I need to point JMF at the FOBS specific jmf.properties. I might be get it to work by invoking my own installer though, to place my jmf.properties somewhere in the native class path, so that's worth looking at. Thank you. Problem there is that on Vista users would have to elevate to run the applet, which is not ideal.necessary and odious).
    Why do you particularly want to embed media in a web page?The customer may want it. I might be able to convince them to go with JNLP/WebStart, but I think I might have the same problem there. Please correct me if I'm wrong...
    I've also read that there are problems with JMF and JNLP owing to the fact that JMF doesn't recognize the security manager invoked by JNLP, and so gives your program no permissions. Haven't tried it myself yet.
    Thanks again!
    Edited by: wodenx on May 7, 2010 12:07 PM

Maybe you are looking for

  • Help Re-Installing Snow Leopard

    I got a new MacBook Pro today to replace my black MacBook from 2007, which I'm passing down to my husband. Tonight, in attempting to get it clean as a whistle for him, I put in the snow leopard disks to reinstall. First, I went through and erased the

  • Saving custom tone mappings

    I'm trying to save custom tone mapping curves for later reference and use.  I can record the "action" of constructing the curve in Image > Adjustments > Curves and applying it to an image.  Unfortunately the "actions" panel does an incomplete job of

  • Shuffle gen 1 will not be recognized by itunes

    The ipod gives a message "The iPod "IPOD" cannot be used b/c it requires itunes version 5.0 or later goo to www.itunes.com... to get the latest version of iTunes or install iTunes fro mteh CD that came with your ipod. I did install the CD that came w

  • Exposure profile edition

    Hi Experts, I am developing  the report where I need to add/delete documents connected to exposure(TR CBIH92). I have already deleted unused documents from hazards, but I cannot delete document before it exists in any regulations for exposure. Is the

  • How to dispaly large images?

    Hi! I have a simple problem, hope somebody could help me! I would like to display images from a LONG RAW type column of an Oracle database (Oracle8i Enterprise Edition Release 8.1.6.0.0) in a BC4J application. I use JDEV 9.0.3. The wizard generated e