Dec 04 2009

SQL*Loader-522: lfiopn failed for file (loader.log)

Published by under Oracle

I used the Oracle SQL Loader to push some data into a table and got the following error: SQL*Loader-522: lfiopn failed for file (loader.log)
This somewhat cryptic error message turned out to be that Oracle SQL Loader didn’t have write permissions in the work directory i.e. in the directory where I executed the sqlldr command. Once I fixed the directory permission everything worked just fine.

8 responses so far

Oct 08 2009

Java primitive data type sizes for byte, short, int, long, float, double and char

Published by under Java

A handy list for Java data types and sizes

Integer Data Types

Data Type Size Digits Min Max
byte 8-bit signed 3 -128 127
short 16-bit signed 5 -32,768 32,767
int 32-bit signed 10 -2,147,483,648 2,147,483,647
long 64-bit signed 19 -9,223,372,036,854,775,808 9,223,372,036,854,775,807

Floating Point Data Types

Data Type Size
float single-precision 32-bit IEEE 754 floating point
double double-precision 64-bit IEEE 754 floating point

Boolean Data Types

Data Type Values
boolean true or false

Character Data Types

Data Type Min Max
char u0000 or 0 uffff or 65,535

Default Values

Data Type Default Value
byte 0
short 0
int 0
long 0L
float 0.0f
double 0.0d
char ‘u0000’
boolean false
Any Object(s) null


No responses yet

Oct 07 2009

How to find project dependencies in a Maven project

Published by under Java,Maven

It’s very useful to be able to see what is included in your class path especially when you’re trying to track down a troublesome dependency. Recently I had an issue with a JDOM dependency; however I had not defined a JDOM dependency in my pom.xml file and I couldn’t quite figure out why this dependency existed. This is where Maven’s excellent dependency plugin comes to the rescue.

In a project you may have dependencies on libraries like Log4J or Freemarker. These libraries in their turn may have dependencies on other libraries, this is also known as transitive dependencies.

Using the following Maven command we’ll be able to see a list of these dependencies:

mvn dependency:resolve

For a nice tree view of the same information use:

mvn dependency:tree

If you want to see a full dependency trail that also show you artifacts that were rejected due to conflicts or other reasons then run maven with the debug flag enabled:

mvn install -X

For more information about the Maven dependency plugin go here:

One response so far

Sep 16 2009

How to control or throttle SCP file transfer speed

Published by under Unix/Linux

I wanted to control how fast SCP copy data between two Linux servers. On a Linux system this can easily be achieved using the “SCP -l” switch. In my case I had to make sure to not exceed 0.5 Mbit/s

Since the “-l” parameter uses Kbit/s the correct value in my case is 500

scp -l 500 big-file.tar

3 responses so far

Sep 09 2009

How I fixed the problem and got my Logitech mouse working OS X 10.6 Snow Leopard

Published by under OS X / Apple OS

Logitech has yet to release updated keyboard and mice drivers for OS X 10.6 / Snow Leopard. I’m quite fond of my Logitech MX 510 mouse and wanted this problem fixed as soon as possible.

I used the instruction from the link below which tells you to download the “Logitech Control Center”, locate the “Logitech Control Center.mkpg” file inside the “Logitech Control Center” and execute it. This will by-pass the OS X version check inside the Logitech installer.

I however wanted to use the installer for my mouse MX 510 which uses the “LCC Installer”. I followed the same instructions, located the “Logitech Control Center.mkpg” and executed it which successfully got the driver installed.

I found the solution to this problem here:

No responses yet

Sep 06 2009

Want to use Spring 3.0 milestone release from Maven?

Published by under Java,Maven,Spring

I wanted to add the Spring 3.0 M4 milestone early access release to a Maven project to test out some of the new features. However Spring  milestone releases are not readily available in the standard public Maven repositories, so what do you do?

For the full explanation check out the link to “Spring/Maven Repositories” link in the bottom. For a quick 1-2-3 step solution add this to the <repositories> section in your Maven pom.xml file so that Maven can find Spring’s early access milestone releases:

  <name>Spring Portfolio Milestone Repository</name>
You can then add Spring 3.0 M4 as a dependency in your pom.xml file:
If you’re looking for other Spring artifacts you can browse them using this Spring Maven artifact URL

This Spring article has additional details on this topic e.g  how to access snapshot releases:

Spring/Maven Repositories

No responses yet

Sep 05 2009

How to automatically provide an answer to Unix commands

Published by under Unix/Linux

How do you automatically provide an answer to a Unix command for example

