Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I am getting the following error while deploying a Spring MVC app on IBM WAS 6.1.

[17/07/13 12:31:55:466 BST] 0000001a WebApp        E   Exception caught while initializing context 
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0':
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Could not instantiate bean class [org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter]:
Constructor threw exception; nested exception is java.lang.ClassCastException:
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl incompatible 
with javax.xml.transform.TransformerFactory
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
            at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
            at com.ibm.ws.wswebcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:917)
            at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:378)
            at com.ibm.ws.wswebcontainer.webapp.WebApp.initialize(WebApp.java:338)
            at com.ibm.ws.wswebcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:93)
            at com.ibm.ws.wswebcontainer.VirtualHost.addWebApplication(VirtualHost.java:162)
            at com.ibm.ws.wswebcontainer.WebContainer.addWebApp(WebContainer.java:673)
            at com.ibm.ws.wswebcontainer.WebContainer.addWebApplication(WebContainer.java:626)
            at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:395)
            at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:611)
            at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1274)
            at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1164)
            at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:591)
            at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:831)
            at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:945)
            at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2120)
            at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:342)
            at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1551)

Same application works fine on Tomcat + Eclipse. But when I deployed this on IBM WAS 6.1 using Rational Application Developer I get this error during server startup.

Could any please help me in resolving this error.

Thanks in advance!

share|improve this question
    
Looks like a library from WAS is incompatible with a library used by your application. – kgautron Jul 17 '13 at 12:59
    
forum.springsource.org/… – VirtualTroll Jul 17 '13 at 13:03

This is a class loader issue and looks very similar to XSLT ClassCastException in WebSphere when Spring tries to create an AnnotationMethodHandlerAdapter

So try setting the class loader policy to PARENT_LAST and remove all dependencies on xml-apis / xerces / javax.xml jars from your application.

share|improve this answer
    
I am just using xalan.jar and if I remove this then I start getting Provider for com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl is not found error. – user2550387 Jul 17 '13 at 13:35
    
Are you using classes from the xalan.jar directly in your application? If so, be sure you're instantiating everything correctly (via TransformerFactory, etc.) Otherwise, you can change the default TransformerFactory implementation by setting the javax.xml.transform.TransformerFactory system property. – Syon Jul 17 '13 at 14:02
    
Do you know how can I set the system property javax.xml.transform.TransformerFactory in Websphere application server and which implementation would be compatible with javax.xml.transform.TransformerFactory – user2550387 Jul 17 '13 at 14:18
    
Try adding this to your web.xml <system-property javax.xml.transform.TransformerFactory="org.apache.xalan.processor.TransformerFa‌​ctoryImpl"/> – Syon Jul 17 '13 at 14:33
    
I just checked the class hierarchy for com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl. It extends javax.xml.transform.sax.SAXTransformerFactory which in turn extends javax.xml.transform.TransformerFactory why is the server throwing ClassCastException then? – user2550387 Jul 17 '13 at 14:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.