Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jboss class cast exception: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

 
Jimmy Wales
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I'm struck with a problem in jboss. When I try to deploy my .war into the server, I get this following error,



from which, it is quite evident that there is a clash of libraries. So, I removed the jar file which contains xerces, which happened to by jaxp-ri-1.4.1.jar. Now, when I try to re-deploy, I get this new error,



where it is complaining that it can't find the xml parsers.

So, now my questions is that does anybody know what can be a solution. Any jaxp jar file that doesn't contain the xerces package?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which version of JBoss AS is this?
 
Jimmy Wales
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, my bad. I should've mentioned it. Its Jboss 4.2.3 GA
 
Jimmy Wales
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the meanwhile, what I thought was, there was problem casting SaxParserFactoryImpl to an instance of SaxParserFactory. So, I thought may be there are two versions of SaxParserFactory and so I looked up the jars having this class. And it turned out to be jaxp-api.jar. I removed both of them and try to deploy again, but then I got this error,




Its strange in a way, because jaxp is not at all needed as all classes needed for xml parsing are already included in jre. Maven, which I use to build my project, somehow includes them. And I can't get away without them

What might be a possible explanation?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post that entire exception stacktrace and also the list of jars that you package in your application?
 
Jimmy Wales
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm posting here all the stack traces. Thanks Jai, btw, for looking into it.

This is the first error I get when I deploy me war with my ear. Deploying only ear doesn't give any problems



When I delete jaxp-api and jaxp-ri jars and deploy, I don't get any errors while deploying, but when I try to connect my war to my ear, I get this error.

 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this com.mondeca.itm.ws.endpoint.ConnectionDOMEndPoint your application's class? If yes, can you post the code that's present in its com.mondeca.itm.ws.endpoint.ConnectionDOMEndPoint.invokeInternal method?
 
Jimmy Wales
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, yes that our class. This is the entry point for webservices(war) into the ear. This class gets the session id for other webservices to use.

Here is the code



We used spring-ws framework to build the webservices.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change this:

JAXBContext context = JAXBContext.newInstance(Constants.PACKAGE_JAVA_SCHEMA);


to:


 
Jimmy Wales
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jai,

I still have problem. Here is the stack trace of the new exception. Interestingly, when I try to connect for the first time, I get the error I posted above, stating that I get it when I deploy after deleting jaxp-ri and jaxp-api jars. I get the same error. But when I repeatedly try to connect, I get this new error,



This is only putting me further down the confusion lane.
 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I ahve the same problem with jboss-5.1.0.GA



Did you ever get it fixed
 
Jimmy Wales
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tony,

I managed to solve it, but as far as I understood it was not a one-stop solution. It was a workaround because it was a known bug in jboss and I guess its not fixed till 6.0.2 release(this is not a stable release). This occurs if your application uses xml parsers. So, in this case, you need to do the proper class loading isolation.

There are a couple of ways to do the class loading isolation. I tried to see which case works when, but I couldn't. It was like a random thing. So, refer to this doc here http://community.jboss.org/wiki/ClassLoadingConfiguration. This explains the class isolation mechanism.

In my case we were trying to do class loading isolation and it was not being done properly and hence there's a conflict b'n application libraries and jboss libraries. So, we had two options, completely remove the isolation or do global isolation.

More info: http://community.jboss.org/thread/159159

PS 1: You may need to change your class loading isolation configuration in jboss-web.xml if you are using jboss 4.2.3 (refer to the above doc)
PS 2: Doing global class loading isolation by changing ear-deployer.xml file may effect the performance of the server, because now all the EJB calls are serialized!

HTH,

Cheers,
 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jimmy,

for migrating to jboss-5.1.0 to remove this error:

ink http://www.mastertheboss.com/jboss-application-server/223-solving-jboss-5-classloading-issues.html

JBoss 5 adds the concepts of custom meta data files, one of which is jboss-classloading.xml
which let you define exactly how the war classloader is constructed.

Added jboss-classloading.xml to C:\appservers\jboss-5.1.0.GA\server\bgifunds\deploy\bgifunds.war\WEB-INF

This sorts out all the class loading problems.

Tony
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic