jacoco:来自Play控制台的封面给出NoClassDefFoundError:无法初始化类com.sun.xml.internal.ws.api.BindingID

时间:2014-01-07 11:33:32

标签: scala sbt jacoco

使用jacoco:cover(2.1.4)从Play控制台运行jacoco4sbt会导致许多测试失败并显示以下消息:

  

[debug]正在运行   的taskdef(com.ourCompany.ourProject.identity.LoginControllerSpec,   org.scalatest.tools.Framework$$anon$1@5b98f69a,false,   [SuiteSelector])       java.lang.NoClassDefFoundError:无法初始化类com.sun.xml.internal.ws.api.BindingID         at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseBinding(RuntimeWSDLParser.java:445)         at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:342)         at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:157)         在com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:120)         at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:257)         在com.sun.xml.internal.ws.client.WSServiceDelegate。(WSServiceDelegate.java:220)         在com.sun.xml.internal.ws.client.WSServiceDelegate。(WSServiceDelegate.java:168)         at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:96)         在javax.xml.ws.Service。(Service.java:77)         在com.bsl.Services。(Services.java:46)         at com.ourCompany.ourProject.identity.UserRepositoryComponent $ OdsUserRepository。(UserRepositoryComponent.scala:92)         在com.ourCompany.ourProject.identity.ComponentRegistry $ class。$ init $(ComponentRegistry.scala:7)         at com.ourCompany.ourProject.identity.LoginControllerSpec $ TestLoginController $。(LoginControllerSpec.scala:20)         在com.ourCompany.ourProject.identity.LoginControllerSpec.TestLoginController $ lzycompute(LoginControllerSpec.scala:20)         在com.ourCompany.ourProject.identity.LoginControllerSpec.TestLoginController(LoginControllerSpec.scala:20)         在com.ourCompany.ourProject.identity.LoginControllerSpec $$ anonfun $ 1.apply $ mcV $ sp(LoginControllerSpec.scala:32)         在com.ourCompany.ourProject.identity.LoginControllerSpec $$ anonfun $ 1.apply(LoginControllerSpec.scala:32)         在com.ourCompany.ourProject.identity.LoginControllerSpec $$ anonfun $ 1.apply(LoginControllerSpec.scala:32)         在org.scalatest.Transformer $$ anonfun $ apply $ 1.apply(Transformer.scala:22)         在org.scalatest.Transformer $$ anonfun $ apply $ 1.apply(Transformer.scala:22)         at org.scalatest.OutcomeOf $ class.outcomeOf(OutcomeOf.scala:85)         at org.scalatest.OutcomeOf $ .outcomeOf(OutcomeOf.scala:104)         在org.scalatest.Transformer.apply(Transformer.scala:22)         在org.scalatest.Transformer.apply(Transformer.scala:20)         at org.scalatest.FlatSpecLike $$ anon $ 1.apply(FlatSpecLike.scala:1636)         at org.scalatest.Suite $ class.withFixture(Suite.scala:1121)         at org.scalatest.FlatSpec.withFixture(FlatSpec.scala:1683)         at org.scalatest.FlatSpecLike $ class.invokeWithFixture $ 1(FlatSpecLike.scala:1633)         在org.scalatest.FlatSpecLike $$ anonfun $ runTest $ 1.apply(FlatSpecLike.scala:1645)         在org.scalatest.FlatSpecLike $$ anonfun $ runTest $ 1.apply(FlatSpecLike.scala:1645)         at org.scalatest.SuperEngine.runTestImpl(Engine.scala:306)         在org.scalatest.FlatSpecLike $ class.runTest(FlatSpecLike.scala:1645)         在org.scalatest.FlatSpec.runTest(FlatSpec.scala:1683)         在org.scalatest.FlatSpecLike $$ anonfun $ runTests $ 1.apply(FlatSpecLike.scala:1703)         在org.scalatest.FlatSpecLike $$ anonfun $ runTests $ 1.apply(FlatSpecLike.scala:1703)         at org.scalatest.SuperEngine $$ anonfun $ traverseSubNodes $ 1 $ 1.apply(Engine.scala:413)         at org.scalatest.SuperEngine $$ anonfun $ traverseSubNodes $ 1 $ 1.apply(Engine.scala:401)         在scala.collection.immutable.List.foreach(List.scala:318)         at org.scalatest.SuperEngine.traverseSubNodes $ 1(Engine.scala:401)         at org.scalatest.SuperEngine.org $ scalatest $ SuperEngine $$ runTestsInBranch(Engine.scala:390)         at org.scalatest.SuperEngine $$ anonfun $ traverseSubNodes $ 1 $ 1.apply(Engine.scala:427)         at org.scalatest.SuperEngine $$ anonfun $ traverseSubNodes $ 1 $ 1.apply(Engine.scala:401)         在scala.collection.immutable.List.foreach(List.scala:318)         at org.scalatest.SuperEngine.traverseSubNodes $ 1(Engine.scala:401)         在org.scalatest.SuperEngine.org $ scalatest $ SuperEngine $$ runTestsInBranch(Engine.scala:396)         at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:483)         在org.scalatest.FlatSpecLike $ class.runTests(FlatSpecLike.scala:1703)         在org.scalatest.FlatSpec.runTests(FlatSpec.scala:1683)         在org.scalatest.Suite $ class.run(Suite.scala:1423)         在org.scalatest.FlatSpec.org $ scalatest $ FlatSpecLike $$ super $ run(FlatSpec.scala:1683)         在org.scalatest.FlatSpecLike $$ anonfun $ run $ 1.apply(FlatSpecLike.scala:1749)         在org.scalatest.FlatSpecLike $$ anonfun $ run $ 1.apply(FlatSpecLike.scala:1749)         在org.scalatest.SuperEngine.runImpl(Engine.scala:545)         在org.scalatest.FlatSpecLike $ class.run(FlatSpecLike.scala:1749)         在com.ourCompany.ourProject.identity.LoginControllerSpec.org $ scalatest $ BeforeAndAfterAll $$ super $ run(LoginControllerSpec.scala:11)         在org.scalatest.BeforeAndAfterAll $ class.liftedTree1 $ 1(BeforeAndAfterAll.scala:257)         at org.scalatest.BeforeAndAfterAll $ class.run(BeforeAndAfterAll.scala:256)         在com.ourCompany.ourProject.identity.LoginControllerSpec.run(LoginControllerSpec.scala:11)         在org.scalatest.tools.Framework.org $ scalatest $ tools $ Framework $$ runSuite(Framework.scala:444)         at org.scalatest.tools.Framework $ ScalaTestTask.execute(Framework.scala:651)         在sbt.TestRunner.runTest $ 1(TestFramework.scala:84)         在sbt.TestRunner.run(TestFramework.scala:94)         at sbt.TestFramework $$ anon $ 2 $$ anonfun $$ init $$ 1 $$ anonfun $ apply $ 8.apply(TestFramework.scala:224)         at sbt.TestFramework $$ anon $ 2 $$ anonfun $$ init $$ 1 $$ anonfun $ apply $ 8.apply(TestFramework.scala:224)         at sbt.TestFramework $ .sbt $ TestFramework $$ withContextLoader(TestFramework.scala:212)         at sbt.TestFramework $$ anon $ 2 $$ anonfun $$ init $$ 1.apply(TestFramework.scala:224)         at sbt.TestFramework $$ anon $ 2 $$ anonfun $$ init $$ 1.apply(TestFramework.scala:224)         在sbt.TestFunction.apply(TestFramework.scala:229)         at sbt.Tests $ .sbt $ Tests $$ processRunnable $ 1(Tests.scala:211)         at sbt.Tests $$ anonfun $ makeSerial $ 1.apply(Tests.scala:217)         at sbt.Tests $$ anonfun $ makeSerial $ 1.apply(Tests.scala:217)         at sbt.std.Transform $$ anon $ 3 $$ anonfun $ apply $ 2.apply(System.scala:45)         at sbt.std.Transform $$ anon $ 3 $$ anonfun $ apply $ 2.apply(System.scala:45)         在sbt.std.Transform $$ anon $ 4.work(System.scala:64)         在sbt.Execute $$ anonfun $ submit $ 1 $$ anonfun $ apply $ 1.apply(Execute.scala:237)         在sbt.Execute $$ anonfun $ submit $ 1 $$ anonfun $ apply $ 1.apply(Execute.scala:237)         在sbt.ErrorHandling $ .wideConvert(ErrorHandling.scala:18)         在sbt.Execute.work(Execute.scala:244)         在sbt.Execute $$ anonfun $ submit $ 1.apply(Execute.scala:237)         在sbt.Execute $$ anonfun $ submit $ 1.apply(Execute.scala:237)         at sbt.ConcurrentRestrictions $$ anon $ 4 $$ anonfun $ 1.apply(ConcurrentRestrictions.scala:160)         在sbt.CompletionService $$ anon $ 2.call(CompletionService.scala:30)         在java.util.concurrent.FutureTask.run(FutureTask.java:262)         at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:471)         在java.util.concurrent.FutureTask.run(FutureTask.java:262)         在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)         at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615)         在java.lang.Thread.run(Thread.java:744)       [error]无法运行测试com.ourCompany.ourProject.identity.LoginControllerSpec:   java.lang.NoClassDefFoundError:无法初始化类   com.sun.xml.internal.ws.api.BindingID

