POI parsing excel error java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Date1904Support

tags: java backend

A few days ago, I made an excel upload and import function. I want to support both xls and xlsx formats for general purpose. No errors were reported during the code writing period, and the required classes are also available. But when the app started the test function, it reported such an error.Caused by: java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Date1904Support  Why is this? My first feeling is caused by the jar package conflict. But I did not find two versions of the same package. Later, I took a closer look at the different versions of poi and poi-ooxml. Could it be that this problem led to an attempt to change the version number to a consistent one. It still doesn't work after the change. After tossing for a long time, I discovered that the version number I changed did not take effect. The original poi maven reference was configured in dependencyManagement, but I changed the reference in dependency. So it didn't work. Made another low-level mistake.The solution to this problem can be summarized as the following two points:

1. The versions of poi.jar and poi-ooxml.jar should be the same.

2. When modifying the version number of the jar package that Maven depends on, pay attention to find out whether the jar package version isdependencyManagement management. Modifying the version number in the dependencys reference does not work if it exists. So if you manage the version number in dependencyManagement, then don't write the version number when you reference the dependencys.

  If parsing excel synchronization supports xls and xlsx dependent packages as follows:

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

excel upload parsing error

Caused by: java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Date1904Support
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at com.aliyun.devata.cms.web.controller.AdminMessageController.importEmpInfo(AdminMessageController.java:139)
    at com.aliyun.devata.cms.web.controller.AdminMessageController$$FastClassBySpringCGLIB$$baba469f.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:651)
    at com.aliyun.devata.cms.web.controller.AdminMessageController$$EnhancerBySpringCGLIB$$4065efb5.importEmpInfo(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:220)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
    ... 100 common frames omitted

 

Intelligent Recommendation

POI parsing Excel file

    Demo 1     2. Demo 2        ...

Use POI parsing Excel

The POI using excel resolves String [] set...

Use POI (Version 4.2.1) in the Java project to solve the error Java.lang.noclassdeffounderror: ORG/Apache/Poi/PoixLDOCUMENTPART

I. Introduction Recently, I encountered the Times of the use of POI version 4.2.1 when I was doing WORD to HTML recently: Analysis of the cause After comparison, it is found that the 4.2.1 version is ...

Java parsing Excel using apache POI parsing

During this time, I re-developed and took over an EXCEL file reading task. The key code is as follows, the code function is not complete, and you need to consider it when you use it. Steal a lazy stic...

POI parsing and generating Excel Excel

No nonsense, the Code Note: The resolution is xlsx format; Incidentally, whether Int may be converted to a String under regular check; Used package are: (POI official download package is the package)....

More Recommendation

POI【java.lang.NoClassDefFoundError】

java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap The cause of the error is lacking JAR related to Collections4 I downloaded the version is POI 3.17 to find a commons-colle...

The exception occurred when using POI to import and export excel: java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap

The company project needs to import and export excel. Since I have not contacted before, I am learning now. During the configuration process, java.lang.NoClassDefFoundError: org/apache/commons/collect...

java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/FileMagic

maven project using the POI to read and write Excel 2007 version wrong, did not know the reason, but later found the imported poi, poi-ooxml and inconsistent versions pom configuration file poi  ...

com.alibaba.excel.exception.ExcelAnalysisException: java.lang.NoClassDefFoundError: org/apache/poi/p

com.alibaba.excel.exception.ExcelAnalysisException: java.lang.NoClassDefFoundError: org/apache/poi/p There are two main reasons currently known for this exception: 1. There is no maven dependency of p...

java.lang.noclassDeffounderror: ORG/Apache/Poi/Filesystem/Filemagic

com.alibaba.excel.exception.excelanalysisexception: java.lang.noclassDeffounderror: Org/Apache/Poifs/Filesystem/Filemagic dependencies. Use EasyExcel Times wrong java.lang.noclassdeffounderror: Org/Ap...

Copyright  DMCA © 2018-2024 - All Rights Reserved - www.programmersought.com  User Notice

Top