ActiveJDBC Instrumentation: Unable to instrument the model classes which are in Jar

1.4k views Asked by At

I am using activejdbc 1.4.9. I created one jar (using maven) which has two ActiveJDBC Model Classes. I added the jar to the application. Application has three more model classes. When I compile and try to run the application (gradle based), activejdbc is instrumenting only 3 classes which are in application but not instrumenting the classes which are in jar. When I try to write the data into the two models which are in jar, It is throwing exception as

org.javalite.activejdbc.DBException: Failed to retrieve metadata from DB. Are you sure table exists in DB ?

Now I have certain doubts. Please help me to resolve and understand few things.

  1. How instrumentation happens ?
  2. When we create a jar, will it include instrumented classes ?
  3. Why it is throwing this error ?
1

There are 1 answers

6
ipolevoy On BEST ANSWER

It is throwing this error in case classes have not been instrumented. This means that before placing your model classes into a jar file, you need to instrument them. Does not matter which build method you use though. This http://javalite.io/instrumentation explains what is instrumentation and how to do it. Instrumentation does not create jars, it merely adds some byte code into your classes. In all scenarios you need:

  1. Write code :)
  2. Compile
  3. Instrument

after this, you can do any of the following:

  • run app using class files in the file system
  • package class files into jar file and use that on your classpath
  • package jar file into a larger app (WAR, EAR, RAR, etc.) and deploy your app

making sense?