【问题标题】:Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'TableauExtract': The specified module could not be found线程“主”java.lang.UnsatisfiedLinkError 中的异常:无法加载库“TableauExtract”:找不到指定的模块
【发布时间】:2017-07-13 15:02:42
【问题描述】:
import com.tableausoftware.TableauException;
import com.tableausoftware.common.Type;
import com.tableausoftware.extract.Extract;
import com.tableausoftware.extract.Row;
import com.tableausoftware.extract.Table;
import com.tableausoftware.extract.TableDefinition;    
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class TestTableau {

    public static void main(String[] args) throws IOException {
        //delete existing extract file
        String extractFile = "extract.tde";
        deleteFile(extractFile);

        try (Extract extract = new Extract(extractFile)) {
            //create table definition
            TableDefinition tableDef = new TableDefinition();
            int columnCount = 100;
            for (int i = 0; i < columnCount; i++) {
                tableDef.addColumn(Integer.toString(i), Type.UNICODE_STRING);
            }

            //create a table
            Table table = extract.addTable("Extract", tableDef);

            //create a sample document
            //reuse the document for each row to minimize the non-tableau CPU and memory consumption
            Random random = new Random();
            List<String> rowData = new ArrayList<>();
            for (int i = 0; i < columnCount; i++) {
                rowData.add(Integer.toString(random.nextInt()));
            }

            long startTime = System.nanoTime();
            System.out.println("Populating table...");

            //populate the table
            int tableRows = 4000000;
            for (int i = 0; i < tableRows; i++) {
                //convert input document to tableau row
                Row row = new Row(tableDef);
                for (int j = 0; j < rowData.size(); j++) {
                    row.setString(j, rowData.get(j));
                }

                //add the row to the table
                table.insert(row);
            }

            long endTime = System.nanoTime();
            System.out.println(String.format("Total time (ms): %s", (endTime - startTime) /
                    1000000));

        } catch (TableauException e) {
            e.printStackTrace();
        }
    }

    private static void deleteFile(String file) {
        File extractFile = new File(file);
        if (extractFile.exists()) {
            extractFile.delete();
        }
    }
}

当我运行代码时出现异常:

线程“主”java.lang.UnsatisfiedLinkError 中的异常:无法 加载库“TableauExtract”:指定的模块不能 找到了。

在 com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:194) 在 com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:283) 在 com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:244) 在 com.sun.jna.Native.register(Native.java:1065) 在 com.tableausoftware.extract.Extract.(Unknown Source) at TestTableau.main(TestTableau.java:21)

我已将以下 jar 文件添加到构建路径:

tableauextract.jar jna.jar tableaucommon.jar

如何解决这个问题?

【问题讨论】:

    标签: java tableau-api


    【解决方案1】:

    如果您的构建路径中有这些库,您是否尝试再次清理并构建您的项目?

    【讨论】:

    • 不,我没有再次构建
    • 如果您正在使用:Eclipse - 转到 Project 并按 clean,然后选择您的项目。 Netbeans - 右键单击​​您的项目单击清理并构建 Intellij - 与 netbeans 相同
    • intellij 中也有同样的异常。我已经构建了项目,当我运行时仍然给我异常
    【解决方案2】:

    UnsatisfiedLinkError 表示您使用的 jar 文件依赖于系统上存在的本机库,位于 Java 知道的位置。从您的堆栈跟踪中,我猜您需要 TableauExtract.dll(可能还有其他)。您需要的库可从此处的 Tableau 站点获得:

    Tableau SDK

    安装后,您需要告诉 Java 如何找到库文件所在的目录。此方法取决于您的操作系统,但在 Unix 上,您可以通过在 tje LD_LIBRARY_PATH 环境变量中包含目录来实现,也可以使用 -Djava.library.path= 标志

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-22
      • 1970-01-01
      • 2014-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多