简体   繁体   中英

Getting :: java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.put(Ljava/lang/Object;)V

I am using the Poi(poi, poi-ooxml-schemas,poi-ooxml-4.4.1 ) api for export-import operation, and now upgraded xmlbeans from 3.0.2 to 5.0.1 version, after upgrading the xmlbeans-5.0.1 getting error while creating new SXSSFWorkbook(100);

.... java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.put(Ljava/lang/Object;)V java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.xssf.model.SharedStringsTable

and using jaxb-api-2.4.0-b180830.0359 version.

I found the following dependency in my pom.xml code and once i removed it.It worked fine for me.

<dependency>
    <groupId>org.apache.servicemix.bundles</groupId>
    <artifactId>org.apache.servicemix.bundles.poi</artifactId>
    <version>4.1.2_1</version>
</dependency>

So remove it and it will work.

I had updated to XMLBeans 5.0.3 earlier. So to fix this I had to update to latest POI (I had the 4.xx series of POI earlier):

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>5.2.2</version>
</dependency>

I solved this problem by simply removing all packages of xmlbeans in my repository and reloading maven projects.

In most cases, if a java.lang.NoSuchMethodError error occurs, the cause could be a dependency package conflict.

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>4.1.2</version>
</dependency>
You can try this also or can move to higher/lower dependency

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM