The Artima Developer Community
Sponsored Link

Java Buzz Forum
Happy NullPointer digging with Kodo 3.4 and Horizontal Mappings

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Marc Logemann

Posts: 594
Nickname: loge
Registered: Sep, 2002

Marc Logemann is founder of www.logentis.de a Java consultancy
Happy NullPointer digging with Kodo 3.4 and Horizontal Mappings Posted: Jul 19, 2007 12:21 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Marc Logemann.
Original Post: Happy NullPointer digging with Kodo 3.4 and Horizontal Mappings
Feed Title: Logemann Blog
Feed URL: http://feeds.feedburner.com/LogemannBlog
Feed Description: Marc Logemann's thoughts on java and other stuff
Latest Java Buzz Posts
Latest Java Buzz Posts by Marc Logemann
Latest Posts From Logemann Blog

Advertisement

Boy, its really time to go open source with the persistence tier. I am tired of the german BEA Kodo support and i am tired to have this guilty feeling when reverse engineering closed source code. Perhaps even writing about this could bring me into jail. But anyway…. to the topic.

It seems that i am the only person on the planet using Horizontal mapping with Kodo 3.x who has made the big mistake to make a typo in the JDO mapping file. With this mapping you can declare the parent attribute mappings in the child JDO file by using <extension vendor-name=”kodo” key=”jdbc-field-mappings”>.

One of my parent attribute mapping definitions had a typo in a way that used the wrong name for an attribute like this:

Code (xml)
  1.  
  2. <extension vendor-name="kodo" key="BasicClientMetaData.elephont">
  3.   <extension vendor-name="kodo" key="jdbc-field-map" value="pc">
  4.     <extension vendor-name="kodo" key="column" value="elephant"></extension>
  5.   </extension>
  6. </extension>
  7.  

So i typed elephont even though the attribute in the BasicClientMetaData object is named “elephant”. Normally Kodo reports with a error message that signals that the name doesnt match with the objects attribute but not so with this specific mapping. There you get :

kodo.util.UserException: java.lang.NullPointerException at kodo.query.AbstractQuery.executeWithArray(AbstractQuery.java:844)

The experienced programmer now thinks that this cant be too hard to solve, you only have to look at executeWithArray() in the AbstractQuery class (which basically means you have to decompile only one class), but then you encounter something which could have been solved better:

Code (java)
  1.  
  2. catch(Exception e) {
  3.    throw new UserException(e.toString(), e)
  4. }

Of course AbstractQuery is only the entry point for a Kodo query and the Nullpointer gets wrapped so that you cant see the exact place of the error in the console. Of course you can debug the catch block and see what implicit “stacktrace” list object “e” has. But this makes it unecessarily complex.

Unfortunately i ended up decompiling some more classes because i have not looked at “e” in the beginning and followed the method calls from AbstractQuery to the lower layers. The way of coding is really questionable because i have a complete different problem in the support queue (for a long time now of course) which looks like the same error. Its the same NullPointer at the same code spot. But this is of course nothing which surprises me because the real problem is not readable in the console stacktrace as mentioned before.

What really makes me mad is that i have to go through this (meaning doing something which feels illegal). I really tried hard to provide a testcase for the error i still have with horizontal mappings and custom field mappings and nobody at BEA (germany) seems to have a clue. I mean, its not that hard to debug if you have the code. I would have found it in a few minutes with the code at hand. Just to remember, i had to decompile the relevant classes which were not obvious for me in the first place and had to put the new Kodo sources for the mentioned classes before the library JAR classloader so that it takes my kodo classes and not the original ones residing in the kodo-runtime.jar (because you cant debug with a decompiled source and the original class because of changed line numbers).

All in all this reminds me how cool open source is. I mean, i am quite good in reading code (when i am not doing work for direct customer projects, i am java consultant, so i am constantly reading code from other developers in various projects), which puts me in a position where its normally not a big deal to find bugs or to see what i am doing wrong with the API.

If i have some time this year, i will finally start migrating to OpenJPA. The last two hours would have been better spent in migrating to JPA instead of decompiling old Kodo classes but as usual, the problem had to be solved, no matter how. I think i will keep the decompiled classes, perhaps i can also solve the issue which is still in support-line-mode and the good thing is, if my business completely fails, i always could ask BEA to hire me for Kodo second level support :)

Read: Happy NullPointer digging with Kodo 3.4 and Horizontal Mappings

Topic: 9 Blog Redesign Ideas Previous Topic   Next Topic Topic: OpenLogic tool runs an inventory on open-source apps

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use