java.lang.NoClassDefFoundError with Apache POI

Originally posted by lcordy on January 23, 2018

I was not getting this error in SoapUI 5.3 free version, exactly the same code reading Excel in ReadyAPI throws the error below. I copied the same jar files from bin/ext folder from SoapUI 5.3 to ReadyAPI. I have tried the suggestion at https://poi.apache.org/faq.html#faq-N10025 and placed ooxml-schemas-1.3.jar in my bin/ext folder as well, to no avail.

Wed Jan 24 15:24:33 NZDT 2018:ERROR:java.lang.NoClassDefFoundError: org/openxmlformats/schemas/spreadsheetml/x2006/main/CTExtensionList
java.lang.NoClassDefFoundError: org/openxmlformats/schemas/spreadsheetml/x2006/main/CTExtensionList
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetPublicMethods(Unknown Source)
at java.lang.Class.getMethods(Unknown Source)
at org.codehaus.groovy.reflection.stdclasses.CachedSAMClass.getSAMMethod(CachedSAMClass.java:164)
at org.codehaus.groovy.reflection.ClassInfo.isSAM(ClassInfo.java:359)
at org.codehaus.groovy.reflection.ClassInfo.createCachedClass(ClassInfo.java:349)
at org.codehaus.groovy.reflection.ClassInfo.access$700(ClassInfo.java:41)
at org.codehaus.groovy.reflection.ClassInfo$LazyCachedClassRef.initValue(ClassInfo.java:497)
at org.codehaus.groovy.reflection.ClassInfo$LazyCachedClassRef.initValue(ClassInfo.java:488)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:49)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:36)
at org.codehaus.groovy.reflection.ClassInfo.getCachedClass(ClassInfo.java:111)
at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:110)
at org.codehaus.groovy.reflection.ParameterTypes.getParametersTypes0(ParameterTypes.java:81)
at org.codehaus.groovy.reflection.ParameterTypes.getParameterTypes(ParameterTypes.java:67)
at org.codehaus.groovy.reflection.CachedMethod.compareToMethod(CachedMethod.java:186)
at org.codehaus.groovy.reflection.CachedMethod.compareTo(CachedMethod.java:142)
at org.codehaus.groovy.reflection.CachedMethod$MyComparator.compare(CachedMethod.java:315)
at java.util.Arrays.binarySearch0(Unknown Source)
at java.util.Arrays.binarySearch(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.find(CachedMethod.java:68)
at groovy.lang.MetaClassImpl.applyPropertyDescriptors(MetaClassImpl.java:2522)
at groovy.lang.MetaClassImpl.setupProperties(MetaClassImpl.java:2261)
at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3302)
at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3266)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:254)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:285)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:295)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:261)
at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:871)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createPojoSite(CallSiteArray.java:125)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:166)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at Script3.run(Script3.groovy:38)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:98)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SoapUIProGroovyScriptEngineFactory.java:82)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:156)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTExtensionList
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 44 more

Originally posted by nmrao on January 23, 2018

Have you restarted the tool after copying the jar files?

Originally posted by lcordy on January 23, 2018

Yep, restarted. Using Poi 3.17 by the way.

Originally posted by nmrao on January 23, 2018

Thanks for clarifying. Would you please list all the files under /bin/ext directory?

Originally posted by lcordy on January 24, 2018

Files in bin/ext attached.

Originally posted by ayonchoudhury on July 23, 2018

This worked for me, incase you still have the issue.

I downloaded the ooxml-schemas-1.3.jar file and placed it into bin/ext along with all the other poi jars.

Originally posted by ps4545 on September 25, 2018

def fs = new FileInputStream(“D:/sample.xlsx”)
def wb = new XSSFWorkbook(fs)
def ws = wb.getSheet(“Sheet1”)

Executing …Groovy script

Which dependency is missing? - got this error SOAP UI 5.4 An error occurred [org/apache/commons/compress/archivers/zip/ZipFile], see error log for details

Can any one help please!

Originally posted by Jason1 on November 19, 2018

I downloaded the ooxml-schemas-1.3.jar file and placed it into bin/ext along with all the other poi jars.

But I still have the same problem : CTExtensionList error

Originally posted by JoanLi on November 30, 2018

I meet the same problem. When I use " def wb= new XSSFWorkbook(file)“, the error prompt which is the same as above pops up. When I use " def wb= WorkbookFactory.reate(file);”, there is no response. I mean there is no error popping up or log printing. In fact, the same script runs properly in my groovy IDE. I am not sure if the soapui 5.4 can not use the poi 4.0.

