Re: [play-framework] [play-2.2.2] Unable to Exclude Certain Library Dependencies

805 views
Skip to first unread message

James Roper

unread,
May 20, 2014, 3:31:14 AM5/20/14
to play-framework
In your project, open target/resolution-cache/reports/<yourprojectname>-compile.xml in a browser that supports XML stylesheets (ie, Firefox or Safari, but not Chrome).  You'll get a nicely formatted report of all the dependencies in your project, with a tree view showing the paths to how transitive dependencies are included, and a summary for each dependency describing which other dependencies require them.  This should tell you which dependencies you need to exclude your dependency from.


On Wed, May 14, 2014 at 4:56 AM, Ben <be...@matthiasgroup.com> wrote:
Hi everyone,

I am using Play 2.2.2 and sbt 0.13.0.  I have been trying to exclude certain libraries from the project at runtime but to no avail.  I have searched through this group as well as other sources on the Internet.  I have tried to use "exclude" and "excludeAll" but Play keeps including the libraries.  Any help or suggestions at this point are greatly appreciated.

Basically, the "com.gemex" % "arch" % "1.8-SNAPSHOT" library depends on "org.acegisecurity" % "acegi-security" % "1.0.5" which depends on two old org.springframework libraries (spring-remote and spring-support).  I want to leave the two old org.springframework libraries out.  Here is my Build.scala file:

import sbt._
import Keys._
import play.Project._
import com.github.play2war.plugin._

object ApplicationBuild extends Build {

  val appName = "feed"
  val appVersion = "1.0-SNAPSHOT"

  val appDependencies = Seq(

    // Add your project dependencies here,
    "com.gemex" % "core" % "1.7" exclude("org.slf4j", "slf4j-log4j12") exclude("log4j", "log4j"),
    "com.gemex" % "arch" % "1.8-SNAPSHOT" exclude("org.springframework", "spring-support") exclude ("org.springframework", "spring-remoting"),
    "com.gemex" % "utils" % "1.7" exclude("org.slf4j", "slf4j-log4j12") exclude("log4j", "log4j"),
    "com.javaforge.scriptella" % "scriptella-core" % "1.0",
    "com.javaforge.scriptella" % "scriptella-drivers" % "1.0",
    "com.javaforge.scriptella" % "scriptella-tools" % "1.0",
    "mysql" % "mysql-connector-java" % "3.1.12",
    "net.sf.beanlib" % "beanlib" % "5.0.3",
    "net.sf.beanlib" % "beanlib-hibernate" % "5.0.3",
    "org.codehaus.janino" % "janino" % "2.6.1",
    "org.hibernate" % "hibernate-core" % "3.6.10.Final",
    "org.quartz-scheduler" %"quartz" % "2.2.1",
    "org.quartz-scheduler" %"quartz-jobs" % "2.2.1",
    "org.springframework" % "spring-core" % "3.2.8.RELEASE",
    "org.springframework" % "spring-beans" % "3.2.8.RELEASE",
    "org.springframework" % "spring-context" % "3.2.8.RELEASE",
    "org.springframework" % "spring-orm" % "3.2.8.RELEASE",
    "org.springframework" % "spring-tx" % "3.2.8.RELEASE",
    "org.springframework.security" % "spring-security-core" % "3.2.2.RELEASE" exclude("org.springframework", "spring-asm"),
    "org.springframework.security" % "spring-security-ldap" % "3.2.2.RELEASE" exclude("org.springframework", "spring-asm"),
    javaCore,
    javaJdbc,
    javaEbean,
    cache
  )

  val main = play.Project(appName, appVersion, appDependencies)

