This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes Jboss class cast exception: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Jboss class cast exception: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl" Watch "Jboss class cast exception: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl" New topic
Author

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

Jimmy Wales
Greenhorn

Joined: Jun 05, 2010
Posts: 10
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

Joined: Jul 20, 2005
Posts: 10240
    
168

Which version of JBoss AS is this?

[My Blog] [JavaRanch Journal]
Jimmy Wales
Greenhorn

Joined: Jun 05, 2010
Posts: 10
Oops, my bad. I should've mentioned it. Its Jboss 4.2.3 GA
Jimmy Wales
Greenhorn

Joined: Jun 05, 2010
Posts: 10
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

Joined: Jul 20, 2005
Posts: 10240
    
168

Can you post that entire exception stacktrace and also the list of jars that you package in your application?
Jimmy Wales
Greenhorn

Joined: Jun 05, 2010
Posts: 10
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

Joined: Jul 20, 2005
Posts: 10240
    
168

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

Joined: Jun 05, 2010
Posts: 10
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

Joined: Jul 20, 2005
Posts: 10240
    
168

Change this:

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


to:


Jimmy Wales
Greenhorn

Joined: Jun 05, 2010
Posts: 10
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

Joined: Jun 29, 2002
Posts: 579
Hi I ahve the same problem with jboss-5.1.0.GA



Did you ever get it fixed
Jimmy Wales
Greenhorn

Joined: Jun 05, 2010
Posts: 10
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

Joined: Jun 29, 2002
Posts: 579
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
 
 
subject: Jboss class cast exception: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl