Skip to content

www.rolfje.com

Ibatis Nullpointer calling stored procedure

Posted on 2006-11-07 By rolfje 1 Comment on Ibatis Nullpointer calling stored procedure
Today, a collegue of mine had a really strange nullpointer problem trying to call a stored procedure in an Oracle 10 database using iBATIS Java 2.2.0. What she had was a normal JavaBean, like so: 

package com.rolfje.foo
public class BarBean {
    private String barName;
    private Long barId;

    ... setters/getters here ...
}

A straightforward parametermap:

<parameterMap class="com.rolfje.foo.BarBean"
      id="barbeanMap">
   <parameter property="barName" />
   <parameter property="barId" />
</parameterMap>

and a straightforward procedure mapping:

<procedure id="insertBar" parameterMap="barbeanMap">
   {	call store_bar (
      ?,?)
   }
</procedure>

When trying to call the stored procedure, she got the following stacktrace:

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation;
uncategorized SQLException for SQL [];
SQL state [null]; error code [0];
--- The error occurred in com/rolfje/foo/sqlmaps/ParameterMap.xml.
--- The error occurred while applying a parameter map.
--- Check the barBeanMap.
--- Check the statement (update procedure failed).
--- Cause: java.lang.NullPointerException; nested exception is

com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/rolfje/foo/sqlmaps/ParameterMap.xml.
--- The error occurred while applying a parameter map.
--- Check the barBeanMap.
--- Check the statement (update procedure failed).
--- Cause: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/rolfje/foo/sqlmaps/ParameterMap.xml.
--- The error occurred while applying a parameter map.
--- Check the barBeanMap.
--- Check the statement (update procedure failed).
--- Cause: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
   at ...executeQueryWithCallback(GeneralStatement.java:188)
   at ...executeQueryForObject(GeneralStatement.java:104)
   at ...queryForObject(SqlMapExecutorDelegate.java:565)
...

After hours of staring at the problem, and comparing code with similar constructions from other projects, we decided to switch to the Oracle 9i thin driver to see if that would solve the problem. It didn’t, but there was an interesting development: The Oracle 9i driver actually gave us a decent error about not being able to parse the SQL statement. Which brings us to…

The solution:
We removed all layout from the procedure mapping, which resulted in:

<procedure id="insertBar" parameterMap="barbeanMap">
   {call store_bar (?,?)}
</procedure>

This solved the problem. Then we switched back to the Oracle 10i thin driver, and the problem was still gone. The problem lies in the TAB between the left curly bracket and the word “call”. Oracle can not handle this.To investigate this problem, we then also tried to insert <![CDATA[ ]]> around the procedure call, but as soon as there is a TAB between the { and the word “call” iBATIS will throw a NullPointer. The strange thing is that you can have spaces, newlines and tabs *anywhere* in the procedure mapping, as long as there is no TAB between the left curly and the word “call”.

Software Tags:ibatis, Java, programming

Post navigation

Previous Post: It ain’t what you do…
Next Post: Creating an Ubuntu Postgres server

Comment (1) on “Ibatis Nullpointer calling stored procedure”

  1. Disgruntled Developer says:
    2015-08-21 at 17:43

    THANK YOU. I’ve been staring at this problem for over a day. I doubt it would have occurred to me that a freaking tab character would cause the Oracle driver to throw an NPE.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

           

Recent Comments

  • rolfje on Methode Buijs uitgelegd
  • LinkedIn is at Peak Enshittifaction – Will Chatham's Blog on Linked-In not really Opt-in?
  • Hans j on 1N4148 diode as RF switch
  • Roaming Rhonda on DLNA on OSX, done right
  • Frans on How to fix a Krups XN2001 Nespresso machine

Tags

Anonimatron Apple backup design DIY DRM eclipse environment Fun gmail google hacking hamradio Hardware helicopter iphone ipod iTunes Java Keynote maven modelling motorcycle music news opinion oracle osx photo photography programming repair review security Software Steve Jobs T-Mobile technology Time Machine Ubuntu usability Utilities vacation windows Workshop

Categories

  • Apple (105)
  • Divorce (1)
  • Electronics (3)
  • Fun (57)
  • Games (7)
  • Hardware (72)
  • Microsoft (18)
  • Racing (14)
  • Software (134)
  • Uncategorized (65)
  • Workshop (20)

Archives

Copyright © 2025 www.rolfje.com.

Powered by PressBook WordPress theme