    .settings(Play2WarPlugin.play2WarSettings: _*)
    .settings(Play2WarKeys.servletVersion := "3.0")
    .settings(Play2WarKeys.explodedJar := true)
    .settings(Play2WarKeys.filteredArtifacts := Seq(("org.springframework", "spring-asm"),
                                                    ("org.springframework", "spring-remoting"),
                                                    ("org.springframework", "spring-support")))
    .settings(Play2WarKeys.targetName := Some("feed"))
    .settings(

      // Add your own project settings here
      resolvers += "GemEx releases repository" at "http://app01.gemex.net/nexus/content/groups/public"
    )
}

Here is the output and it appears to include the org.springframework 1.0.5 libraries (spring-remote and spring-support)

/Library/Java/JavaVirtualMachines/1.6.0_43-b01-447.jdk/Contents/Home/bin/java -Dfile.encoding=UTF8 -Dsbt.boot.properties=file:////Users/benw/Applications/play-2.2.2/framework/sbt/sbt.boot.properties -Djline.terminal=none -Dsbt.log.noformat=true "-Dplay.version= ]; then
  PLAY_VERSION=" -Dtarget.env=local -Dsbt.global.base=/private/var/folders/gz/p08d8vkn7hx4lkr1pmkb_zk40000gn/T/sbt-global-plugin6624736794483619280stub -Dsbt.ivy.home=/Users/benw/Applications/play-2.2.2/repository -Dconfig.resource=local.conf -Dplay.home=/Users/benw/Applications/play-2.2.2/framework -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M -classpath /Users/benw/Applications/play-2.2.2/framework/sbt/sbt-launch.jar xsbt.boot.Boot run
[info] Loading project definition from /Users/benw/Projects/gemex/feed/project

This project uses Play 2.2.2!
Update the Play sbt-plugin version to  ]; then
  PLAY_VERSION= (usually in project/plugins.sbt)
        
