2
votes

I am trying to deploy a Spring-Ws application on WAS 8 with the below configuration:

Web.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/xxx-servlet.xml</param-value>
</context-param>

<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/log4j.properties</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>xxx-services</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    <init-param>
        <param-name>transformWsdlLocations</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>xxx-services</servlet-name>
    <url-pattern>/endpoints/*</url-pattern>
</servlet-mapping>

<resource-ref>
    <description>MGI Data Source</description>
    <res-ref-name>jdbc/xxxDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

Spring-Context.xml

<sws:annotation-driven />

<context:component-scan
    base-package="com.xxx.webservices.endpoints,com.xxx.webservices.service,com.xxx.webservices.dao" />


<bean id="validatingInterceptor"
    class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
    <property name="schemas">
        <list>
            <value>WEB-INF/classes/schemas/CodeDetails.xsd</value>
            <value>WEB-INF/classes/schemas/GetAccountRangeConfig.xsd</value>
            <value>WEB-INF/classes/schemas/GetCABExceptionTerms.xsd</value>
            <value>WEB-INF/classes/schemas/SaveAccountRangeConfig.xsd</value>
        </list>
    </property>
    <property name="validateRequest" value="true" />
</bean>

<bean id="testService"
    class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition"
    lazy-init="true">
    <property name="schemaCollection">
        <bean
            class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
            <property name="inline" value="true" />
            <property name="xsds">
                <list>
                    <value>WEB-INF/classes/schemas/CodeDetails.xsd</value>
                    <value>WEB-INF/classes/schemas/GetAccountRangeConfig.xsd</value>
                    <value>WEB-INF/classes/schemas/GetCABExceptionTerms.xsd</value>
                    <value>WEB-INF/classes/schemas/SaveAccountRangeConfig.xsd</value>
                </list>
            </property>
        </bean>
    </property>
    <property name="portTypeName" value="TestService" />
    <property name="serviceName" value="TestService" />
    <property name="locationUri"
        value="/endpoints" />
</bean>

<bean id="exceptionResolver"
    class="org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver">
    <property name="defaultFault" value="SERVER" />
    <property name="exceptionMappings">
        <value>
            org.springframework.oxm.ValidationFailureException=CLIENT,Invalid Request
        </value>

    </property>
</bean>

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/jdbc/xxxDB"/>
</bean>

When I build and deploy this WAR file onto WAS 8, I am getting the below error message:

SourceId: org.springframework.web.context.support.XmlWebApplicationContext.org.springframework.context.support.AbstractApplication

Context.refresh ExtendedMessage: Exception encountered during context initialization - cancelling refresh attemptorg.springframework.beans.factory .BeanCreationException: Error creating bean with name 'org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection#0': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org/apache/ws/commons/schema/XmlSchemaCollection.read(Lorg/ xml/sax/InputSource;)Lorg/apache/ws/commons/schema/XmlSchema; at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.j ava:1553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.jav a:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java: 475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:72 5) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:7 57) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1704) at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:411) at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88) at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169) at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:749) at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:634) at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:426) at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:718) at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1177) at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1370) at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639) at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:968) at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:776) at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1379) at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2189) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:435) at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:378) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:126) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$1.run(CompositionUnitMgrImpl.java:653) at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5477) at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5603) at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:667) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:611) at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1269) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56) at java.lang.reflect.Method.invoke(Method.java:620) at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:88) at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56) at java.lang.reflect.Method.invoke(Method.java:620) at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:292) at javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1261) at java.security.AccessController.doPrivileged(AccessController.java:311) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:88) at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1255) at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:1093) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:832) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:814) at com.ibm.ws390.management.connector.corba.CorbaConnectorImpl.invoke(CorbaConnectorImpl.java:1073) at com.ibm.ws390.management.connector.corba._CorbaConnectorImplBase._invoke(_CorbaConnectorImplBase.java:416) at com.ibm.ws390.orb.CommonBridge.invoke(CommonBridge.java:1898) at com.ibm.ws390.orb.CommonBridge.getAndProcessWork(CommonBridge.java:725) at com.ibm.ws390.orb.CommonBridge.runApplicationThread(CommonBridge.java:614) at com.ibm.ws.util.ThreadPool$ZOSWorker.run(ThreadPool.java:2116) Caused by: java.lang.NoSuchMethodError: org/apache/ws/commons/schema/XmlSchemaCollection.read(Lorg/xml/sax/InputSource;)Lorg/apache/ ws/commons/schema/XmlSchema; at org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection.afterPropertiesSet(CommonsXsdSchemaCollection.java:140) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactor y.java:1612) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.j ava:1549) ... 60 more

I searched through StackOverFlow, spent a lot of time researching on this issue in Google and tried changing the class loading strategy to Parent Last but still I am getting the same error. Here is the list of JARs inside my WEB-INF/lib:

aopalliance-1.0.jar
commons-dbcp-1.2.2.jar
commons-logging-1.1.3.jar
commons-pool-1.3.jar
jaxb-api-2.2.12.jar
jaxb-core-2.2.11.jar
jaxb-impl-2.2.11.jar
log4j-1.2.17.jar
ojdbc6-11.2.0.jar
spring-aop-4.1.0.RC2.jar
spring-beans-4.1.0.RC2.jar
spring-context-4.1.0.RC2.jar
spring-context-support-4.1.0.RC2.jar
spring-core-4.1.0.RC2.jar
spring-expression-4.1.0.RC2.jar
spring-jdbc-4.1.0.RC2.jar
spring-oxm-4.1.0.RC2.jar
spring-secutiry-core-3.2.5.RELEASE.jar
spring-tx-4.0.9.RELEASE.jar
spring-web-4.1.0.RC2.jar
spring-webmvc-4.1.0.RC2.jar
spring-ws-core-2.2.1.RELEASE.jar
spring-ws-security-2.2.1.RELEASE.jar
spring-ws-test-2.2.1.RELEASE.jar
spring-xml-2.2.1.RELEASE.jar
xmlschema-core-2.2.1.RELEASE.jar
xmlunit-1.5.jar

Has any body faced this issue? Any help would be greatly appreciated. Should I remove any other JAR? Am I missing something?

I even tried mvn dependency:tree -Dverbose=true -Dincludes=org.apache.ws.xmlschema:xmlschema-core:: but nothing came up :(

1
Switch class loading to parent last that way your web-inf/lib directory will be consulted before the classes of the app server. - M. Deinum
I already tried that but still I am getting the same error. Is there any other setting that I should do? - Venkatesh Nachimuthu
For starters I would fix mixing different versions of spring jars (4.0.9 and 4.1.0.RC2) also why aren't you using a final version but some beta version? Your JAXB versions also appear not to match up (also you shouldn't need JAXB as that is part of the JDK). You also might want to downgrade xmlschema to 2.2.0 and use the full xmlschema jar and not only the core. - M. Deinum
I have updated my pom.xml to use latest Spring JARs. But I am not sure why the latest spring-tx is not being picked up by Maven. I have not declared it manually, it might be part of other spring JAR dependencies. Also, my code works now after moving xmlschema-core-2.2.1.RELEASE.jar to a shared library. Thanks a lot!!! - Venkatesh Nachimuthu

1 Answers

2
votes

IBM WAS has its own implementation of class org.apache.ws.commons.schema.XmlSchemaCollection, located in one of many jars supplied with WAS. To prevent WAS from loading first class XmlSchemaCollection that doesn't have the necessary method read(), you should use your own xmlschema-core-2.2.1.RELEASE.jar (in version 2.2.1 class XmlSchemaCollection for sure has needed read() method) as IBM WAS shared library. You can setup shared library and connect it to your web application in WAS administrative console. It will fix your problem.