Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

Automating web application with Jacob api and selenium is produces UnsatisfiedLinkError

Open 1 Answers 79 Views
0 1
I have used Jacob Api for uploading files on automating web application with selenium, but it produces UnsatisfiedLinkError. Am new for Jacob api to file upload so please help and thanks in advance.

Source Code:-

public class FileUpload {
    public static void main(String a[]){
        WebDriver driver;
        try {
            System.setProperty("", "/home/ionixx/workspace/IXAutomateNew1/chromedriver/chromedriver_linux");
            driver = new ChromeDriver();
            String workingDir = System.getProperty("user.dir");
            final String jacobdllarch = System.getProperty("")
                    .contains("32") ? "jacob-1.18-x86.dll" : "jacob-1.18-x64.dll";
            String jacobdllpath = workingDir + "/" + jacobdllarch;
            File filejacob = new File(jacobdllpath);
            AutoItX uploadWindow = new AutoItX();

            String filepath = workingDir + "/home/ionixx/Downloads/123.pdf";
            if (uploadWindow.winWaitActive("File Upload", "", 5)) {
                if (uploadWindow.winExists("File Upload")) {
                    uploadWindow.controlClick("File Upload", "", "&Open");
        } catch (Exception e) {
Only local connections are allowed.
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /home/ionixx/workspace/Test/jacob-1.18-x64.dll which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/ionixx/workspace/Test/jacob-1.18-x64.dll: /home/ionixx/workspace/Test/jacob-1.18-x64.dll: invalid ELF header (Possible cause: endianness mismatch)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(
    at java.lang.ClassLoader.loadLibrary(
    at java.lang.Runtime.load0(
    at java.lang.System.load(
    at autoitx4java.AutoItX.<init>(
    at FileUpload.main(
commented by (202 points)
can you post the screenshot of the upload button?

1 Answer

Usually  unsatisfied link error happens when you are running 32-bit JVM on 64-bit operating system.

Go to uninstall program window and remove any 32-bit JVM.

Check what version of JVM is installed in your PATH variable.

Also, make sure that your IDE is pointing to 64-bit JVM.

After making sure above steps, restart your IDE or the computer to make sure that you are using 64-bit JVM and your IDE is pointing to the same.
answered by (202 points)
commented by (12 points)
Am using 64 bit only
[email protected]:~$ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
[email protected]:~$
commented by (202 points)
Great! Now make sure that your IDE is pointing to 64-bit version. What IDE are you using?
commented by (12 points)
Eclipse Java EE IDE for Web Developers.

Version: Neon.1a Release (4.6.1)
Build id: 20161007-1200
commented by (202 points)
For Eclipse, to see/edit the version being used, go to Preferences -> Java -> Installed JREs.

If you see JDK you want in the list select it
If not, click Search…, navigate the location where your JDK is installed
Now you should see all installed JDKs, select the one you want
Click OK/Finish

You can restart your IDE and see if your JDK is reflected on your project,

Right-click your project > properties
Select “Java Build Path” on left, then “JRE System Library”, click Edit…
Select "Workspace Default JRE"
Click "Installed JREs"
commented by (12 points)
Preferences -> Java -> Installed JREs shows installed library for Name=>java-8-Oracle, Location=>/usr/local/jvm/java-8-oracle, Type=>Standard VM.

Whether i need to change it?
commented by (202 points)
I just realized that JACOB uses native COM library from Windows.

Apart from JDK configuration, we should first make sure that you have all COM components in place.

Can you install wine for Linux? But, I doubt that AutoIT and JACOB will work on  Linux based GUI.
commented by (12 points)
In error shows like "It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'. "

I have tried with following way, but got "not an ELF file" error

> execstack -c /home/ionixx/workspace/Test/lib/jacob.jar
    execstack: "/home/ionixx/workspace/Test/jacob-1.18-x64.dll" is not an ELF file
> execstack -c /home/ionixx/workspace/Test/jacob-1.18-x64.dll
   execstack: "/home/ionixx/workspace/Test/jacob-1.18-x64.dll" is not an ELF file
commented by (202 points)
I looked into below thread and it looks like WINE with JACOB is not possible yet.
commented by (202 points)
Yes, those errors you ought to get because there is no compiler for your DLL files on your Linux box.

Try porting the same code on Windows machine
commented by (202 points)
Or you can try exploring Sikuli

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.