0

我使用 Spark 框架开始了一个小项目,我选择了 ActiveJDBC 作为它的 ORM,它使用 Gradle 来构建所有的东西。

(更新,它使用的是 ActiveJDBC 1.4.12)

这是我的build.gradle文件:

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://repo.javalite.io' }
    }
    dependencies {
        classpath group: 'org.javalite', name: 'activejdbc-gradle-plugin', version: '1.4.13-SNAPSHOT'
    }
}

apply plugin: 'java'
apply plugin: 'org.javalite.activejdbc'

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'org.slf4j',             name: 'slf4j-simple',                       version: '1.7.20'
    compile group: 'com.sparkjava',         name: 'spark-core',                         version: '2.5'
    compile group: 'junit',                 name: 'junit',                              version: '4.12'
    compile group: 'org.postgresql',        name: 'postgresql',                         version: '9.4.1211.jre7'
    compile group: 'org.javalite',          name: 'activejdbc',                         version: '1.4.13-SNAPSHOT'
    compile group: 'org.javalite',          name: 'activejdbc-instrumentation',         version: '1.4.13-SNAPSHOT'
}

task runApp(dependsOn: 'build', type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    main = "my.app.Application"
}

我有一个简单的模型来访问所有很酷的模型方法:

public class User extends Model {}

当我尝试构建项目时,问题就开始了:

     Execution failed for task ':instrumentModels'.
        > org.javalite.instrumentation.InstrumentationException: java.lang.RuntimeException: my.app.model.User class is frozen

            * Exception is:
    ...

            java.lang.RuntimeException: org.javalite.instrumentation.InstrumentationException: java.lang.RuntimeException:my.app.model.User class is frozen
            at org.javalite.instrumentation.Instrumentation.instrument(Instrumentation.java:70)
            at org.javalite.instrumentation.Instrumentation$instrument.call(Unknown Source)
            at org.javalite.instrumentation.gradle.ActiveJDBCInstrumentation.instrument(ActiveJDBCInstrumentation.groovy:30)
            at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
            at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:136)
            at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:129)
            at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:118)
            at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:623)
            at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:606)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
            ... 68 more
    Caused by: org.javalite.instrumentation.InstrumentationException: java.lang.RuntimeException: my.app.model.User class is frozen
            at org.javalite.instrumentation.ModelInstrumentation.instrument(ModelInstrumentation.java:43)
            at org.javalite.instrumentation.Instrumentation.instrument(Instrumentation.java:57)
            ... 78 more
    Caused by: java.lang.RuntimeException: my.app.model.User class is frozen
            at javassist.CtClassType.checkModify(CtClassType.java:288)
            at javassist.CtBehavior.setBody(CtBehavior.java:432)
            at javassist.CtBehavior.setBody(CtBehavior.java:412)
            at org.javalite.instrumentation.ModelInstrumentation.doInstrument(ModelInstrumentation.java:53)
            at org.javalite.instrumentation.ModelInstrumentation.instrument(ModelInstrumentation.java:40)
            ... 79 more
4

1 回答 1

1

这是几天前在此处修复的已知错误:https ://github.com/javalite/activejdbc/issues/537 请在此处获取最新的 1.4.13-SNAPSHOT:http ://repo.javalite.io .

更新:

基本上,此异常是由于检测插件使用的 Javassist 拒绝检测该类,因为它已经在当前 VM 中检测。对于无关紧要的非 Gradle 项目,因为进程在检测后退出,但 Gradle 进程仍然存在。问题已解决,应该可以正常工作。

于 2016-10-02T21:05:43.800 回答