2

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!

2
  • Looks like a library from WAS is incompatible with a library used by your application. Commented Jul 17, 2013 at 12:59
  • forum.springsource.org/… Commented Jul 17, 2013 at 13:03

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

9 Comments

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.
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.
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
Try adding this to your web.xml <system-property javax.xml.transform.TransformerFactory="org.apache.xalan.processor.TransformerFactoryImpl"/>
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?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.