[info] Set current project to feed (in build file:/Users/benw/Projects/gemex/feed/)
[info] Updating {file:/Users/benw/Projects/gemex/feed/}feed...
[info] Resolving org.scala-lang#scala-library;2.10.3 ...
[info] Resolving com.typesafe.play#sbt-link;2.2.2 ...
[info] Resolving org.javassist#javassist;3.18.0-GA ...
[info] Resolving com.jsuereth#scala-arm_2.10;1.3 ...
[info] Resolving org.scala-stm#scala-stm_2.10;0.7 ...
[info] Resolving com.typesafe#config;1.0.2 ...
[info] Resolving joda-time#joda-time;2.2 ...
[info] Resolving org.joda#joda-convert;1.3.1 ...
[info] Resolving com.fasterxml.jackson.core#jackson-annotations;2.2.2 ...
[info] Resolving com.fasterxml.jackson.core#jackson-core;2.2.2 ...
[info] Resolving com.fasterxml.jackson.core#jackson-databind;2.2.2 ...
[info] Resolving org.scala-lang#scala-reflect;2.10.3 ...
[info] Resolving io.netty#netty;3.7.0.Final ...
[info] Resolving com.typesafe.netty#netty-http-pipelining;1.1.2 ...
[info] Resolving org.slf4j#slf4j-api;1.7.5 ...
[info] Resolving org.slf4j#jul-to-slf4j;1.7.5 ...
[info] Resolving org.slf4j#jcl-over-slf4j;1.7.5 ...
[info] Resolving ch.qos.logback#logback-core;1.0.13 ...
[info] Resolving ch.qos.logback#logback-classic;1.0.13 ...
[info] Resolving com.typesafe.akka#akka-actor_2.10;2.2.0 ...
[info] Resolving com.typesafe.akka#akka-slf4j_2.10;2.2.0 ...
[info] Resolving org.apache.commons#commons-lang3;3.1 ...
[info] Resolving com.ning#async-http-client;1.7.18 ...
[info] Resolving oauth.signpost#signpost-core;1.2.1.2 ...
[info] Resolving commons-codec#commons-codec;1.3 ...
[info] Resolving oauth.signpost#signpost-commonshttp4;1.2.1.2 ...
[info] Resolving org.apache.httpcomponents#httpcore;4.0.1 ...
[info] Resolving org.apache.httpcomponents#httpclient;4.0.1 ...
[info] Resolving commons-logging#commons-logging;1.1.1 ...
[info] Resolving xerces#xercesImpl;2.11.0 ...
[info] Resolving xml-apis#xml-apis;1.4.01 ...
[info] Resolving javax.transaction#jta;1.1 ...
[info] Resolving org.yaml#snakeyaml;1.12 ...
[info] Resolving org.hibernate#hibernate-validator;5.0.1.Final ...
[info] Resolving javax.validation#validation-api;1.1.0.Final ...
[info] Resolving org.jboss.logging#jboss-logging;3.1.1.GA ...
[info] Resolving com.fasterxml#classmate;0.8.0 ...
[info] Resolving org.reflections#reflections;0.9.8 ...
[info] Resolving com.google.guava#guava;14.0.1 ...
[info] Resolving com.google.code.findbugs#jsr305;2.0.1 ...
[info] Resolving javax.servlet#javax.servlet-api;3.0.1 ...
[info] Resolving com.gemex#core;1.7 ...
[info] Resolving org.hibernate#hibernate-core;3.6.10.Final ...
[info] Resolving antlr#antlr;2.7.6 ...
[info] Resolving commons-collections#commons-collections;3.1 ...
[info] Resolving dom4j#dom4j;1.6.1 ...
[info] Resolving org.hibernate#hibernate-commons-annotations;3.2.0.Final ...
[info] Resolving org.hibernate.javax.persistence#hibernate-jpa-2.0-api;1.0.1.Final ...
[info] Resolving org.springframework#spring-core;3.2.8.RELEASE ...
[info] Resolving commons-logging#commons-logging;1.1.3 ...
[info] Resolving org.springframework#spring-orm;3.2.8.RELEASE ...
[info] Resolving org.springframework#spring-beans;3.2.8.RELEASE ...
[info] Resolving org.springframework#spring-jdbc;3.2.8.RELEASE ...
[info] Resolving org.springframework#spring-tx;3.2.8.RELEASE ...
[info] Resolving com.gemex#arch;1.8-SNAPSHOT ...
[info] Resolving org.acegisecurity#acegi-security;1.0.5 ...
[info] Resolving org.springframework#spring-remoting;1.2.9 ...
[info] Resolving org.springframework#spring-aop;1.2.9 ...
[info] Resolving commons-lang#commons-lang;2.1 ...
[info] Resolving oro#oro;2.0.8 ...
[info] Resolving org.springframework#spring-support;1.2.9 ...
[info] Resolving log4j#log4j;1.2.9 ...
[info] Resolving commons-beanutils#commons-beanutils;1.8.3 ...
[info] Resolving net.sf.jasperreports#jasperreports;3.6.1 ...
[info] Resolving commons-digester#commons-digester;1.7 ...
[info] Resolving com.lowagie#itext;2.1.0 ...
[info] Resolving bouncycastle#bcmail-jdk14;136 ...
[info] Resolving bouncycastle#bcprov-jdk14;136 ...
[info] Resolving jfree#jcommon;1.0.15 ...
[info] Resolving jfree#jfreechart;1.0.12 ...
[info] Resolving eclipse#jdtcore;3.1.0 ...
[info] Resolving log4j#log4j;1.2.17 ...
[info] Resolving org.springframework#spring-web;3.2.8.RELEASE ...
[info] Resolving org.springframework#spring-aop;3.2.8.RELEASE ...
[info] Resolving aopalliance#aopalliance;1.0 ...
[info] Resolving org.springframework#spring-context;3.2.8.RELEASE ...
[info] Resolving org.springframework#spring-expression;3.2.8.RELEASE ...
[info] Resolving org.springframework.ldap#spring-ldap-core;1.3.1.RELEASE ...
[info] Resolving commons-lang#commons-lang;2.5 ...
[info] Resolving tapestry#tapestry;3.0.3 ...
[info] Resolving bsf#bsf;2.3.0 ...
[info] Resolving commons-fileupload#commons-fileupload;1.0 ...
[info] Resolving jboss#javassist;2.6 ...
[info] Resolving ognl#ognl;2.6.3 ...
[info] Resolving org.apache.tapestry#tapestry-core;5.0.17 ...
[info] Resolving org.apache.tapestry#tapestry-ioc;5.0.17 ...
[info] Resolving org.apache.tapestry#tapestry5-annotations;5.0.17 ...
[info] Resolving javassist#javassist;3.8.0.GA ...
[info] Resolving org.slf4j#slf4j-log4j12;1.5.2 ...
[info] Resolving com.gemex#utils;1.7 ...
[info] Resolving com.enterprisedt#edtFTPj;1.5.3 ...
[info] Resolving com.javaforge.scriptella#scriptella-core;1.0 ...
[info] Resolving commons-jexl#commons-jexl;1.1 ...
[info] Resolving junit#junit;3.8.1 ...
[info] Resolving com.javaforge.scriptella#scriptella-drivers;1.0 ...
[info] Resolving com.rackspacecloud#client-cloudfiles;1.0 ...
[info] Resolving net.sf.jasperreports#jasperreports;5.5.0 ...
[info] Resolving commons-digester#commons-digester;2.1 ...
[info] Resolving com.lowagie#itext;2.1.7.js2 ...
[info] Resolving bouncycastle#bcmail-jdk14;138 ...
[info] Resolving bouncycastle#bcprov-jdk14;138 ...
[info] Resolving bouncycastle#bctsp-jdk14;138 ...
[info] Resolving org.bouncycastle#bctsp-jdk14;1.38 ...
[info] Resolving org.bouncycastle#bcprov-jdk14;1.38 ...
[info] Resolving org.bouncycastle#bcmail-jdk14;1.38 ...
[info] Resolving org.codehaus.castor#castor;1.2 ...
[info] Resolving org.apache.httpcomponents#httpclient;4.1.3 ...
[info] Resolving org.apache.httpcomponents#httpcore;4.1.4 ...
[info] Resolving commons-codec#commons-codec;1.4 ...
[info] Resolving org.freemarker#freemarker-gae;2.3.20 ...
[info] Resolving org.quartz-scheduler#quartz;2.2.1 ...
[info] Resolving c3p0#c3p0;0.9.1.1 ...
[info] Resolving org.quartz-scheduler#quartz-jobs;2.2.1 ...
[info] Resolving org.springframework#spring-context-support;3.2.8.RELEASE ...
[info] Resolving org.springframework#spring-webmvc;3.2.8.RELEASE ...
[info] Resolving com.javaforge.scriptella#scriptella-tools;1.0 ...
[info] Resolving org.apache.ant#ant;1.7.1 ...
[info] Resolving org.apache.ant#ant-launcher;1.7.1 ...
[info] Resolving mysql#mysql-connector-java;3.1.12 ...
[info] Resolving net.sf.beanlib#beanlib;5.0.3 ...
[info] Resolving net.sf.beanlib#beanlib-hibernate;5.0.3 ...
[info] Resolving org.codehaus.janino#janino;2.6.1 ...
[info] Resolving org.codehaus.janino#commons-compiler;2.6.1 ...
[info] Resolving org.springframework.security#spring-security-core;3.2.2.RELEASE ...
[info] Resolving org.springframework.security#spring-security-ldap;3.2.2.RELEASE ...
[info] Resolving org.springframework.ldap#spring-ldap-core;1.3.2.RELEASE ...
[info] Resolving com.jolbox#bonecp;0.8.0.RELEASE ...
[info] Resolving com.h2database#h2;1.3.172 ...
[info] Resolving tyrex#tyrex;1.0.1 ...
[info] Resolving org.avaje.ebeanorm#avaje-ebeanorm;3.2.2 ...
[info] Resolving org.avaje.ebeanorm#avaje-ebeanorm-agent;3.2.1 ...
[info] Resolving net.sf.ehcache#ehcache-core;2.6.6 ...
[info] Resolving com.github.play2war#play2-war-core-servlet30_2.10;1.2-beta4 ...
[info] Resolving com.github.play2war#play2-war-core-common_2.10;1.2-beta4 ...
[info] Resolving org.springframework#spring-jdbc;1.2.9 ...
[info] Resolving org.springframework#spring-dao;1.2.9 ...
[info] Resolving junit#junit;4.11 ...
[info] Resolving org.hamcrest#hamcrest-core;1.3 ...
[info] Resolving org.specs2#specs2_2.10;2.1.1 ...
[info] Resolving org.scalaz#scalaz-core_2.10;7.0.2 ...
[info] Resolving org.scalaz#scalaz-concurrent_2.10;7.0.2 ...
[info] Resolving org.scalaz#scalaz-effect_2.10;7.0.2 ...
[info] Resolving com.novocode#junit-interface;0.10 ...
[info] Resolving org.scala-tools.testing#test-interface;0.5 ...
[info] Resolving org.fluentlenium#fluentlenium-festassert;0.8.0 ...
[info] Resolving org.fluentlenium#fluentlenium-core;0.8.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-java;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-android-driver;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-remote-driver;2.32.0 ...
[info] Resolving cglib#cglib-nodep;2.1_3 ...
[info] Resolving org.json#json;20080701 ...
[info] Resolving org.seleniumhq.selenium#selenium-api;2.32.0 ...
[info] Resolving org.apache.httpcomponents#httpclient;4.2.1 ...
[info] Resolving org.apache.httpcomponents#httpcore;4.2.1 ...
[info] Resolving commons-codec#commons-codec;1.6 ...
[info] Resolving org.apache.commons#commons-exec;1.1 ...
[info] Resolving net.java.dev.jna#jna;3.4.0 ...
[info] Resolving net.java.dev.jna#platform;3.4.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-chrome-driver;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-htmlunit-driver;2.32.0 ...
[info] Resolving net.sourceforge.htmlunit#htmlunit;2.12 ...
[info] Resolving xalan#xalan;2.7.1 ...
[info] Resolving xalan#serializer;2.7.1 ...
[info] Resolving commons-collections#commons-collections;3.2.1 ...
[info] Resolving org.apache.httpcomponents#httpmime;4.2.3 ...
[info] Resolving net.sourceforge.htmlunit#htmlunit-core-js;2.12 ...
[info] Resolving net.sourceforge.nekohtml#nekohtml;1.9.18 ...
[info] Resolving net.sourceforge.cssparser#cssparser;0.9.9 ...
[info] Resolving org.w3c.css#sac;1.3 ...
[info] Resolving commons-io#commons-io;2.2 ...
[info] Resolving org.eclipse.jetty#jetty-websocket;8.1.9.v20130131 ...
[info] Resolving org.eclipse.jetty#jetty-util;8.1.9.v20130131 ...
[info] Resolving org.eclipse.jetty#jetty-io;8.1.9.v20130131 ...
[info] Resolving org.eclipse.jetty#jetty-http;8.1.9.v20130131 ...
[info] Resolving org.seleniumhq.selenium#selenium-firefox-driver;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-ie-driver;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-iphone-driver;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-safari-driver;2.32.0 ...
[info] Resolving org.webbitserver#webbit;0.4.14 ...
[info] Resolving org.seleniumhq.selenium#selenium-support;2.32.0 ...
[info] Resolving org.easytesting#fest-assert;1.4 ...
[info] Resolving org.easytesting#fest-util;1.1.6 ...
[info] Resolving org.pegdown#pegdown;1.4.0 ...
[info] Resolving org.parboiled#parboiled-java;1.1.5 ...
[info] Resolving org.parboiled#parboiled-core;1.1.5 ...
[info] Resolving org.ow2.asm#asm;4.1 ...
[info] Resolving org.ow2.asm#asm-tree;4.1 ...
[info] Resolving org.ow2.asm#asm-analysis;4.1 ...
[info] Resolving org.ow2.asm#asm-util;4.1 ...
[info] Resolving commons-io#commons-io;2.4 ...
[info] Resolving org.scala-lang#scala-compiler;2.10.3 ...
[info] Resolving org.scala-lang#jline;2.10.3 ...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.

