Skip to content

www.rolfje.com

Tag: Java

Ibatis 2.2 Ignores XML encoding

Posted on 2008-07-20 By rolfje No Comments on Ibatis 2.2 Ignores XML encoding

At my company, we’re using Ibatis to do operations on Oracle databases. As most of our software is designed to be international, we keep our XML files in UTF-8 encoding. Recently we discovered that Ibatis had some trouble parsing the XML files when we were using diacritics in them. As it turns out, Ibatis 2.2 actually ignores the “UTF-8” setting in the XML file header altogether.

This was actually reported as an issue at apache’s issue tracker, and fixed in Ibatis release 2.3 and upward. In the meantime, if you can not swich to a new release because of tight deadlines and no time for regression tests, you can set the file.encoding property to UTF-8, because then Ibatis will parse the XML in the correct encoding.

Uncategorized

Tomcat, UTF-8 and the RequestDumperValve

Posted on 2008-07-20 By rolfje No Comments on Tomcat, UTF-8 and the RequestDumperValve

A week ago, we encountered a funny problem where our Tapestry 3.0 application seemed to screw up the encoding of form posts. Every time we tried to post a form with diacritics in the input fields, the data got mangled before reaching the application code.

As it turned out, somebody had turned on the RequestDumperValve in the Tomcat configuration file. The request dumper does not only dump the request, but is also kind enough to mangle the data before handing it over to the servlet for further processing:

Read More “Tomcat, UTF-8 and the RequestDumperValve” »

Software

Hacking Your Way Through Codebases

Posted on 2008-07-02 By rolfje 1 Comment on Hacking Your Way Through Codebases

I found a nice blog post which describes how it is after you leave school and start programming for a real company. You discover that programming is more like 80% reading and 20% coding.

Read the article at the Tired Architect’s blog titled “Hacking Your Way Through Codebases”.

Software

Layer Violations

Posted on 2008-04-13 By rolfje 3 Comments on Layer Violations

Like buildings, software usually a deviation of a standard structure. The architect chooses the structure his design will be based upon. After making design adjustments to the structure to cater the requirements, the architect supervises the builders. Like a building architect, the software architect supervises while walking around in the structure during the build.

Software projects can get so large and complex that the architect can not posibly monitor all the code all the time. This is where te tooling comes in. In this post, I will explain how to use Checkstyle to automatically monitor the basic architectural integrety of the software.

Read More “Layer Violations” »

Software

GForge CVS/SSH Authentication Failures

Posted on 2008-02-26 By rolfje No Comments on GForge CVS/SSH Authentication Failures

Recently we had a problem connecting to our GForge CVS through SSH. We added the public RSA key to the GForge user, but because of wrong configuration on the client we tried to connect a couple of times with the wrong key. After a while the GForge CVS will return the following error:

Received disconnect from <GForge ip>: 2: Too many authentication failures for <username>

To solve this, simple ask a GForge administrator to edit the GForge user, and press the “Save” button without changing anything. You will be able to reconnect immediately after the administrator has pressed “Save”.

Software

Link CVS/SVN commit to GForge Tracker Item

Posted on 2008-02-21 By rolfje 3 Comments on Link CVS/SVN commit to GForge Tracker Item

Today I spent some time figuring out what the exact format of the CVS comment is when I want to link a commit to a GForge tracker item. I’ll try to explain it a bit simpler:

  • We have GForge installed at work. We use GForge to manage a software project for a customer.
  • The customer reports a bug in the Tracker of GForge. This bug gets assigned to me.
  • I read the code, find the problem and fix it. Now I want to commit the fix to the GForge integrated CVS, and have it automatically linked to the Tracker item for future reference.

I spent 30 minutes Googling for an example, and did find a lot of info, but no real usage examples. The info says “Include the tracker item id in the commit comment”. I spent anther 10 to 20 minutes trying to figure out if this meant just the number, the number with the prefix, or brackets, or both. To save more people from searching, you should copy-paste the complete tracker id from the tracker item screen.

Read More “Link CVS/SVN commit to GForge Tracker Item” »

Software

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

request a password at the command-line without display

Posted on 2006-08-18 By rolfje No Comments on request a password at the command-line without display

For those of you trying to request a password from the user at the command-line, without the password being displayed on-screen, Java 6 finaly has the answer, along with better access to the console.

I hope that soon we will never see this hideous construction to do the same again.

Software

Killing oracle sessions, the easy (JDBC) way.

Posted on 2006-02-23 By rolfje 2 Comments on Killing oracle sessions, the easy (JDBC) way.
Does Oracle complain about not being able to drop a table for a currently connected user, but you are sure you disconnected? Do the sessions “hang” in “inactive” state? Just log on as system, and execute the following query: 

SELECT
'ALTER SYSTEM KILL SESSION ''' || sid || ',' || serial# || '''; --',
       s.sid,
       s.serial#,
       s.osuser,
       s.username,
       s.program,
	status
FROM   v$session s
WHERE status = 'INACTIVE';

You will get a list of statements you need to execute (just copy-pase) to kill the inactive sessions. Don’t listen to the guys telling you to do intricate System Administrator stuff on a command prompt, just use any JDBC tool.

EDIT: Single query which also lists the kill command if the “alter system kill session” trick did not work:

SELECT
'ALTER SYSTEM KILL SESSION ''' || s.sid || ',' || s.serial# ||
       '''; -- kill -9 ' || p.spid,
       s.sid,
       s.serial#,
       p.spid,
       s.username,
       s.program,
       s.status
FROM   v$session s, v$process p
WHERE s.paddr = p.addr
  and (s.state='INACTIVE' or s.state='KILLED');

Thanks Bas en Jeroen!

Software

Tapestry/OGNL: Could not find an adaptor for class XYZ

Posted on 2006-02-07 By rolfje No Comments on Tapestry/OGNL: Could not find an adaptor for class XYZ
Getting the “Could not find an adaptor for class Foo” Mesage in Tapestry? You probably forgot to make your class Serializable. A simple description of a possible problematic situation follows: 

Read More “Tapestry/OGNL: Could not find an adaptor for class XYZ” »

Software

Posts navigation

Previous 1 2 3 4 Next
           

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