Sammy
Sammy

Reputation: 4578

ClassCastException in weblogic when using prefer-web-inf-classes

I had to add

<prefer-web-inf-classes>true</prefer-web-inf-classes>

to weblogic.xml to resolve a Hibernate antr compatibility issue with Weblogic. after adding that I was getting all different kind of classCastException related to XML parsers.

I understood from reading other threads that weblogic is trying to use a different class that what the application is expecting.

I spend all day researching and tried different solutions like removing "xml-apis......." jar files. but everytime I get ClassCastException. The cast "from" class changes when I remove jar files, but I always get

ClassCastException: "some xml parser related class" can not be cast to javax.xml.parsers.DocumentBuilderFactory

is there a way to know which xml parser jars are really causing the issue.

I m using Maven 2 to manage dependencies

Upvotes: 1

Views: 2220

Answers (2)

Jeremy Goodell
Jeremy Goodell

Reputation: 19002

Good answer to your own question. I also found this method (if you use maven), which generates a really nice dependency chart. I had this same problem, and using the dependency chart I was able to determine that the offending library, xml-apis*.jar, was loaded by maven as a dependency of jasperreports. Adding the exclusion element to the pom.xml for the jasperreports module fixed the problem.

http://maven.40175.n5.nabble.com/where-is-xml-apis-1-0-b2-jar-coming-from-td88057.html

Upvotes: 1

Sammy
Sammy

Reputation: 4578

Answering my own question:

I removed all jars that contains classes from javax.xml.* package by doing a java search and searching Package and check search in "application Libraries". then I had to remove sax..jar file. everything worked as expected after that.

Upvotes: 1

Related Questions