LoginControlerSpec

package com.ourCompany.ourProject.identity

import org.scalatest.{ Matchers, BeforeAndAfterAll, FlatSpec }
import play.api.test.{ FakeApplication, FakeRequest }
import com.ourCompany.ourProject.tags.UnitTest
import play.api.Play
import org.specs2.mock.Mockito
import play.api.test.Helpers._

@UnitTest
class LoginControllerSpec extends FlatSpec with BeforeAndAfterAll with Mockito with Matchers {
  override def beforeAll() {
    Play.start(FakeApplication())
  }

  override def afterAll() {
    Play.stop()
  }

  object TestLoginController extends LoginController with Secured with ComponentRegistryMock

  val Home = "/"
  val username = "XXX@ourCompanyprofessional.com"
  val password = "XXX1"
  val isRememberMe = false
  val expirationPolicy = SessionExpirationPolicy
  val odsUser = OdsUser(Identity(username, ""), Some(username))

  behavior of "LoginController"

  it should "send 200 for renderLoginForm with not authenticated user" in {
    status(TestLoginController.renderLoginForm(FakeRequest())) should be(OK)
  }

  it should "send 303 for renderLoginForm with authenticated user" in {
    val cookie = TestLoginController.authenticatorService.create(odsUser.identity, expirationPolicy) match {
      case Right(a: Authenticator) => a.toCookie
      case _ => fail()
    }
    TestLoginController.userRepository.find(odsUser.identity.userId) returns Some(odsUser)
    val result = TestLoginController.renderLoginForm(FakeRequest().withCookies(cookie))
    redirectLocation(result) should be(Some(Home))
    status(result) should be(SEE_OTHER)
  }

