• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Parent POM having old Spring with run time dependency , child pom used new Spring

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

My parent POM which I can't change is having Spring 3.0.3 defined with run time dependency where as the child pom is using a new Spring version 3.2.9 with compile time dependency. Now the WAR which is getting created is having the old Spring Jars as well along with new one. So when I run my application I am getting the below error

2015-08-20 16:37:28,069 INFO [org.springframework.web.context.ContextLoader] - <Root WebApplicationContext: initialization started>
2015-08-20 16:37:28,123 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:404)

The Parent POM is having the below Entry
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.context</artifactId>
<scope>runtime</scope>
</dependency>

The following jars are getting added to the war file along with the new 3.2.9 version Jars.

WEB-INF/lib/org.springframework.context-3.0.3.RELEASE.jar
WEB-INF/lib/org.springframework.expression-3.0.3.RELEASE.jar
WEB-INF/lib/org.springframework.beans-3.0.3.RELEASE.jar
WEB-INF/lib/org.springframework.core-3.0.3.RELEASE.jar

In my child POM there is no reference of old Spring version.

Is there a solution to this issue? Note we can not change the Parent POM.xml as it is being used across multiple application.

Regards
Abhishek
 
Ranch Hand
Posts: 376
2
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what about adding explicit version ?

<version>${spring.version}</version>

 
Abhishek Rath
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the child POM I have added the version explicitly. However the older one is getting downloaded added to WAR and used during runtime and hence resulting in the error due to spring version mismatch.
 
Abhishek Rath
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I executed the mvn dependency:tree I found the below

[INFO] +- org.springframework:spring-oxm:jar:3.2.9.RELEASE:compile
[INFO] | \- org.springframework:spring-beans:jar:3.2.9.RELEASE:compile
[INFO] +- org.springframework:org.springframework.context:jar:3.0.3.RELEASE:runtime
[INFO] | +- org.springframework:org.springframework.asm:jar:3.0.3.RELEASE:runtime
[INFO] | +- org.springframework:org.springframework.aop:jar:3.0.3.RELEASE:runtime
[INFO] | | \- org.aopalliance:com.springsource.org.aopalliance:jar:1.0.0:runtime
[INFO] | +- org.springframework:org.springframework.beans:jar:3.0.3.RELEASE:runtime
[INFO] | +- org.springframework:org.springframework.core:jar:3.0.3.RELEASE:runtime
[INFO] | \- org.springframework:org.springframework.expression:jar:3.0.3.RELEASE:runtime
[INFO] \- org.slf4j:com.springsource.slf4j.org.apache.commons.logging:jar:1.5.10:runtime

The new Spring is used for Compile and the old one is for runtime.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are going to use one version of Spring to compile, and another to run, then you are guaranteed to get java.lang.NoSuchMethodError somewhere. You shouldn't be using differrent versions of Spring.
 
Abhishek Rath
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes . Now i would like to override the runtime old version of Spring which is defined in my parent pom in my child POM. The reason is I cant change my Parent POM as it is being used across application. Is there any way I can do it in my child POM?
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic