当前位置: 首页 > 面试题库 >

错误的ELF类:ELFCLASS32(可能的原因:体系结构字宽不匹配)

谷梁子昂
2023-03-14
问题内容

我有一个奇怪的异常,说错误的ELF类,但包装器设置正确。

要从Belgiun ID卡发行商的官方网站上使用此SDK读取Belgiun
ID卡:http
://eid.belgium.be/en/binaries/beid-
sdk-3.5.3-ubuntu-9.10-i686-6193_tcm147-94066_tcm406-114986 。
g

$ uname -a # Using NetBeans IDE 7.3 in Ubuntu 12.10 64-bit
Linux sun-M14xR2 3.5.0-25-generic #39-Ubuntu SMP Mon Feb 25 18:26:58 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
$ java -version
java version "1.7.0_15"
OpenJDK Runtime Environment (IcedTea7 2.3.7) (7u15-2.3.7-0ubuntu1~12.10.1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

码:

package javaapplication1;

import java.lang.*;
import be.belgium.eid.*;

public class JavaApplication1 {
  //*****************************************************************************
  // Get the data and dump to the screen
  // Beware: The data coming from the cards is encoded in UTF8!
  //*****************************************************************************

  private static void getSISData(BEID_SISCard card) throws Exception {
    BEID_SisId sisId = card.getID();

    System.out.println();

    System.out.println("\tPeronal data:");
    System.out.println("\t-------------");
    System.out.println("\tName                 : " + sisId.getName());
    System.out.println("\tSurname              : " + sisId.getSurname());
    System.out.println("\tInitials             : " + sisId.getInitials());
    System.out.println("\tGender               : " + sisId.getGender());
    System.out.println("\tDateOfBirth          : " + sisId.getDateOfBirth());
    System.out.println("\tSocialSecurityNumber : " + sisId.getSocialSecurityNumber());

    System.out.println();

    System.out.println("\tCard data:");
    System.out.println("\t----------");
    System.out.println("\tLogicalNumber        : " + sisId.getLogicalNumber());
    System.out.println("\tDateOfIssue          : " + sisId.getDateOfIssue());
    System.out.println("\tValidityBeginDate    : " + sisId.getValidityBeginDate());
    System.out.println("\tValidityEndDate      : " + sisId.getValidityEndDate());
  }

  //*****************************************************************************
  // Get the data from a Belgian SIS card
  //*****************************************************************************
  private static void getSISCardData(BEID_ReaderContext readerContext) throws Exception {
    BEID_SISCard card = readerContext.getSISCard();
    getSISData(card);
  }

  //*****************************************************************************
  // Get the data and dump to the screen
  // Beware: The data coming from the cards is encoded in UTF8!
  //*****************************************************************************
  private static void getEIDData(BEID_EIDCard card) throws Exception {
    BEID_EId eid = card.getID();

    if (card.isTestCard()) {
      card.setAllowTestCard(true);
      System.out.println("");
      System.out.println("Warning: This is a test card.");
    }

    System.out.println("\tDocumentVersion    : " + eid.getDocumentVersion());
    System.out.println("\tDocumentType       : " + eid.getDocumentType());

    System.out.println();

    System.out.println("\tPeronal data:");
    System.out.println("\t-------------");
    System.out.println("\tFirstName          : " + eid.getFirstName());
    System.out.println("\tSurname            : " + eid.getSurname());
    System.out.println("\tGender             : " + eid.getGender());
    System.out.println("\tDateOfBirth        : " + eid.getDateOfBirth());
    System.out.println("\tLocationOfBirth    : " + eid.getLocationOfBirth());
    System.out.println("\tNobility           : " + eid.getNobility());
    System.out.println("\tNationality        : " + eid.getNationality());
    System.out.println("\tNationalNumber     : " + eid.getNationalNumber());
    System.out.println("\tSpecialOrganization: " + eid.getSpecialOrganization());
    System.out.println("\tMemberOfFamily     : " + eid.getMemberOfFamily());
    System.out.println("\tAddressVersion     : " + eid.getAddressVersion());
    System.out.println("\tStreet             : " + eid.getStreet());
    System.out.println("\tZipCode            : " + eid.getZipCode());
    System.out.println("\tMunicipality       : " + eid.getMunicipality());
    System.out.println("\tCountry            : " + eid.getCountry());
    System.out.println("\tSpecialStatus      : " + eid.getSpecialStatus());

    System.out.println("");

    System.out.println("\tCard data:");
    System.out.println("\t----------");
    System.out.println("\tLogicalNumber      : " + eid.getLogicalNumber());
    System.out.println("\tChipNumber         : " + eid.getChipNumber());
    System.out.println("\tValidityBeginDate  : " + eid.getValidityBeginDate());
    System.out.println("\tValidityEndDate    : " + eid.getValidityEndDate());
    System.out.println("\tIssuingMunicipality: " + eid.getIssuingMunicipality());
  }

  //*****************************************************************************
  // Get the data from a Belgian kids EID card
  //*****************************************************************************
  private static void getKidsCardData(BEID_ReaderContext readerContext) throws Exception {
    BEID_KidsCard card = readerContext.getKidsCard();
    getEIDData(card);
  }

  //*****************************************************************************
  // Get the data from a Belgian foreigner EID card
  //*****************************************************************************
  private static void getForeignerCardData(BEID_ReaderContext readerContext) throws Exception {
    BEID_ForeignerCard card = readerContext.getForeignerCard();
    getEIDData(card);
  }

  //*****************************************************************************
  // Get the data from a Belgian EID card
  //*****************************************************************************
  private static void getEidCardData(BEID_ReaderContext readerContext) throws Exception {
    BEID_EIDCard card = readerContext.getEIDCard();
    getEIDData(card);
  }

  //*****************************************************************************
  // get a string representation of the card type
  //*****************************************************************************
  private static String getCardTypeStr(BEID_ReaderContext readerContext) throws Exception {
    String strCardType = "UNKNOWN";
    BEID_CardType cardType = readerContext.getCardType();

    if (cardType == BEID_CardType.BEID_CARDTYPE_EID) {
      strCardType = "BEID_CARDTYPE_EID";
    } else if (cardType == BEID_CardType.BEID_CARDTYPE_KIDS) {
      strCardType = "BEID_CARDTYPE_KIDS";
    } else if (cardType == BEID_CardType.BEID_CARDTYPE_FOREIGNER) {
      strCardType = "BEID_CARDTYPE_FOREIGNER";
    } else if (cardType == BEID_CardType.BEID_CARDTYPE_SIS) {
      strCardType = "BEID_CARDTYPE_SIS";
    } else {
      strCardType = "BEID_CARDTYPE_UNKNOWN";
    }
    return strCardType;
  }

  //*****************************************************************************
  // Show the info of the card in the reader
  //*****************************************************************************
  private static void showCardInfo(String readerName) throws Exception {
    BEID_ReaderContext readerContext = BEID_ReaderSet.instance().getReaderByName(readerName);
    if (readerContext.isCardPresent()) {
      System.out.println("\tType               : " + getCardTypeStr(readerContext));

      BEID_CardType cardType = readerContext.getCardType();

      if (cardType == BEID_CardType.BEID_CARDTYPE_EID) {
        getEidCardData(readerContext);
      } else if (cardType == BEID_CardType.BEID_CARDTYPE_KIDS) {
        getKidsCardData(readerContext);
      } else if (cardType == BEID_CardType.BEID_CARDTYPE_FOREIGNER) {
        getForeignerCardData(readerContext);
      } else if (cardType == BEID_CardType.BEID_CARDTYPE_SIS) {
        getSISCardData(readerContext);
      } else {
      }
    }
  }

  //*****************************************************************************
  // Show the reader info an get the data of the card if present
  //*****************************************************************************
  private static void showReaderCardInfo(String readerName) throws Exception {
    BEID_ReaderContext readerContext = BEID_ReaderSet.instance().getReaderByName(readerName);

    System.out.println("Reader: " + readerName);
    System.out.println("\tCard present: " + (readerContext.isCardPresent() ? "yes" : "no"));

    showCardInfo(readerName);

    System.out.println("");
  }

  //*****************************************************************************
  // scan all the card readers and if a card is present, show the content of the
  // card.
  //*****************************************************************************
  private static void scanReaders() throws Exception {
    long nrReaders = BEID_ReaderSet.instance().readerCount();
    System.out.println("Nr of card readers detected: " + nrReaders);

    for (int readerIdx = 0; readerIdx < nrReaders; readerIdx++) {
      String readerName = BEID_ReaderSet.instance().getReaderName(readerIdx);
      showReaderCardInfo(readerName);
    }
  }

  //*****************************************************************************
  // Main entry point
  //*****************************************************************************
  public static void main(String argv[]) {
    System.out.println("[Info]  eID SDK sample program: read_eid");

    String osName = System.getProperty("os.name");

    if (-1 != osName.indexOf("Windows")) {
      System.out.println("[Info]  Windows system!!");
      System.loadLibrary("beid35libJava_Wrapper");
    } else {
      System.loadLibrary("beidlibJava_Wrapper");
    }

    try {
      BEID_ReaderSet.initSDK();
      scanReaders();
    } catch (BEID_Exception e) {
      System.out.println("[Catch] BEID_Exception:" + e.GetError());
    } catch (Exception e) {
      System.out.println("[Catch] Exception:" + e.getMessage());
    }


    try {
      BEID_ReaderSet.releaseSDK();
    } catch (BEID_Exception e) {
      System.out.println("[Catch] BEID_Exception:" + e.GetError());
    } catch (Exception e) {
      System.out.println("[Catch] Exception:" + e.getMessage());
    }
  }
}

输出:

[Info]  eID SDK sample program: read_eid
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/sun/Downloads/beidsdk/beidlib/Java/unsigned/libbeidlibJava_Wrapper.so.3.5.3: /home/sun/Downloads/beidsdk/beidlib/Java/unsigned/libbeidlibJava_Wrapper.so.3.5.3: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1675)
    at java.lang.Runtime.loadLibrary0(Runtime.java:840)
    at java.lang.System.loadLibrary(System.java:1047)
    at javaapplication1.JavaApplication1.main(JavaApplication1.java:269)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