  it should "send 303 for login with valid credentials" in {
    val fakeRequest = FakeRequest().withFormUrlEncodedBody(
      UsernameField -> username, PasswordField -> password, RememberMeField -> isRememberMe.toString)

    TestLoginController.userRepository.login(username, password) returns Right(odsUser)
    val result = TestLoginController.login(fakeRequest)
    cookies(result).get(Authenticator.cookieName) match {
      case Some(c) => assert(c.name == Authenticator.cookieName && !c.value.isEmpty)
      case _ => fail()
    }
    redirectLocation(result) should be(Some(Home))
    status(result) should be(SEE_OTHER)
  }

  it should "send 400 for login with invalid credentials" in {
    val fakeRequest = FakeRequest().withFormUrlEncodedBody(
      UsernameField -> username, PasswordField -> password, RememberMeField -> isRememberMe.toString)

    TestLoginController.userRepository.login(username, password) returns Left(new Error)
    val result = TestLoginController.login(fakeRequest)
    status(result) should be(BAD_REQUEST)
  }

  it should "send 400 for login with invalid form input" in {
    val fakeRequest = FakeRequest().withFormUrlEncodedBody(
      UsernameField -> "", PasswordField -> "", RememberMeField -> "")

    val result = TestLoginController.login(fakeRequest)
    status(result) should be(BAD_REQUEST)
  }

}