--- (Running the application from SBT, auto-reloading is enabled) ---

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/benw/Applications/play-2.2.2/repository/local/ch.qos.logback/logback-classic/1.0.13/jars/logback-classic.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/benw/Applications/play-2.2.2/repository/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.5.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0%0:9000

Server started, use Alt+D to stop

Note that if I build the app into a WAR file and took out these two jars, the app runs without any problems.  When these two jars are included, the app gets confused and used the old classes and throws an exception.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
James Roper
Software Engineer

Typesafe – Build reactive apps!
Twitter: @jroper

Ben

unread,
Feb 6, 2015, 2:49:45 PM2/6/15
to play-fr...@googlegroups.com
I haven't yet solved this problem since my initial post.  I decided to not worry about it and test the code by strictly using the WAR file created by the Play2War plugin.  However, I am now ready to try to fix this again so I can run and test using the native activator/play command.

James, thanks for the tip (very helpful) on where to look to figure out the dependencies.  The report basically confirmed that the acegi-security library is only required by our "com.gemex" % "arch" library (see screenshot).  It shows that it is in configurations, "compile, runtime".  I have researched and tried many different ways to exclude this library and all libraries that depend on this to no avail.

Since then, I have upgraded the project to Play 2.3.7 and sbt version to 0.13.7.  I also tried using sbt version 0.13.6.  All in the hope that it will fix this problem.

I have tried this:

  "com.gemex" % "arch" % "1.8" exclude ("org.acegisecurity", "acegi-security")

and this:

  "com.gemex" % "arch" % "1.8" intransitive()

and this:

assemblyExcludedJars in assembly := {
  val cp = (fullClasspath in assembly).value
  cp filter {_.data.getName == "org.springframework.spring-support-1.2.9.jar"}
}

No matter what I have tried, the acegi-security jar is still being included.

Any other advice or what logs I can chase after.  

Thanks,
Ben
2015-02-06_13-46-29.jpg

Will Sargent

unread,
Feb 10, 2015, 3:04:10 PM2/10/15
to play-fr...@googlegroups.com
Check out the SBT dependency graph and the diagramming sugar that Gilt put together:


Will Sargent
Consultant, Professional Services
Typesafe, the company behind Play Framework, Akka and Scala

Ben

unread,
Feb 10, 2015, 3:14:33 PM2/10/15
to play-fr...@googlegroups.com
Okay, I solved this issue 15 mins after I posted my last reply.  I wasn't able to find the post again to give an update until now - after Google Groups just emailed me about this post.

In any case, the issue was that com.gemex.core was dependent on com.gemex.arch and com.gemex.arch was dependent on the org.acegisecurity.  Adding the exclude on the com.gemex.arch library wasn't enough.  I had to add the exclude on com.gemex.core too.  Logically, I would think sbt would be smart enough to understand that since com.gemex.core is dependent on com.gemex.arch, and com.gemex.arch is excluding the org.acegisecurity library, it would also leave it out.  Nope.

Also, doing the assemblyExcludedJars in assembly didn't do anything either.  As far as I understand, this should have left out the specified jar no matter what.

Hope this helps someone!
Ben

...
Reply all
Reply to author
Forward
0 new messages