简体   繁体   中英

Getting a ClassNotFoundException even though I have the correct jar

This is from my pom.xml:

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

And this is from my error message:

java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Workbook not 

found by poi-ooxml [355]

I don't see any error messages on my Spring Tool Suite(very similar to Eclipse), and POI libraries are successfully imported. I really can't understand why am I getting this error.

Also the code runs in an OSGi bundle, and poi jars are deployed along others.

UPDATE: Ok I have found something: The error says:

java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Workbook not 

found by poi-ooxml [355]

But my Workbook.class is inside of poi instead of poi-ooxml. How do I make maven to look inside of poi instead of poi-ooxml?

Your question is not very clear... Are you using Eclipse when this error occur or maven?

Usually, the best thing is to run

mvn clean install

in the home directory of pom.xml and this will give you a lot more information

Usually when you have an error such ClassNotFoundException it means that you miss a dependency in the pom.xml.

Go over all your dependencies and check what is missing in the pom.

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