Announcement Announcement Module
Collapse
No announcement yet.
How to exclude specific depedency version Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to exclude specific depedency version

    My grails (1.3.5) app contains both slf4j versions 1.5.8 & 1.6.1; thus
    resulting in a version clash (see below).

    I believe grails uses version 1.5.8 and another app dependency uses 1.6.1. How
    can I exclude a specific slf4j version to eliminate this conflict? Thanks.

    SEVERE: Exception sending context initialized event to listener instance of
    class org.codehaus.groovy.grails.web.context.GrailsConte xtLoaderListener
    java.lang.NoSuchMethodError:
    org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/ThrowableV
    at
    org.apache.commons.logging.impl.SLF4JLocationAware Log.error(SLF4JLocationAwareLog.java:225)
    at
    org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:225)

    at
    org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 47)
    at
    org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3972)
    at
    org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4467)
    at
    org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:791)
    at
    org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:546)
    at org.apache.catalina.startup.HostConfig.deployWAR(H ostConfig.java:905)
    at
    org.apache.catalina.startup.HostConfig.deployWARs( HostConfig.java:740)
    at
    org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:500)
    at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:1277)
    at
    org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:321)
    at
    org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:785)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at
    org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at
    org.apache.catalina.core.StandardService.start(Sta ndardService.java:519)
    at
    org.apache.catalina.core.StandardServer.start(Stan dardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:581)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at
    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:414)
    Last edited by dan0; Feb 10th, 2011, 01:13 PM.

  • #2
    The user guide explains how to do this. Simply add an 'excludes' with the dependency:
    Code:
    runtime "commons-io:commons-io:1.4", {
        excludes "commons-logging"
    }

    Comment


    • #3
      Originally posted by pledbrook View Post
      The user guide explains how to do this. Simply add an 'excludes' with the dependency:
      Code:
      runtime "commons-io:commons-io:1.4", {
          excludes "commons-logging"
      }
      Thanks for the link. However, prior to submitting my OP, I reviewed the user guide. As I understand it, only non-grail required (transitive) dependency's can be 'excluded.' I was curious if there was a way to choose which version of the dependency is excluded, regardless if it is required by grails or another dependency. For example, in my current situation grails requires version 1.5.8 while another dep requires 1.6.1. I want to know if it is currently possible to 'exclude' the grails requirement of 1.5.8 and use 1.6.1

      Currently, to solve the problem, I'm excluding version 1.6.1 which is a non-grails dep.

      Thanks.
      Last edited by dan0; Feb 10th, 2011, 01:06 PM.

      Comment


      • #4
        See the section on inherited dependencies (3.7.4) for the syntax to use.

        Comment


        • #5
          Originally posted by pledbrook View Post
          See the section on inherited dependencies (3.7.4) for the syntax to use.
          I foolishly stopped at section 3.7.1; I certainly need to read the user guide more thoroughly.

          In any event, thanks again for the help.

          Comment


          • #6
            I have the same exact issue.

            I did it like:
            Code:
            grails.project.dependency.resolution = {
                inherits("global") {
                    excludes 'groovy-all'
                }
            }
            
            dependencies {
                compile 'org.codehaus.groovy:groovy-all:1.8.3'
            }
            However both groovy-all versions are excluded. The original one 1.7.8 which is inherited from Grails dependencies and the explicit specified 1.8.3 too. This results with no desired dependency at all.

            If version specified at the excludes line none groovy-all jar is excluded. I mean the exclude does not work at all. The result is dependency conflict visible through dependency-report.
            By version specified at excludes line I mean:

            Code:
                inherits("global") {
                    excludes 'org.codehaus.groovy:groovy-all:1.7.8'
                }
            Good thing is that war archive gets only desired lib version, but this is normal behavior thanks to conflict manager even if no excludes statement specified at all.

            How this can be solved?

            I'm trying with Grails 1.3.7

            Comment


            • #7
              How to exclude specific depedency version

              Could you please elaborate your situation a little bit more?

              Comment


              • #8
                Me? Of course.

                Shortly speaking I would like to upgrade groovy version from 1.7.8 to current one (1.8.3) for application built with Grails 1.3.7.
                How this can be achieved?

                Longer story is when I put excludes 'groovy-all' at inherits("global") block in BuildConfig.groovy then groovy-all.jar is excluded totally despite newer version is specified explicit to 1.8.3 at dependencies block, section compile.
                OK, I can agree it can be treated as desired behavior but when I set which exact version should be excluded (1.7.8) then following things occur when running command:
                - grails dependency-report, shows conflict between groovy versions: 1.7.8 as evicted and 1.8.3 as selected
                - grails run-app, still shows groovy 1.7.8 at start page (considering inconsistency with above point)
                - grails war, put inside war desired jar version 1.8.3 and no 1.7.8 so only this one behave correct. However one can simply run into inconsistent application behavior f.e. when developing with grails run-app and deploying with grails war

                I'm quite sure this is a bug or even two independent bugs. Maybe there is some way to overcome it?

                Comment

                Working...
                X