lxbzmy / java-simple-serial-connector

Automatically exported from code.google.com/p/java-simple-serial-connector
0 stars 0 forks source link

Native Library will not link when user_home is read only. #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I found this issue on a vmware fusion workstation where the user_home 
variable points at a list of shared folders on the host machine rather than at 
the location of the local windows profile.  This issue is probably caused by 
VMWare fusion, not by Java, because I tried it in both JRE 1.6 and JRE 1.7 and 
both reference a read only user_home.
2. To duplicate it - make the user_home read only.
3. call SerialNativeInterface.getSerialPortNames();

What is the expected output? What do you see instead?
Expected is a list of local ports.  What we get back is an error: 
java.lang.UnsatisfiedLinkError: jssc.SerialNativeInterface.getSerialPortNames() 
at
jssc.SerialNativeInterface.getSerialPortNames(Native Method)

What version of the product are you using? On what operating system?
0.9 on Windows 7 running in a VMWare Fusion VM on Mac OSx Host.

Please provide any additional information below.
The problem is that the serial native interface class attempts to extract the 
library into the user_home.  

First off the class should throw an exception if it cannot extract the library 
and explain the issue so that someone doesn't have to look at the source to 
figure out why a call to a function within the class is failing.  If loadLib is 
false in the static block just before the system attempts to load the native 
library, throw an exception.  Better yet, if the directory is not writeable 
before, throw an exception when that is determined before we even get down to 
trying to load the library.

I suggest as a solution to create a property setter that overrides the 
user_home and allows the implementor to specify an alternate user_home.  That 
is how I am solving the issue for my application - I'm adding a variable and a 
setter for that variable.

I would be happy to contribute my patch, as well as create exceptions as per my 
suggestion above.  

Original issue reported on code.google.com by erich.pl...@gmail.com on 10 Feb 2013 at 2:48

GoogleCodeExporter commented 9 years ago
how to jSSC extract and load the native lib in static block using Ubuntu(Linux) 
machine can u tell me steps?

Original comment by karuna.f...@gmail.com on 15 Mar 2013 at 1:08

GoogleCodeExporter commented 9 years ago
I have problem here " java.lang.UnsatisfiedLinkError?????: 
jssc.SerialNativeInterface?????.openPort(Ljava/lang/String;)I"

using jssc 0.9.0 inside a tomcat application (war).

It is working properly in windows machine, but i am getting error in Ubuntu 
(Linux) Machine how to solve this error

S/W Details jSSC version : jSSC 0.9.0

    OS version : Ubuntu 10.4 Java version : 6 

Tomcat 6 Can any one help me? 

Original comment by karuna.f...@gmail.com on 15 Mar 2013 at 1:10

GoogleCodeExporter commented 9 years ago
The problem is that the JSSC connector attempts to determine the home directory 
and extract the library into that directory.  If JSSC cannot determine the home 
directory, or the home directory is read only, then it fails to extract the 
library.

I submitted suggestions for how to fix this issue and even offered to 
contribute the changes myself if the owner of this project would give me access 
to commit the change but heard nothing back.  So, I went ahead and forked the 
code myself and made the required changes to my code and recompiled it.

It's not very difficult - you just add an override parameter to the package 
with a location to extract the libs to, check for that parameter in the lib 
extractor code, and then extract to the specified lib directory.  I did this by 
creating a static configuration class where I set a static variable called 
libpath when I start using the JSSC connector.  Then the lib extractor looks at 
that static configuration class to see if there's a libpath specifies and 
extracts there if it is specified.  

Wish I could fix this for everyone, but could get no response from the author.

Good luck.

Erich

Original comment by erich.pl...@gmail.com on 15 Mar 2013 at 3:37

GoogleCodeExporter commented 9 years ago
Fixed in 2.4.0

Original comment by scream3r.org@gmail.com on 26 Apr 2013 at 11:56

GoogleCodeExporter commented 9 years ago
hi am getting this error when deploying the file in Ubuntu 10.04 please reply 
me how can i rectify  the error  my mail id srkvsivagiri@gmail.com 

java.lang.UnsatisfiedLinkError : 
jssc.SerialNativeInterface.openPort(Ljava/lang/String;)I
null

please give me a details setp to solve the problem 
waiting for u r reply 
thanks 

Original comment by srkvsiva...@gmail.com on 2 May 2013 at 2:18

GoogleCodeExporter commented 9 years ago
There is no solution in the current code base.  I downloaded the source and 
patched it myself.  This is how I did it.

1) I created a static singleton class to use to hold configuration - call this 
"SerialConfiguration" or something like that.  I have a String property in 
there called libraryPath.  This is the destination where I want to extract the 
libs to, where I know that I will have RW access to create folders and extract 
files.
2) In the JSSC code I modified the class that extracts the libraries to check 
first to see if SerialConfiguration has a libraryPath specified.  If so, then 
it uses this path as the extraction point.  If not, then it defaults to the 
standard JSSC way of finding the user_home and extracting there.
3) In my code outside of JSSC, I call this singleton and set the property 
libraryPath to a directory that I know I can RW to.  

Now, it works.

If I could get the owner of JSSC to give me access to the code, I would 
contribute my changes, but I haven't been able to reach him so the bug remains 
open.

Erich

Original comment by erich.pl...@gmail.com on 2 May 2013 at 6:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
hi sorry ya i tried in Ubuntu but failed to access ,ple correct and give i have 
attached my file 

Original comment by srkvsiva...@gmail.com on 3 May 2013 at 10:19

Attachments:

GoogleCodeExporter commented 9 years ago
You'll have to send me your full email address so that I can email you a copy 
of the jar directly.  

Original comment by erich.pl...@gmail.com on 7 May 2013 at 4:31

GoogleCodeExporter commented 9 years ago
hi my email id is srkvsivagiri@gmail.com .......i am getting an error in 
tomcat6 while loading the library ...its failed to load the library ... but i 
can run in eclipse and netbenas ..ple help me to resolve my problem am waiting 
for u r message my error is unsatisfied link error  

Original comment by srkvsiva...@gmail.com on 7 May 2013 at 2:45

GoogleCodeExporter commented 9 years ago
I just emailed you my patched jar.

Here's how you use it.

(1) put it in web-inf/lib folder so tomcat loads it.
(2) You'll need to add the following code before you try to do anything with 
JSSC:

JSSCProperties.libDirectory="/path/to/rw/directory";

This tells my patched JSSC jar file to extract the JSSC binary files into the 
directory that you have specified in the above line of code.

You will need to make sure that the directory you specify is RW for whatever 
user you are running tomcat with.

Good luck.

Erich

Original comment by erich.pl...@gmail.com on 8 May 2013 at 4:54

GoogleCodeExporter commented 9 years ago
hi i could not get any value from Ubuntu- tomcat6 using u r files ple give 
details steps 
my email id srkvsivagiri@gmail.com 

Original comment by srkvsiva...@gmail.com on 10 May 2013 at 5:43

GoogleCodeExporter commented 9 years ago
I suggest you first get it working on your machine and once your code works 
then try to move it to tomcat on Ubuntu.  

Original comment by erich.pl...@gmail.com on 10 May 2013 at 7:26

GoogleCodeExporter commented 9 years ago
hi Erich  i got the output thanks for the support :):) 

Original comment by srkvsiva...@gmail.com on 12 May 2013 at 7:03