编辑:

https://code.google.com/p/eid-viewer/ https://code.google.com/p/eid-mw/


问题答案:

它不起作用,因为您使用的是64位版本的Java,并且您尝试使用的SDK包含32位本机库(libbeidlibJava_Wrapper.so.3.5.3)。64位JRE无法加载32位本机库。

您需要使用32位Java版本,或者查找具有64位本机库的SDK版本。



 类似资料:
  • 问题内容: 在Solaris计算机上运行我的应用程序时,出现指向某些.so文件的错误。但是,该应用程序在Windows机器上运行得很好。如果我没记错的话,我的应用程序期望使用64位版本,但是Solaris机器中只有.so文件的32位版本。有没有一种方法可以解决此问题,因此它将改用32位版本?我了解它与字节码无关,但可能与JVM无关。我尝试使用-d32或-d64运行,但没有效果。 更新: 这是确切的

  • 问题内容: 什么样的问题可能会导致Java的ProcessBuilder.start方法返回IOException并带有错误码= 5的注释? 具体来说,我们已经看到了一个远程客户系统,它按照以下方式运行一些Java代码: …抛出这样的异常… 我们已经确认异常中提到的命令“ C:\ example \ example.exe arguments1 arguments2”可以通过cmd.exe手动成功

  • 我有一个Web窗体网站项目。本网站引用了4个类库项目。这些类库中有3个引用第三方程序集。对于3个类库项目中的每一个,我都得到以下编译器错误。 我已经在类库项目上尝试了所有可能的anycpu/x86/x64组合。我不能在网站项目上更改此内容。我有x86和x64版本的第三方DLL。两者都试过。 “ClassLibrary.csproj”(默认目标)(4)->(ResolveAssemblyRefere

  • 本文向大家介绍hdfs的体系结构相关面试题,主要包含被问及hdfs的体系结构时的应答技巧和注意事项,需要的朋友参考一下 解答: hdfs有namenode、secondraynamenode、datanode组成。 为n+1模式 namenode负责管理datanode和记录元数据 secondraynamenode负责合并日志 datanode负责存储数据

  • 问题内容: 我在雄猫服务器(+ liferay)上收到此异常 我的课是这样的: 我在行上收到此异常, 当队列已满但大小为2 ^ 31时,可能会发生此错误,并且我确定没有那么多命令在等待。 一开始一切都稳定,但在我重新部署战争后,一切开始发生。此类不是战争的一部分,而是放在tomcat / lib中的jar中。 您是否知道为什么会发生这种情况以及如何解决? 问题答案: 从ThreadPoolExec