Originally posted by Camerlock on December 10, 2018

My aim is to read and write and xlsx file from Groovy Test Step.

For xls files everything worked fine.

Trying upgrading to poi vers. > 3.12 is not that helpful because on ReadyAPI or SOAPUI Pro version this will break Test Step Datasource with Excel for loading data. The Test Step is then failed.

I then rolback and have to face the multiple issues described here. I was unsuccessful everytime.

After trying all available API in POI and also trying using the additional OOXML Schemas lib I must admitted too: Handling / updating xlsx files in Groovy step is not currently possible.

ERROR: An error occurred [org/openxmlformats/schemas/spreadsheetml/x2006/main/CTExtensionList], see error log for details

Originally posted by mityfai on July 12, 2019

I’ve been struggling with this issue for a while and trying it again with every new Release and hoping it’s been solved. By the current release, unfortunately not!

Anonymous: Ist there any hope that this well known issue will be solved:

can ReadyAPI be inproved to handle xlsx file in groovy script or should will exclude that combination from test cases implementation at all.

Originally posted by Nastya_Khovrina on July 16, 2019

Please try the solution from this article:

https://smartbear-cc.force.com/portal/KbArticleViewer?name=Example-of-using-third-party-Java-libraries-in-Groovy-script-reading-from-Excel-file-using-Apache-POI&sp=all

Originally posted by bompeacock on August 18, 2019

I am also stuck with this issue, any pro or Nastya_Khovrina have any ideas, please tell me,
But my solution is changing .xlsx to xls, it does work. But I want to use .xlsx instead of .xls file.

Originally posted by Nastya_Khovrina on August 22, 2019

Hi bompeacock.,

Do you use a script from this KB article: https://smartbear-cc.force.com/portal/KbArticleViewer?name=Example-of-using-third-party-Java-libraries-in-Groovy-script-reading-from-Excel-file-using-Apache-POI&sp=all?

It’s working fine for me with .xslx file with ReadyAPI 2.8.0 and Apache POI 4.1.0.

What versions do you use?

Do you have the exact same error in the log as the error from the first post?

Originally posted by ayonchoudhury on August 22, 2019

Apart from the poi jars, download the jar

ooxml-schemas-1.3.jar

Place this jar in your SmartBear\SoapUI-5.4.0\bin\ext

and restart SOAP UI. Should work now!!

You can find more on my blog - https://testbuster309148348.wordpress.com/blog/

Let me know if this helps

Originally posted by bompeacock on August 22, 2019

Hi Nastya_Khovrina ,
I tried, and 4.0.1 throw an another Exception and all DataSource steps (using excel file) were brokenwith the same error message as below:

It still only works for .xls.

Why don’t Ready API 2.8.0 Pro install lib POI 4.0.1 or working exactly version already instead of 3.12 that somtime not working with .xlsx? Because when I release script Ready API for my customer I can not decide to choose which version for POI lib.

Originally posted by JustinM89 on August 23, 2019

Just a heads up, in %READYAPI_HOME%/lib, there is poi-ooxml-schemas-3.12.jar – if you are adding a different version to bin/ext, both of these JARs are probably getting added to the classpath and could cause issues.

I ran into this same issue with bouncy-castle (specifically bcprov-jdk) – we needed this dependency to encrypt passwords, so we added it into bin/ext, but we kept getting this strange Arrays.concatenate([B][B][B]) error. After some poking around we realized that there was another version of this same JAR in lib/ and it seemed that when we were calling our encrypt method, it was using the method from this JAR, and not the one we had placed in bin/ext.

We simply replaced the version of bouncy-castle in the lib directory with the same version we had in bin/ext and this resolved the issue – however, I’m pretty sure doing this has the potential to break something in SoapUI if it is relying on a class from a specific version of a JAR and you go and swap it out with a different version, so do this at your own risk.

Originally posted by Nastya_Khovrina on August 26, 2019

bompeacock,

Please try the solutions from here:

https://stackoverflow.com/questions/52381075/apache-poi-java-lang-noclassdeffounderror-org-apache-commons-compress-archivers

But, Justin is right, using libraries versions which differ from versions in ReadyAPI installation may cause issues.

Originally posted by bompeacock on August 26, 2019

Nastya_Khovrina ,

Your answer is not resolving my issue. Thank, maybe I should still use POI ver 3.12 and .xlsfiles.