excluding transitive dependencies

505 views
Skip to first unread message

Andrew Mullins

unread,
Jan 4, 2012, 10:47:24 PM1/4/12
to simple-b...@googlegroups.com
I can't seem to get this to work...

this doesn't seem to do anything
"commons-validator" % "commons-validator" % "1.3.1" exclude("org.apache.commons", "commons-logging")

this works but excludes all dependencies (I only need to exclude commons-logging)
"commons-validator" % "commons-validator" % "1.3.1" intransitive()

What am I missing?

Arjan Blokzijl

unread,
Jan 5, 2012, 1:22:13 AM1/5/12
to simple-b...@googlegroups.com
I think the groupId is not "org.apache.commons" but just "commons-logging" see for example http://search.maven.org/#search%7Cga%7C1%7Ccommons-logging

Arjan

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/Wdn1vazCQ4EJ.
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

Andrew Mullins

unread,
Jan 5, 2012, 2:26:53 PM1/5/12
to simple-b...@googlegroups.com
Well, that didn't work, either.
I know it's not being brought in by another dependency because I can change the commons-validator dependency to intransitive and the commons-logging jar isn't added.

Looking at the dependencies of commons-validator, I see that some of its dependencies also depend on commons-logging (I wonder if this makes a difference).

My current commons-validator dependency looks like:
"commons-validator" % "commons-validator" % "1.3.1" exclude("commons-logging", "commons-logging")

Andrew Mullins

unread,
Jan 5, 2012, 4:07:57 PM1/5/12
to simple-b...@googlegroups.com
It seems that the jar is being excluded when I package the web app (no commons-logging in WEB-INF/lib). However, when I run my app via xsbt-web-plugin with container:start, commons-logging-1.0.4.jar is being loaded from somewhere...

The whole reason for my posting this is that I am receiving a NoClassDefFoundError at runtime:
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:159)
org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:178)
com.rackspacecloud.client.cloudfiles.FilesClient$1.<init>(FilesClient.java:174)
com.rackspacecloud.client.cloudfiles.FilesClient.<init>(FilesClient.java:174)
com.rackspacecloud.client.cloudfiles.FilesClient.<init>(FilesClient.java:216)
...
java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
java.net.URLClassLoader$1.run(URLClassLoader.java:202)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:190)
sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
java.lang.ClassLoader.loadClass(ClassLoader.java:306)
java.lang.ClassLoader.loadClass(ClassLoader.java:247)
org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:159)
org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:178)
com.rackspacecloud.client.cloudfiles.FilesClient$1.<init>(FilesClient.java:174)
com.rackspacecloud.client.cloudfiles.FilesClient.<init>(FilesClient.java:174)
com.rackspacecloud.client.cloudfiles.FilesClient.<init>(FilesClient.java:216)

My Project's Dependencies:
object Dependencies {

  val liftVersion = "2.4-M5"
  val jettyVersion = "7.4.5.v20110725"

  val lift = Seq(
    "net.liftweb" %% "lift-webkit" % liftVersion % "compile->default" withSources(),
    "net.liftweb" %% "lift-mapper" % liftVersion % "compile->default" withSources(),
    "net.liftweb" %% "lift-widgets" % liftVersion % "compile->default" withSources()
  )

  val jetty = "org.eclipse.jetty" % "jetty-webapp" % jettyVersion % "container"
  val servlet = "javax.servlet" % "servlet-api" % "2.5" % "provided"

  val scalate = "org.fusesource.scalate" % "scalate-core" % "1.5.3" % "compile"

  val slf4j = "org.slf4j" % "slf4j-log4j12" % "1.6.4" % "compile"
  val jcl_slf4j = "org.slf4j" % "jcl-over-slf4j" % "1.6.4" % "compile"

  val commons_validator = "commons-validator" % "commons-validator" % "1.3.1" % "compile" exclude("commons-logging", "commons-logging")

  val httpclient = "org.apache.httpcomponents" % "httpclient" % "4.1.2" % "compile" intransitive()
  val httpcore = "org.apache.httpcomponents" % "httpcore" % "4.1.2" % "compile" intransitive()

  val dispatch = Seq(
    "net.databinder" %% "dispatch-http" % "0.8.7" % "compile" withSources() withJavadoc() intransitive(),
    "net.databinder" %% "dispatch-core" % "0.8.7" % "compile" withSources() withJavadoc() intransitive(),
    "net.databinder" %% "dispatch-futures" % "0.8.7" % "compile" withSources() withJavadoc() intransitive()
  )

  val quartz = "org.quartz-scheduler" % "quartz" % "2.1.2" % "compile" withSources()

  val junit = "junit" % "junit" % "4.5" % "test->default"
  val specs = "org.scala-tools.testing" %% "specs" % "1.6.9" % "test->default"

  val postgres = "postgresql" % "postgresql" % "8.4-702.jdbc4" % "runtime->default"


  val webapp = Seq(
    jetty, servlet,
    scalate,
    slf4j, jclSlf4j,
    commons_validator,
    httpcore, httpclient,
    quartz,
    junit, specs,
    postgres
  ) ++ lift ++ dispatch

}

Can anyone give me some insight on the NoClassDefFoundError for LogFactory?

Thanks,
Andy

Andrew Mullins

unread,
Oct 23, 2012, 12:10:23 PM10/23/12
to simple-b...@googlegroups.com
I changed my dependencies a bit - now using logback for logging.
I don't think I had to change anything outside of the project

object Dependencies {
  ...
  val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.1"
  val slf4jJcl = "org.slf4j" % "jcl-over-slf4j" % "1.7.1"
  val slf4jlog4j = "org.slf4j" % "log4j-over-slf4j" % "1.7.1"
  val logback = "ch.qos.logback" % "logback-classic" % "1.0.7"
  val commonsValidator = "commons-validator" % "commons-validator" % "1.3.1" withSources()
  ...
  val globalExclusions = <dependencies>
    <exclude org="commons-logging" artifact="commons-logging" />
  </dependencies>
}


object BuildSettings {
  ...
  val buildSettings: Seq[Project.Setting[_]] = {
    Defaults.defaultSettings ++
    ... // webSettings, resolvers, etc
    (ivyXML := Dependencies.globalExclusions) ++
    ... // project name, organization, version
  }
}



On Tuesday, October 23, 2012 5:20:58 AM UTC-5, Andreas Hartmann wrote:
Hi Andrew,

I'm facing the same issue. Have you been able to resolve it?
TIA for any feedback!

Best regards,
Andreas

Johannes Rudolph

unread,
Oct 24, 2012, 5:58:51 AM10/24/12
to simple-b...@googlegroups.com
Which sbt version do you use? There were some changes 0.12.0 wrt exclusion.
Reply all
Reply to author
Forward
0 new messages