Spring web service Servlet.init() for servlet spring-ws threw exception - spring

I am trying to learn Spring web services, I found this tutorial :
http://jeromebulanadi.wordpress.com/2010/02/25/basic-spring-web-service-tutorial-from-contract-to-security/#comment-302
I imported the project prerson in eclipse, added the jar files, but when I run the project and typed :
http://localhost:8080/person/Person.wsdl
I got this error :
javax.servlet.ServletException: Servlet.init() for servlet spring-ws threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:662)
root cause
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘Person’ defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/xml/serializer/TreeWalker
Can you please help me ?
thanks.

java.lang.NoClassDefFoundError: org/apache/xml/serializer/TreeWalker
Add xalan-2.7.1.jar to your CLASSPATH.

Use xalan-2.7.0.jar. It worked for me.

I found a solution to this problem, just added serializer.jar to my classpath and it's working now, it looks like xalan-2.7.1.jar is missing TreeWalker.

Related

Mule Migration from 3.8.4 to 3.9.2 jars related issue

Getting below issue while migration from 3.8.4 to 3.9.2 Mule runtime.
java.lang.NoClassDefFoundError: org/springframework/context/ResourceLoaderAware (org.mule.api.lifecycle.InitialisationException) (org.mule.api.config.ConfigurationException)
I have spring spring-context-4.1.9.RELEASE.jar and all default jars in opt folder of Mule runtime.
ResourceLoaderAware class is in this spring-context-4.1.9.RELEASE.jar.
Any idea how do I resolve this issue.
Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name '_muleNotificationManager': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_muleTransactionManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.mule.api.transaction.TransactionManagerFactory org.mule.config.spring.factories.TransactionManagerFactoryBean.txManagerFactory; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] for bean with name 'entityManagerFactory' defined in class path resource [CCModuleFlood-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/context/ResourceLoaderAware (org.mule.api.lifecycle.InitialisationException) (org.mule.api.config.ConfigurationException)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:49) ~[mule-core-3.9.2.jar:3.9.2]
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:69) ~[mule-core-3.9.2.jar:3.9.2]
at org.mule.context.DefaultMuleContextFactory$1.configure(DefaultMuleContextFactory.java:89) ~[mule-core-3.9.2.jar:3.9.2]
at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:222) ~[mule-core-3.9.2.jar:3.9.2]
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:81) ~[mule-core-3.9.2.jar:3.9.2]
at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:210) ~[mule-module-launcher-3.9.2.jar:3.9.2]
... 18 more
Error NoClassDefFoundError doesn't mean that it was not able to find the class, it means that there was some previous error loading the class. You need to find the previous error to identify the root cause.
It might that there are some incompatible versions in the classpath that caused the original error.

Upgrading Spring with 3.1 to spring 4.0 applicationcontext.xml

I'm trying to upgrade spring from version 3.1 to version 4.0. But i am getting an error on RestApi :
14:11:00,286 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]
14:11:00,381 ERROR [ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:413)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
Thanks in advance..

Tomcat but not Jetty: NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey

I have recently upgraded my Wicket 6 application from Spring 3 to Spring 4.
When I run the application locally on Jetty 7, it runs fine.
When I deploy it to Tomcat 7, I get the following error:
[2014-05-07 10:20:47,121] ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
Is this a Tomcat issue or should I just go ahead and try to solve the nested exception java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()?
If the issue is indeed with the foreignKey, then why does the problem not occur on Jetty?
spring.version 4.0.4.RELEASE
hibernate.version 4.3.5.Final
dataSource: class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey
This exception occurs of there are conflicting version of javax.persistence.ForeignKey class. Check your classpath and if you are using maven check the dependencies.
For me, issue fixed after downgrading my project to java 6 and hibernate-entitymanager version to 3.6.9.FINAL

java.lang.NoSuchMethodError: org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)

I am getting the below error when I try to configure a spring-hibernate application:
org.springframework.beans.factory.BeanDefinitionStoreException:
Unexpected exception parsing XML document from ServletContext resource
[/WEB-INF/spring-servlet.xml]; nested exception is
java.lang.NoSuchMethodError:
org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues;
I have org.springframework.beans-3.0.0.M3.jar in the build path.
Please help.
Thanks in advance!
See java.lang.NoSuchMethodError: org.springframework.beans.MutablePropertyValues.add
Why you are using 3.0.0.M3 ?
Try to upgrade your spring version to 3.0.0.RELEASE.
add method was added in
Changes in version 3.0.0.RC3 (2009-12-01)
added chaining-capable "add" method to MutablePropertyValues

BeanCreationException with Spring and Jackson API

I am getting following exception while trying to use Jackson API with Spring 3.0.6. I have jackson jars of v1.8.9 (core-asl, mapper-asl) into the classpath but still due to some conflicting jars I am facing the error ::
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#8': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.converter.json.MappingJacksonHttpMessageConverter]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.codehaus.jackson.type.JavaType.<init>(Ljava/lang/Class;I)V
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270) [org.springframework.beans-3.0.6.RELEASE.jar:]
... 30 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.converter.json.MappingJacksonHttpMessageConverter]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.codehaus.jackson.type.JavaType.<init>(Ljava/lang/Class;I)V
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74) [org.springframework.beans-3.0.6.RELEASE.jar:]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958) [org.springframework.beans-3.0.6.RELEASE.jar:]
... 34 more
Caused by: java.lang.NoSuchMethodError: org.codehaus.jackson.type.JavaType.<init>(Ljava/lang/Class;I)V
at org.codehaus.jackson.map.type.TypeBase.<init>(TypeBase.java:13) [jackson-mapper-asl-1.8.9.jar:]
at org.codehaus.jackson.map.type.SimpleType.<init>(SimpleType.java:39) [jackson-mapper-asl-1.8.9.jar:]
at org.codehaus.jackson.map.type.SimpleType.constructUnsafe(SimpleType.java:56) [jackson-mapper-asl-1.8.9.jar:]
at org.codehaus.jackson.map.ObjectMapper.<clinit>(ObjectMapper.java:188) [jackson-mapper-asl-1.8.9.jar:]
at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.<init>(MappingJacksonHttpMessageConverter.java:56) [org.springframework.web-3.0.6.RELEASE.jar:]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [:1.6.0_24]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [:1.6.0_24]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [:1.6.0_24]
at java.lang.reflect.Constructor.newInstance(Constructor.java:532) [:1.6.0_24]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) [org.springframework.beans-3.0.6.RELEASE.jar:]
... 36 more
The correct version dependency of Jackson for Spring 3.0.6 is 1.4.2(per Spring's pom), try replacing 1.8.9 with this version, it should work correctly.
Thanks for your reply. However, I could solve out the issue doing some R&D... I need not go down to Jackson v1.4.2, instead I used the same version with slight modification in JBoss configuration itself.
In JBoss, go to modules/org/codehaus/jackson/jackson-core-asl/main/
Here JBoss is using its own version of Jackson API (though we had different version in classpath). So I copied the v1.8.9 and made changes accordingly in module.xml (in same directory). Similar thing was repeated for mapper jars v1.8.9.
With this I could fix the issue and run things again.... :)

Resources