Multiple classes accessing the same DLL???

This behaviour is completely unacceptable.
Let's visualise my app:
There a 2 java classes:
     ClassA:
          public String[] getPaths(){
               return getNativePaths();
          public native String[] getNativePaths();
          static{
               System.loadLibrary("mylib");
          }     ClassB:
          public void setPaths(String[] paths){
               setNativePaths(paths);
          public native void setNativePaths(String[] paths);
          static{
               System.loadLibrary("mylib");
          }     MainClass:
          public void testA(){
               ClassB clsB=new ClassB();
               String paths[]={"c:\\test.txt"};
               clsB.setPaths(paths);
          public void testB(){
               ClassA clsA=new ClassA();
               String paths[]=clsA.getPaths();
          public void testC(){
               ClassA clsA=new ClassA();
               String[] paths=clsA.getPaths();
               clsA=null;
               ClassB clsB=new ClassB();
               clsB.setPaths(paths);
          }Method testA and testB in MainClass don't pose any problems, they work fine. :)
But when calling testC, I get this:
java.lang.UnsatisfiedLinkError: no mylib in java.library.path
     at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1403)
     at java.lang.Runtime.loadLibrary0(Runtime.java:788)
     at java.lang.System.loadLibrary(System.java:832)
     ...ClassA and ClassB both work good if used separately (another thread). But if we call one after another (same thread), an exception is thrown.
So, what's the problem here?
Is it the return of a string array?

1 remark:
If I do this:
    ClassA clsA=new ClassA();
    ClassB clsB=new ClassB();
    clsB.setPaths(clsA.getPaths());This works, but if you call the dll again after this, you'll get the same exception over and over again.
I think it has something to do with the release of strings (cause there isn't any).
My native code that returns an array of Strings:
    jobjectArray strArray=null;
    strArray=env->NewObjectArray(nSize,env->FindClass("java/lang/String"),env->NewStringUTF(""));
    // loop
    env->SetObjectArrayElement(strArray,nCount,env->NewStringUTF(dlg->GetNextPathName(pos)));
    nCount++;
    return strArray;

Similar Messages

  • Multiple classes in the same source file

    I'm not sure what this is called, having multiple classes in the same source file. At first I thought it ws called subclassing but then I googled it and found that subclasses are just derived classes. Here's an example of what I'm talking about.
    public class A {
    class B {
    class C {
    }So first of all, what is having multiple classes in the same source file called?
    Secondly, what are the advantages/disadvantages of this?
    Thirdly, can you have a class completely WITHIN a class (same source file but inside the class not outside) and what are the advantages/disadvantages of this?

    Advantage: You can reduce the number of source files specialy when your secondry classes are used only in the public class of the file.
    Disadvantage: Normaly it make things more clear if we have one-to-one correspondance of class and source files. This make things easy when you want to find the java file of a perticuler class file. Also If you later wanted to create a seperate public class with a same name as one of those secondry classes you got lots of changes to do.
    You can avoid this by creating them as nested classes
    ex:-
    public class MyPublicClass{
       private static class MyInnerClass{
    }this way the inner class will create a class file with name "MyPublicClass$MyInnerClass.class" instead of just "MyInnerClass.class"
    And also if you declare the inner class as public you can access them from out side

  • Multiple User Accessing the same record issue

    I am planning to design an app where we have the following use case requirement.
    If a user who is logged into the system is accessing a record(plan in this case) anyone else who is logged into the system at the same time should be locked out of that same plan but should still be able to access other plans in the system. A plan has many things associated with it so the 2nd user should be locked out of everything associated to the plan being accessed by the first user.
    What is the best way to implement this at the application or the database level?
    Here are some options we have been bouncing around.
    1. When the first user logs in and accesses the first plan we lock the plan at the app level using a singleton class which has one and only one instance on the app server. The plan_id can be put as an entry into a hashtable which can be in the session and is created if one does not exist. When the 2nd user tries to access the same plan, since the plan_id is still in the hashtable he would be locked out. However we somehow need to timeout the first user after 30 mts of inactivity or so so that others can access the plan and are not locked out for ever if the first user walks away from his PC or does not close his browser, thus keeping his session alive indefinitely.
    2. In the database in the plan table we add a column for 'locked'. When the first entry is created in the plan table locked column is marked as 'yes' or 1 and when the user closes the browser we use some javascript to trigger an event which changes that 'yes' or 1 to 'no' or 0 thus unlocking the plan. However the big issue we see in this concept is that we will have to put a javascript onUnload method in all jsp pages in the app because the user could be anywhere in the app after starting his plan access after login.
    Conceptually the 2 options are the same but one is done at the app whereas the other is at the database level.
    Is there a better way to handle this scenario using transactions or some other technological option.
    Thanks

    Another solution involving no modification of the database structure:
    As soon as a user want to access a plan, try to UPDATE the plan record... if it fails, the record was locked
    by another user before. When the user has finished with the plan, you can COMMIT or ROLLBACK the changes, which will free the lock for other users.
    An advantage of this solution is that if program crashes unexpectedly, there will automatically be a ROLLBACK.
    Of course, you need a transaction for this... and perhaps more if you want to separate the 'locking transaction' (virtual update just for restricting access) from the 'operating transaction' (in which you will
    do the DB stuff: inserts, updates, deletes, etc.)
    Hope this helped,
    Regards.

  • Multiple threads access the same method.

    Hello,
    I have been trying for a long time to find out multiple threads access the shared data.
    I have written a sample code, there I my intention is that method has to be accessed
    onlny one thread at a time., mean one thread finished the job, then next thread can
    access the shared source. But for this code I am not getting the desired out put what I want. But if I am using synchronized block I am getting the output. Please correct where I got mistake. Please see my code.
    public class TestThread implements Runnable {
         Shared r;
         public TestThread() {
              r = new Shared();
         public static void main(String args[]) {
              Thread t1 = new Thread(new TestThread());
              Thread t2 = new Thread(new TestThread());
              t1.setName("A");
              t2.setName("B");
              t1.start();
              t2.start();
          * (non-Javadoc)
          * @see java.lang.Runnable#run()
         @Override
         public void run() {
              // TODO Auto-generated method stub
              r.count();
    class Shared {
         public synchronized void count() {
              String name = Thread.currentThread().getName();
              System.out.println(name + ":accessed...");
              try {
                   for (int i = 0; i < 5; i++) {
                        System.out.println(name + ": " + i);
              } catch (Exception e) {
                   // TODO: handle exception
    }Thanks
    Bhanu lakshmi.

    It depends on what you synchronize. Non-static methods synchronize on the object, so if you're using several objects, you'll be able to call each from their own thread.
    Make your method synchronized or use only a single object and see the difference.

  • Prevent multiple users accessing the same form

    hi,
    i am working in forms
    i have a requirement like this
    if more than one user are using the same form and try to access the same record then the second user should not be able to do transaction
    he should be popped up with a msg saying that other user is working on it
    can any one suggest how to do this in my form
    thanks in advance
    selvaraj s

    That is pretty much exactly the way Forms works automatically.
    Two users can use the same form, and can even display the same data record. One of the users can make changes to the record -- Forms locks the row upon the FIRST keystroke in the first field the user begins to change.
    Once the row is locked, the second user is free to look at the record, and won't even know if another user has begun making changes. However, if second user tries to change even one field in the record, Forms pops up the message, "Could not reserve record (2 tries). Keep trying? Yes / No"
    There are also protections so if the first user actually changes the row and commits, then the second user tries to make a change. Forms will automatically detect whether changes were made, and if so, will undo the change and issue the message, "FRM-40654: Record has been updated by another user. Re-query to see change."
    The above automatic processing works very nicely. If it will not work for you, then what is it you need?

  • Multiple users accessing the same server.

    Ok here is my issue, about 2 months ago I started having issues with Filesharing on my 2012 Mac Mini running Lion server (current update). We have 3 users that VPN into our conpany network and usually access the same folder, 2 months ago they started conflicting with each other. When one VPNs into the network and connects to the server they are fine, if the second one connects to the network they are fine but if the second one tries to access the fileshare they knock the second one off the server. The first one's connection eventually hangs and they have to completely disconnect from the VPN. I am wondering if this was caused by a patch or if there is something else going on. I have tried to reboot the server and checked the logs for anything but I am not seeing what may be causing this. I have restarted the Filesharing in the Server app and still get the same problem, the users are connecting via local credentials to the server. I don't think it is a password issue since either user can log in and access as long as another user doesn't so I am not sure what the issue could be.
    any help appriciated,
    josh

    By 'standard record locking system' do you mean there is nothing I need to do programatically? No block level properties to change?
    So you are saying this is just the way it always works. So as soon as one of our call center agents opens a record all I have to do is create a pending update to any field?
    But won't another user be able to open the form and just query that record not knowing another user has it open?

  • Installing multiple instances accessing the same database

    Hi,
    I want to install two different instances of Oracle 10g in two different machines which will access the same database which will be stored in the shared storage.
    Is it possible to install them without installing RAC? The instances will be one active and the other passive, so the services will be up in one server and down in the other and the switching (shutting down one server and starting up the other) will be manual.
    Two servers will be running Linux and clustered in Linux level.
    Does Oracle offers this solution without installing Clusterware software?
    Thank you

    > The instances will be one active and the other passive, so the services will be up in one server and down in
    the other and the switching (shutting down one server and starting up the other) will be manual
    Missed this part as I was thinking proper cluster and RAC.
    This is neither. Yes, this can be done using two servers and shared storage.
    Is it a good idea? Not really. As this configuration does not provide redundancy at physical database level. You loose that storage.. bye-bye database. Does not matter whether you have a 100 backup servers that can be used.
    Thus the business reasons that you are trying to meet with this config have to be clarified and expectations determined.
    Separate servers using Data Guard will be a far more superior solution in many respects.

  • Multiple users accessing the same data in a global temp table

    I have a global temp table (GTT) defined with 'on commit preserve rows'. This table is accessed via a web page using ASP.NET. The application was designed so that every one that accessed the web page could only see their data in the GTT.
    We have just realized that the GTT doesn't appear to be empty as new web users use the application. I believe it has something to do with how ASP is connecting to the database. I only see one entry in the V$SESSION view even when multiple users are using the web page. I believe this single V$SESSION entry is causing only one GTT to be available at a time. Each user is inserting into / selecting out of the same GTT and their results are wrong.
    I'm the back end Oracle developer at this place and I'm having difficulty translating this issue to the front end ASP team. When this web page is accessed, I need it to start a new session, not reuse an existing session. I want to keep the same connection, but just start a new session... Now I'm losing it.. Like I said, I'm the back end guy and all this web/connection/pooling front end stuff is magic to me.
    The GTT isn't going to work unless we get new sessions. How do we do this?
    Thanks!

    DGS wrote:
    I have a global temp table (GTT) defined with 'on commit preserve rows'. This table is accessed via a web page using ASP.NET. The application was designed so that every one that accessed the web page could only see their data in the GTT.
    We have just realized that the GTT doesn't appear to be empty as new web users use the application. I believe it has something to do with how ASP is connecting to the database. I only see one entry in the V$SESSION view even when multiple users are using the web page. I believe this single V$SESSION entry is causing only one GTT to be available at a time. Each user is inserting into / selecting out of the same GTT and their results are wrong.
    I'm the back end Oracle developer at this place and I'm having difficulty translating this issue to the front end ASP team. When this web page is accessed, I need it to start a new session, not reuse an existing session. I want to keep the same connection, but just start a new session... Now I'm losing it.. Like I said, I'm the back end guy and all this web/connection/pooling front end stuff is magic to me.
    The GTT isn't going to work unless we get new sessions. How do we do this?
    Thanks!You may want to try changing your GTT to 'ON COMMIT DELETE ROWS' and have the .Net app use a transaction object.
    We had a similar problem and I found help in the following thread:
    Re: Global temp table problem w/ODP?
    All the best.

  • What happens when multiple users access the same servlet?

    Do the users share all the same resources? Or is a new process generated for each user? I have a servlet that builds a string to return to the user and I only have myself to test, so I can't really see what happens when many users access the servlet. Is there a possibility that the string will get screwed up, like when dealing with multiple threads, or do all the users get their own resources and I don't have to worry about that?

    huh? if you can point a test servlet at it, you can point a browser at it (even if the servlet does not serve html it will run)
    try pasting the servlet URL into a web browser
    refreshing multiple browsers repeatedly could provide a manual test

  • How to use multiple instances of the same dll ?

    Hi,
    I'd like to use multiple instances of a jni dll . I have created
    different threads, in each thread, I have called System.loadLibrary(..),
    and I would like each thread to access a different instance of this
    library.
    Unfortunately, the loadLibrary function is effective only once so I
    can not find the way to do this.
    Can anyone help me on this ?
    Thanks.
    Francois.

    Hi, :)
    and I would like each thread to access a different
    instance of this library.In Win32, this is outright impossible. A DLL will only exist once in a process space.
    In Unix, or at least in Solaris, I think this is also not possible, as libraries are loaded by the dynamic linker, and it keeps tabs of which modules have already been loaded into the process space.
    I'm assuming your problem is that your native library has non-reentrant code.
    If so, there are two approaches you can take to this:
    1) If you have access to the source code for the native library, change it so that it is reentrant.
    2) If you do not, change your Java code so that access to the native code is made from whithin synchronize blocks.
    If your problem is of a different nature, I'll second the words of the previous poster and ask you what it is...
    Cheers,
    J.

  • Multiple Users accessing the same core set of queried data

    Hi. We have a small call center and we want to build an app where the users can query the same core set of data and use it to initiate calls to study participants. The trick is that they will also need to update each record with information from the call. So we need to stop two call center agents from potentially calling the same participant at the same time.
    Is there a good method or best practice for creating a app to do this? The concern is that multiple call center agents would be querying the screen with the same core set of records (for example, querying by 'Ready for Call' status). When a call is placed the agent will have a conversation with the participant and ultimately end up updating the record after about 10 minutes. So my question is whether there is a good way to keep multiple agents from working with the same record (e.g. calling the same participant simultaneously)?
    Right now it seems that Oracle will lock a record for update, but only after an agent has initiated a change to the record. This still leaves a window of opportunity for two or more agents to be calling the same participant at the same time.
    Any thoughts or ideas on this would be greatly appreciated. Thanks so much.

    By 'standard record locking system' do you mean there is nothing I need to do programatically? No block level properties to change?
    So you are saying this is just the way it always works. So as soon as one of our call center agents opens a record all I have to do is create a pending update to any field?
    But won't another user be able to open the form and just query that record not knowing another user has it open?

  • Please help! Multiple users accessing the same data sets

    Hi all,
    Can anyone provide a bit of insight in to a question I have?
    We have two users that require to see the same set of data in the BPC Excel interface at the same time. The information is employees and date.
    User 1 would like to see All Employee SignedData for 1 month, and User 2 would like to see just a slice of the Employees for 1 month.
    If both of the Users are logged in at the same time, what will happen in terms of SAP 'locking' the data set? I am aware of Data Access Profiles to restrict their access to particular Master Data but there will be the requirement for users to see (maybe just in read-only), data that is shared between both Users.
    Will it throw up an error or can I make it so that users have 'read only' access?
    Any advice would be very much appreciated!
    Nick

    Hi Nick,
    No issue with that at all.
    They can even both have write access. If they try to update the exact same record at the same time BPC will just keep writing Delta records.
    User A enters 10
    User B enters 20
    User A refreshes and will get 20
    User B refreshes and also gets 20

  • Problem with multiple threads accessing the same Image

    I'm trying to draw into one Image from multiple threads. It works fine for a while, but then suddenly, the image stops updating. Threads are still running but the image won't update. I'm using doublebuffering and threads are simply drawing counters into Image with different speed.
    It seems like the Image gets deadlocked or something. Anyone have any idea what's behind this behavior or perhaps better solution to do such thing.
    Any help will be appreciated.

    Sorry Kglad, I didn't mean to be rude. With "No coding
    errors" I meant the animation itself runs with no errors. I'm sure
    you could run the 20 instances with no freezing (that's why I put
    the post :) ) But I'm affraid it is an animation for a client, so I
    cannot distribute the code.
    Perhaps I didnt explain the situation clearly enough (in part
    because of my poor english...).-
    - By 20 instances I mean 20 separated embedded objects in the
    html
    - The animation is relatively simple. A turned on candle, in
    each cycle I calculate the next position of the flame (that
    oscilates from left to right). The flame is composed by 4
    concentric gradients. There is NO loops, only an 'onEnterFrame'
    function refreshing the flame each time.
    - It's true that I got plenty variables at the _root level.
    If that could be the problem, how can I workaround it?
    - It is my first time trying to embed so many objects at the
    same time too. No idea if the problem could be the way I embed the
    object from the html :(
    - The only thing I can guess is that when a cycle of one of
    the object is running, the other 19 objects must wait their turn.
    That would explain why the more instances I run, the worst results
    I get. In that case, I wonder if there's a way to run them in a
    kind of asynchronous mode, just guessing...
    Any other comment would be appreciated. Anyway, thanks a lot
    everybody for your colaboration.

  • Can multiple Macs access the same firewire volume simultaneously?

    I have a firewire drive and hub, and two Mac Minis. I would like to use this hardware to build an Oracle 10g Real Application Cluster (RAC). To do this, both Macs would have to be able to read/write blocks on the same volume on the firewire drive (Oracle prevents collisions). Newer Linux kernels have support for doing this. It seems that the Mac OS X Server 10.3.4 that I am using blocks at the volume level by node. It would seem to preclude my using this hardware unless I devote another machine to being an NFS server for the shared storage. I'm looking for possible kernel tricks to get this to work.
    Jeremiah
    Mac Mini   Mac OS X (10.3.4)  

    According to Oracle's white paper on RAC:
    The type of disk storage used can be network attached storage (NAS), storage area network (SAN), or SCSI disk.
    It does go on to say:
    Alternatively Oracle supports the use of raw devices and some cluster file systems such as Oracle Cluster File System (OCFS) which is available on Windows, Linux and Solaris
    I suppose if Oracle is taking over the raw device, support might be possible, but OCFS is not available for Mac OS X.

  • Multiple controllers accessing the same model object?!

    Hi all,
    I have a rather simple but really fundamental question. I am implementing an application which
    communicates with a camera. My application main window is controlled by "MyController" class,
    which has a "Camera" object "myCam" and a "capture" button. I would like to add "continuous
    capture" functionality. I have subclassed NSButton(CameraCaptureButton class) and set in IB
    the identity of the button. In the new class I have also the methods mouseUp/mouseDown which
    are properly working. The problem now is how to send messages to "myCam" from CameraCaptureButton class. There is some sample code(mine is much more complex but I will extract only the part that I am interested in):
    //CameraCaptureButton.h
    #import "CameraCaptureButton.h"
    #import "MyController.h"
    @implementation CameraCaptureButton
    - (id)initWithFrame:(NSRect)frame
    self = [super initWithFrame:frame];
    if (self)
    // Initialization code here.
    return self;
    - (void) mouseDown:(NSEvent *)theEvent
    //some pictures which are also set correctly
    NSImage* buttonDown = [NSImage imageNamed:@"ReleaseFpsButtonDown.png"];
    [self setImage:buttonDown];
    NSLog(@"capture button down");
    - (void) mouseUp:(NSEvent *)theEvent
    //some pictures which are also set correctly
    NSImage* button = [NSImage imageNamed:@"ReleaseFpsButtonOn.png"];
    [self setImage:button];
    NSLog(@"capture button up");
    @end
    //MyController.h
    #import <Cocoa/Cocoa.h>
    #import "Camera.h"
    @interface MyController : NSWindowController
    Camera* myCam;
    Thank you in advance for any post!

    The functionality is implemented and working. Ray if you read this: Thank you! Below I post the most important parts of my code, I will appreciate any comments or suggestions for better implementation( for example should I 'retain' the camera object in the setter method or is it already retain by the call in the header file?!)!
    // MyController.h
    #import "Camera.h"
    @interface MyController : NSWindowController
    /*some mode definitions*/
    Camera* leCamera;
    /*some more definitions*/
    @property (nonatomic, retain) Camera *leCamera;
    /*some more methods and properties*/
    @end
    // MyController.m
    #import "MyController.h"
    @implementation MyController
    - (id)init
    if (self = [super init])
    Camera* cam = [[Camera alloc] init];
    [self setLeCamera: cam];
    ...some more code...
    return self;
    -(void) setLeCamera: (Camera*) cam
    leCamera = cam;
    - (Camera*) leCamera
    return leCamera;
    @end
    // CameraCaptureButton.m
    #import "CameraCaptureButton.h"
    #import "MyController.h"
    #import "Camera.h"
    @implementation CameraCaptureButton
    - (id)initWithFrame:(NSRect)frame
    self = [super initWithFrame:frame];
    if (self)
    return self;
    - (void) mouseDown:(NSEvent *)theEvent
    NSImage* buttonDown = [NSImage imageNamed:@"ReleaseFpsButtonDown.png"];
    [self setImage:buttonDown];
    MyController *delegate = [[NSApplication sharedApplication] delegate];
    Camera* cam = delegate.leCamera;
    int driveMode = [[cam camProp] driveMode];
    if(driveMode == 1)
    [cam releaseCam: 12];
    else
    [cam releaseCam: 0];
    - (void) mouseUp:(NSEvent *)theEvent
    NSImage* button = [NSImage imageNamed:@"ReleaseFpsButtonOn.png"];
    [self setImage:button];
    MyController *delegate = [[NSApplication sharedApplication] delegate];
    Camera* cam = delegate.leCamera;
    int driveMode = [[cam camProp] driveMode];
    if(driveMode == 1)
    [cam releaseCam: 13];
    @end
    Have fun!
    Regards
    - artOf...
    P.S. the mouseUp/down events seem to track by default the mouse, so when I am over the
    button and push it, it does as expected. Same for mouseUp, even if I hold the button pushed,
    drag the mouse outside my application and then release it I get the mouseUp event which is
    great I had so many problems in the .NET version with that

Maybe you are looking for

  • How can I create a Pooled VDI infraestructure using Win server 2012 as VM image?

    Hello I have followed the "usual" way to build a pooled VDI desktop using Win7 or Win8 with success, but it fails when I use an image of Win Server 2012 as VM instead.  Am I overlooking something?  Should I need to prepare the image in a different wa

  • Trying to split a table (so I can format across pages)

    Hi, I'm fairly new to a Mac and to using Pages 09 (I picked a great time to change systems when writing up something important!) How do I get a Table to split (as you can easily with MS Word) so that I can easily format my tables and text across mult

  • How do I print a pdf file that is printing too light to read??

    I have a pdf that I must print to buy a home.  It will not print as is. I shot screen shots, brought them into Photoshop, made them jpgs and adjusted the gamma to make them very black and white.  It helped but the pages cannot be read. There is plent

  • Webex Node Multi-Tenant Configuration

    Hi,      We are currently deploying webex node on ASR for a client, in the UC 8.x it mentions the ability to multi-tenant the node capabilityes e.g Page 22-9 "There is also the potential to deploy the WebEx Node for ASR in a multi-tenant capacity, in

  • Shelf life expiration dates for finished goods

    Hi, Is there any opportunities with in SAP to block the finished goods once it reaches the self life expiration goods AUTOMATICALLY.Our business requirement is particularly interested in this requirement.ONLY FINISHED GOODS,BLOCKING AUTOMATICALLY. UP