build.sbt

gitHeadCommitSha in ThisBuild := Process("git rev-parse HEAD").lines.head

(testOptions in Test) += Tests.Argument(TestFrameworks.ScalaTest, "-h", "target/report")

org.scalastyle.sbt.ScalastylePlugin.Settings

scalacOptions := Seq("-feature")

build.scala

import com.typesafe.sbt.SbtNativePackager._
import com.typesafe.sbt.SbtScalariform._
import play.Project._
import sbt.Keys._
import sbt._
import sbtbuildinfo.Plugin._
import scala._
import scala.util.Try
import scala.Some
import de.johoop.jacoco4sbt.JacocoPlugin._

object BuildSettings {
  val buildOrganization = "com.ourCompany.ourProject"
  val buildVersion      = "0.1-SNAPSHOT"
  val buildScalaVersion = "2.10.2"
  val envConfig = "-Djava.awt.headless=true -Dsbt.log.format=false -Dconfig.file=" + 
      Option(System.getProperty("env.config")).getOrElse("local.application")
  val maxErrors = 20
  // disable running browserstack tests by default. Possible options: true | false [default]
  val browserstack: Boolean = Try(System.getProperty("test.browserstack").toBoolean).getOrElse(false)

  val buildSettings = Defaults.defaultSettings ++ Seq (
    organization := buildOrganization,
    version      := buildVersion,
    scalaVersion := buildScalaVersion,
    scalacOptions ++= Seq("-unchecked", "-optimise", "-deprecation",
      "-Xcheckinit", "-encoding", "utf8", "-feature", "-Yinline-warnings",
      "-Xfatal-warnings"),
    javaOptions ++= Seq("-Xms512M","-Xmx1536M", "-Xss1M", "-XX:ReservedCodeCacheSize=192M",
      "-XX:+CMSClassUnloadingEnabled", "-XX:MaxPermSize=512M"),
    javaOptions += envConfig,
    publishMavenStyle := false
  )
}

object Resolvers {
  val remoteRepoUrl = "ourCompany Nexus Snapshots" at "http://nexus.ci.bln.ourCompany-xxx.com/content/repositories/snapshots/"
  val publishRepoUrl = "ourCompany Nexus Snapshots" at "http://nexus.ci.bln.ourCompany-xxx.com/content/repositories/snapshots/"
  val releaseRepoUrl = "ourCompany Nexus Releases" at "http://nexus.ci.bln.ourCompany-xxx.com/content/repositories/releases/"
}

object Dependencies {
  val ods =  "de.bsmo.ourCompany-professional" % "sprprof-ws" % "2.2.1-SNAPSHOT"
  val scalatest = "org.scalatest" %% "scalatest" % "2.0" % "test->*"  withSources()
  val mockito = "org.mockito" % "mockito-all" % "1.9.5" % "test"
  val ghostDriver = "com.github.detro.ghostdriver" % "phantomjsdriver" % "1.0.3" % "test"
  val cmsClient = "com.ourCompany.cms.ws.clients" % "ourCompany-cms-java-api" % "1.1.6"
  val solrjClient = "org.apache.solr" % "solr-solrj" % "4.3.1" % "compile"
}

object ApplicationBuild extends Build {

  import BuildSettings._
  import Dependencies._
  import Resolvers._

  // Sub-project specific dependencies
  val commonDeps = Seq(
    ods,
    scalatest,
    mockito,
    ghostDriver,
    cmsClient,
    jdbc,
    anorm,
    filters,
    solrjClient,
    cache
  )
  //val bN = settingKey[Int]("current build Number")
  val gitHeadCommitSha = settingKey[String]("current git commit SHA")
  val release = settingKey[Boolean]("Release")

