hi, while writing xssf file, i am getting a Exception saying Caused by: java.lang.ClassCastException: Caused by: java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source) at org.apache.poi.util.DocumentHelper.<clinit>(DocumentHelper.java:52) ... 121 more Details: pom.xml <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.11</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.11</version> <exclusions> <!-- STAX comes with Java 1.6 --> <exclusion> <artifactId>stax-api</artifactId> <groupId>javax.xml.stream</groupId> </exclusion> <exclusion> <artifactId>stax-api</artifactId> <groupId>stax</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-stax-api_1.2_spec</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.codehaus.woodstox</groupId> <artifactId>woodstox-core-lgpl</artifactId> <version>4.4.1</version> </dependency> <dependency> <groupId>xerces</groupId> <artifactId>xerces</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>xerces</groupId> <artifactId>xmlParserAPIs</artifactId> <version>2.6.2</version> </dependency> <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.11.0</version> </dependency> Library Inside war: xercesImpl-2.4.0.jar xml-apis-1.3.04.jar xml-apis-ext-1.3.04.jar
That looks a very complicated pom file, and if your project is just doing POI stuff, it contains lots of things that aren't needed, and most likely one of those is breaking it You should be fine with just: <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.11</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.11</version> </dependency> No need for any exclusions with 3.11, no need for anything else!
i tried the same but now i am getting below error org/xml/sax/SAXException: java.lang.NoClassDefFoundError: org/xml/sax/SAXException
These are included in Java 6 and newer, so it seems you are either using a Java prior to 6 (which is not supported any more by POI), or the JRE that you are using is not fully conforming to standards, e.g. we had similar problems with IBM JDK, where using IBM JDK 7 resolved problems. Please review http://poi.apache.org/faq.html#faq-N1017E and see if the suggestions there make it work. For now I cannot see any problem in POI, therefore I am closing this as WORKSFORME, please reopen with more information and full code to reproduce the error if you still think this is caused by POI itself.