Grailsアプリケーション(v 2.4.3)で、従来のOracle 10g DBを使用していて、以下のエラーが発生しています。サービスの統合テストを実行しようとしているとき。私はGoogleとここで検索しましたが、サービスの統合テスト中にこのエラーを受け取った他の人は見つかりませんでした。ドメインクラスの私の単体テストは問題なく実行されますが、私は統合テストでこのエラーが発生します。Grails 2.4.3統合テストエラーjava.lang.NoClassDefFoundError:org/springframework/mock/web/MockAsyncContext
アプリケーションは、サービスレイヤですべての休止状態の呼び出しを持つように構成されており、ドメインクラスにそれらを置くことはできません。
Running 1 integration test...
| Running 1 integration test... 1 of 1
| Failure: test getAllDeliveryTypes(catalog.CatalogServiceSpec)
| java.lang.NoClassDefFoundError: org/springframework/mock/web/MockAsyncContext
at java.lang.Class.privateGetDeclaredMethods(Class.java:2693)
at java.lang.Class.getDeclaredMethods(Class.java:1967)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at grails.test.spock.IntegrationSpec.initRequestEnv(IntegrationSpec.groovy:96)
at grails.test.spock.IntegrationSpec.setup(IntegrationSpec.groovy:62)
Caused by: java.lang.ClassNotFoundException: org.springframework.mock.web.MockAsyncContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
... 6 more
| Completed 1 integration test, 1 failed in 0m 0s
統合テストクラス
package catalog
import grails.test.spock.IntegrationSpec
import spock.lang.*
/**
*
*/
class CatalogServiceSpec extends IntegrationSpec {
static DeliveryType deliveryType
static CatalogService catalogService = new CatalogService()
def setup() {
deliveryType = new DeliveryType()
deliveryType.id = 1
deliveryType.createdById = 101
deliveryType.createdOn = new Date()
deliveryType.modifiedById = 101
deliveryType.modifiedOn = new Date()
deliveryType.code = '01'
deliveryType.name = 'In-Person Classroom'
}
@Unroll("test getAllDeliveryTypes")
def "test getAllDeliveryTypes"() {
when:
def results = catalogService.getAllDeliveryTypes()
then:
results.size() == 1
}
}
Serviceクラス
package catalog
import grails.transaction.Transactional
@Transactional
class CatalogService {
List<DeliveryType> getAllDeliveryTypes() {
List<DeliveryType> deliveryTypes = DeliveryType.list(sort: "id", order: "asc")
return deliveryTypes
}
}
ドメイン
package catalog
class DeliveryType {
static constraints = {
id range: 1..2500000000
createdById range: 1..2500000000
modifiedById range: 1..2500000000
code maxSize: 6, unique: true
name maxSize: 30
}
static mapping = {
version false
table name: 'delivery_type', schema: 'catalog'
id generator:'assigned'
}
Long id
Long createdById
Date createdOn
Long modifiedById
Date modifiedOn
String code
String name
}
設定ファイル
dependencies {
test "org.grails:grails-datastore-test-support:1.0-grails-2.4"
runtime 'org.springframework:spring-test:3.1.0.RELEASE'
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.7'
compile ":asset-pipeline:1.9.6"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.5.5" // or ":hibernate:3.6.10.17"
runtime ":database-migration:1.4.0"
}
ありがとうございました。
ブレット