cp: overwrite `destination/./b.txt'?

Many Unix/Linux commands that operate on files may stop and ask for confirmation for each file before completing an action. Of course for many Unix/Linux commands there are parameters that allows you to specify the desired behavior, but there are other commands that doesn’t have that capability. Advanced Unix users just look up the “yes” command on how to solve this. Here’s a contrived example where a directory called “destination” contains two files “a.txt” and “b.txt”. We will now copy two files “b.txt” and “c.txt” from a directory called “source”

|-- destination
|   |-- a.txt
|   `-- b.txt
`-- source
 |-- b.txt
 `-- c.txt

We’ll copy the files using the “cp” command

cp source/*.txt destination/.

When we do this we’ll get the following response on the command line where the OS is asking us what it want us to do since one file being copied already exist in the destination directory i.e. “b.txt”

cp: overwrite `destination/./b.txt'?

Unfortunately on Linux the cp command doesn’t have an option to automatically answer this question with a ‘y’ or ‘n’ answer. There’s more than one solution to this problem depending on what you want to do, and one solution is to use the Unix “yes” command. This command will output a string repeatedly until killed. If we want to avoid overwriting any of the files in the destination directory we could use the “yes” command to answer all questions with a no “n”. Below you can see how the “yes” command is used to automatically provide the answer “n” to the “cp” command. Use “man yes” for more information about the “yes” command.

yes n | cp source/*.txt destination/.

This successfully copies all files with the exception of the “b.txt” file which is what we wanted. The “yes” command automatically provided the answer “n” to the “cp” command question whether or not we wanted to overwrite the destination file.

In the case that you mess up when you use the “yes” command for example by typing this:

yes bingo

The “yes” command will output the word “bingo” repeatedly to the screen. You can stop it by typing Control-C or in a different shell type “pgrep yes” which will display the “yes” commands PID (process ID) which you can use to kill the “yes” command by typing “kill <PID>”

pgrep yes

In my case it returned 24940 so I killed it with:

kill 24940

One response so far

Aug 31 2009

JUnit 4 error: reference to assertEquals is ambiguous

Published by under Java,JUnit,Testing

This is a somewhat confusing compilation failure that sometimes happen when you write unit tests using JUnit 4. This is an example code snippet that produces this error (result.getValue() returns an Integer object):

assertEquals(12345, result.getValue());

And when you try to compile your project it produces a compilation error like this:

/projects/myapp/src/test/java/org/myapp/[88,8] reference to assertEquals is ambiguous, both method assertEquals(double,double) in org.junit.Assert and method assertEquals(java.lang.Object,java.lang.Object) in org.junit.Assert match

Since JUnit offer several methods that are very similar the compiler can not always determine which one to use. In our case we have the number 12345 which is an int and result.getValue() which is an Integer. You’d think that the compiler could figure out to convert the number 12345 to an Integer object which would give us a match on “assertEquals(java.lang.Object, java.lang.Object) method, but instead it throws the above error.

The reason for this is that Java uses best match to try to determine the method that will require the least conversion of the parameters. In this case one method requires boxing, and the other method would require un-boxing. Both of these methods have equal priority and that’s why there is ambiguity since none of the methods are more specific than the other.

The solution is to help the compiler determine what it need to do. We can do that using this:

assertEquals(12345, (int) result.getValue());

or this:

assertEquals((Integer)12345, result.getValue());

to resolve this problem. The second solution that converts 12345 to an Integer object is most likely the better once since Java will auto-box a null value to the number 0 which may not be the correct behavior for the class you’re testing.

4 responses so far

Aug 26 2009

Spring XML and defining end of line characters in a bean property

Published by under Java,Spring,XML

If you need to define and end of line character (EOL) like n in your Spring XML files in a bean property you can’t do this

<bean id="some-bean-id" class="some-class">
    <property name="my-property-name" value="n"/>

This simply wont work. You’ll end up with a backslash followed by the letter n. What you have to do is to use an escape character like this

<bean id="some-bean-id">
    <property name="my-property-name" value="&#10;"/>

No responses yet

Aug 26 2009

Maven, Log4j and javax.jms

Published by under Java,Logging,Maven

Log4j version 1.2.15 added features which has new dependencies on sun and javax packages. When you try to build your project using Maven and log4j 1.2.15 you will see this:

[INFO] Unable to find resource 'com.sun.jmx:jmxri:jar:1.2.1' in repository central (
[INFO] Unable to find resource 'com.sun.jdmk:jmxtools:jar:1.2.1' in repository central (
[INFO] Unable to find resource 'javax.jms:jms:jar:1.1' in repository central (

These packages are not in the Maven repositories due to licensing issues. There are two simple solutions to this problem. You can either modify your pom.xml file to use the previous version of log4j (log4j 1.2.14) which doesn’t depend on the JMX and JMS packages:


Or you can exclude the dependencies with the caveat that some of the lo4gj appenders  that depend on these packages wont be available

        These packages are not in the Maven repository
        If you do this certain log4j appenders will not be available

No responses yet

« Newer Entries - Older Entries »