Activejdbc Null pointer Exception in Model Finder and Model.getMetaModel

336 views
Skip to first unread message

ActiveJdbc User (Nitin)

unread,
Mar 26, 2012, 6:32:52 PM3/26/12
to ActiveJDBC Group
Folks

I am using Intellij and maven for running active jdbc and it works
like a charm . I am using a main class to kick off some entity
creation and teardown which works great from IntelliJ (after doing
mvn process-classes) .

However when i try to package all dependencies and run the same
command through command line (java -cp <name of jar> mainclass ) i
land up with this exception sometimes and some other times it just
works

Exception in thread "main" org.javalite.activejdbc.InitException:
java.lang.NullPointerException
at org.javalite.activejdbc.Registry.init(Registry.java:162)
at org.javalite.activejdbc.Model.getMetaModel(Model.java:59)
at org.javalite.activejdbc.Model.deleteAll(Model.java:549)
........
at com.something.BootStrap.main(BootStrap.java:25)
Caused by: java.lang.NullPointerException
at org.javalite.activejdbc.ModelFinder.findModels(ModelFinder.java:
38)
at org.javalite.activejdbc.Registry.init(Registry.java:136)

Can anyone shed light on what could be going on?

Thanks
Nitin

ActiveJdbc User (Nitin)

unread,
Mar 26, 2012, 7:28:23 PM3/26/12
to ActiveJDBC Group
An additional point to note is that when i do maven package (after or
before mvn process-classes) the jar that i land up with has an empty
active jdbc_models.properties file

I manually copied over the the active jdbc_model.properties file (the
completed instrumented one) and ran it from command line and that
seems to work fine

I noticed that 80% of the time the properties file that is copied into
the jar is empty and the rest of the 20% it works fine .

What would be a recommended way to do this reliably ?

Nitin


On Mar 26, 3:32 pm, "ActiveJdbc User (Nitin)" <ksha...@groupon.com>
wrote:

ipolevoy

unread,
Mar 26, 2012, 8:11:14 PM3/26/12
to activejd...@googlegroups.com
Hm, I was about to say that this might be a problem, can you publish the instrumentation plugin configuration in the POM?

thanks
Igor

K.Nitin Sharma

unread,
Mar 26, 2012, 8:13:15 PM3/26/12
to activejd...@googlegroups.com
Igor

I am using the exact same version as mentioned in the wiki
   <plugin> 
                <groupId>org.javalite</groupId>
                <artifactId>activejdbc-instrumentation</artifactId>
                <version>1.2-SNAPSHOT</version>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>instrument</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Thanks
Nitin
--
Nitin 
SDET - Relevance and Personalization
Groupon - Palo Alto

ipolevoy

unread,
Mar 26, 2012, 8:14:37 PM3/26/12
to activejd...@googlegroups.com
Oh, wait.. so the instrumentation plugin does generate the activejdbc_models.properties file correctly, but for some reason you it is not packaged?
For me, the instrumentation plugin works flawlessly, always creating this file.
Maybe there is a problem in how you assemble the app? Do you use an assebmly plugin?

thanks
Igor

K.Nitin Sharma

unread,
Mar 26, 2012, 8:17:33 PM3/26/12
to activejd...@googlegroups.com
Hi igor

 Yes i use a maven-assembly-plugin for this . That may be true (since instrumentation works fine if i run from Intellij)

Also on a side note : I am getting the following error when i try to get the latest snapshot of active jdbc

Failed to execute goal org.javalite:activejdbc-instrumentation:1.2-SNAPSHOT:instrument (default) on project gandalf: Failed to add output directory to classpath: org.javalite.instrumentation.InstrumentationException: java.lang.RuntimeException: java.util.zip.ZipException: invalid LOC header (bad signature) 

May be your recent fix caused this ?
Nitin

K.Nitin Sharma

unread,
Mar 26, 2012, 10:36:56 PM3/26/12
to activejd...@googlegroups.com
Closure for this thread

 It seems we have a sort of execution dependency in maven . The order in which targets was executed was the problem. Guess process-classes was done after package 

I have changed activejdbc to execute in the package phase as opposed to defining it as a separate phase and  then assembling after that

That seems to have fixed it 

Also : A work around for failing latest snapshot . Just comment out the updateAlways flag in the plugin repositories . 

Thanks
Nitin 

ipolevoy

unread,
Mar 27, 2012, 12:19:13 AM3/27/12
to activejd...@googlegroups.com
good to know, however, this is rather strange that process-classes executes after package, this should not happen.
Glad it worked out in the end.

thanks
Reply all
Reply to author
Forward
0 new messages