0

I started a little project using Spark Framework and I chose ActiveJDBC as its ORM, It's using Gradle to build all whole thing.

(UPDATED, IT WAS USING ActiveJDBC 1.4.12)

Here is my build.gradle file:

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"
}

I've a simple model to access all cool Model's methods:

public class User extends Model {}

The problem starts when I try build the project:

     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
Aleff
  • 257
  • 1
  • 3
  • 13

1 Answers1

1

this is a known bug which was fixed a few days ago here: https://github.com/javalite/activejdbc/issues/537 Please, get the latest 1.4.13-SNAPSHOT here: http://repo.javalite.io.

Update:

Basically, this exception was due to the fact that the Javassist being used by the instrumentation plugin refused to instrument the class because it was already instrumented in the current VM. For non-Gradle projects that does not matter, as the process exits after instrumentation, but Gradle process stays. The issue was fixed, and should be working.

ipolevoy
  • 5,432
  • 2
  • 31
  • 46
  • I can't find that latest version on maven for activejdbc core... only activejdbc-gradle-plugin is ok. How can I add that repo to my gradle.build? – Aleff Oct 08 '16 at 23:31
  • Strange! It is possible that this fix did not make it into the release due to how dependencies are defined in the Gradle plugin. Please use the 1.4.13-SNAPSHOT version from here: http://repo.javalite.io/. Please, ensure that ActiveJDBC libgrary, the instrumentation plugin and Gradle plugin are all on teh same version. – ipolevoy Oct 09 '16 at 20:13
  • I updated the gradle's build file, but I'm still got that entity frozen. Check it out above, please. – Aleff Oct 10 '16 at 17:17
  • Have you tried to use the latest snapshot for instrumentation plugin, Gradle plugin and ActiveJDBC itself? – ipolevoy Oct 12 '16 at 04:59
  • Can you create a simple project that replicates this bug and share here? Also, you might want to open a new issue: https://github.com/javalite/activejdbc/issues – ipolevoy Oct 12 '16 at 16:22