  lazy val ourProject = play.Project(
    "ourProject",
    path = file("."),
    settings = Defaults.defaultSettings ++ buildSettings ++
      Seq(libraryDependencies ++= commonDeps) ++
      Seq(scalariformSettings: _*) ++
      Seq(playScalaSettings: _*) ++
      Seq(publishArtifact := false) ++
      buildInfoSettings ++
      jacoco.settings ++
      Seq(
        sourceGenerators in Compile <+= buildInfo,
        buildInfoKeys ++= Seq[BuildInfoKey](
          resolvers,
          libraryDependencies in Test,
          buildInfoBuildNumber,
          BuildInfoKey.map(name) { case (k, v) => "project" + k.capitalize -> v.capitalize },
          "envConfig" -> envConfig, // computed at project load time
          BuildInfoKey.action("buildTime") {
            System.currentTimeMillis
          } // re-computed each time at compile
        ),
        buildInfoPackage := "com.ourCompany.ourProject"
      ) ++
      Seq(resolvers += remoteRepoUrl) ++
      Seq(resolvers += releaseRepoUrl) ++
      Seq(mappings in Universal ++= Seq(
        file("ops/rpm/start-server.sh") -> "start-server.sh",
        file("ops/rpm/stop-server.sh") -> "stop-server.sh"
      )) ++
      Seq(testOptions in Test += Tests.Argument(if(browserstack) "-n" else "-l", "com.ourCompany.ourProject.tags.BrowserStackTest"))
  ).settings(version <<=  version in ThisBuild)
  .settings(parallelExecution in jacoco.Config := false)
  .settings({
    if(browserstack) {
      javaOptions in Test += "-Dconfig.file=conf/browserstack.application.conf"
    } else {
      javaOptions in Test += "-Dtest.none=true"
    }
  })



  lazy val ourProjectPackaging = Project(
    "packaging",
    file("ourProjectPackaging"), settings=
      Defaults.defaultSettings ++
      Seq(Packaging.settings:_*) ++
      Seq(resolvers += publishRepoUrl) ++
      buildSettings ++
      publishSetting ++
      Seq(publishArtifact := false) ++
      credentialsSetting
  ).settings(Packaging.rpmDistSettings: _*).settings(version <<=  version in Rpm )

  lazy val credentialsSetting = credentials += {
    Seq("NEXUS_USER", "NEXUS_PASSWORD").map(k => Option(System.getenv(k))) match {
      case Seq(Some(user), Some(pass)) =>
        Credentials("Sonatype Nexus Repository Manager",
          "nexus.ci.bln.ourCompany-xxx.com", user, pass)
      case _ =>
        Credentials(Path.userHome / ".ivy2" / ".credentials")
    }
  }

  lazy val publishSetting = publishTo <<= version.apply{
    v =>
      val nexus = "http://nexus.ci.bln.ourCompany-xxx.com/"
      if (v.trim.endsWith("SNAPSHOT"))
        Some("snapshots" at nexus + "content/repositories/snapshots")
      else
        Some("releases" at nexus + "content/repositories/snapshots")
  }
}

命令序列

  1. 启动Play控制台(播放)
  2. 清洁
  3. jacoco:覆盖
  4. 详情

    Play版本:使用Scala 2.10.2构建的2.2.1版本(运行Java 1.7.0_45) 玩游戏:

    [info] This is sbt 0.13.0
    [info] The current project is {file:/home/schl14/work/ProjektName/}ProjektName 0.1-b012d0e6a2c5b4a746490c0d34856af5e7d09bb9
    [info] The current project is built against Scala 2.10.2
    [info] Available Plugins: play.Project, com.typesafe.sbteclipse.plugin.EclipsePlugin, org.sbtidea.SbtIdeaPlugin, com.typesafe.sbt.SbtNativePackager, com.typesafe.sbt.SbtScalariform, sbtbuildinfo.Plugin, org.scalastyle.sbt.ScalastylePlugin, de.johoop.jacoco4sbt.JacocoPlugin
    [info] sbt, sbt plugins, and build definitions are using Scala 2.10.2
    

    问题

    它以前工作过(如许多提交前一样),但我未能确定源代码的哪些更改jacoco:cover失败。这种行为可能是什么原因?

    一旦解决了,我将减少这里发布的不必要的信息量!目前很难确定需要提供什么。

0 个答案:

没有答案