Search code examples
javaintellij-ideaactivejdbc

Debugging ActiveJDBC with IntelliJ IDEA


I am new to ActiveJDBC. I am trying to debug the sample project.

The code I want to debug is:

public static void main(String[] args) {

    Base.open();

    Person director  = new Person("Stephen Spielberg");
    director.saveIt();

    //[break point here] 
    director.add(new Movie("Saving private Ryan", 1998));
    director.add(new Movie("Jaws", 1982));
    director.getAll(Movie.class).forEach(System.out::println);

    Base.close();
}

The code compiles correctly and the instrumentation is properly executed (I believe) (have a look here).

The debugger is launched and paused at the defined break-point.

I am trying to evaluate the expression "Person.count()" and I am expecting the result to be 1.

But I have the following error in the 'Evaluate expression' window:

Method threw 'org.javalite.activejdbc.InitException' exception.

failed to determine Model class name, are you sure models have been instrumented?

Have a look: https://unsee.cc/nipareto/


Solution

  • It is possible that you recompiled models after instrumentation unintentionally. If you instrument, then make any change to a model, and then try to run your code, and IDE will detect the change and recompile your model, thus blowing away instrumentation.

    Ensure you instrument before you run your code.

    Additionally, the link you provided: https://github.com/javalite/activeweb-simple is not corresponding to code. I think you are using this one: https://github.com/javalite/simple-example. If so, try running on command line according to README.

    Debugging models in ActiveJDBC in IDEA is what I do daily:) Also, I recommend you watch the video on this page: http://javalite.io/instrumentation because it walk you step by step using IDEA.

    UPDATE April 10 2017:

    I recorded this video to show you how to instrument and debug an ActiveJDBC project: https://www.youtube.com/watch?v=2OeufCH-S4M