Author Archive

java.lang.ArrayIndexOutOfBoundsException with EmbeddedLDAP

11 December 2013 2 comments

If you forcefully stop the Weblogic Admin Server you might end up with corrupted LDAP files, and your admin server won’t start up with the following exception

####<Dec 7, 2013 2:45:18 AM BST> <Critical> EmbeddedLDAP <AdminServer> <VDE Replication Thread> <<anonymous>> <> <BEA-000000> <java.lang.ArrayIndexOutOfBoundsException
     at com.octetstring.vde.EntryChanges.readBytes(
     at com.octetstring.vde.EntryChanges.<init>(
     at com.octetstring.vde.replication.BackendChangeLog.getChange(

Before you do anything make sure that you have a copy or you know all the groups and users you have created in your domain.

The solution on Weblogic 7.x was to delete the EmbeddedLDAP.tran file. But with later Weblogic versions this might not work. Another solution is to backup and delete the servers/<admin server>/data/ldap folder. If this still does not work then backup and delete the servers/<admin server>/data folder. This will fix it but once the Admin server is up and running make sure that all the groups and users are still there. If not you will have to recreate all of them manually from the console.

Categories: WebLogic

More WTF!

15 November 2013 Leave a comment
if (true)
    if (externalCreditDeposit == 0)
        creditDeposit = internalCreditDeposit;
        creditDeposit = intWeight * internalCreditDeposit + extWeight * externalCreditDeposit;

Just to make sure that it will always be executed!

// Variable declaration
        String oldMsisdn = "";
        String newMsisdn = "";
        int rows = 0;
        int cols = 0;
        int tmp = 0;
        int listPtr = 0;

Just to make sure that we know there are variable declarations!

if (request.getParameter("hasBlackberyFromTor")!=null && request.getParameter("hasBlackberyFromTor").equals("1")) {
         blackberryExtraPlus  = "-22";

Unnecessary empty if statement.

Categories: Java, WTF

Not tested yet! (WTF)

5 November 2013 1 comment

This is some production code, that fails.

// Do conjunction////NOT TESTED YET???I dont know what will happen : (
startConjunction(customers, application);

Not sure if the author forgot the comment there or it indeed is not tested. But knowing that the code might not work and not fixing it is really WTF!

Categories: Java, WTF

WTF code!

7 October 2013 1 comment

While I was looking at some legacy code I stumbled upon a few wtf! moments. This is code that surprised me and made me laugh. Not that I haven’t written bad code in my life, but this is hilarious.

setPMPLogHistory(new Integer(applicationId).toString());

In the code above, the variable applicationId is already a String! The developer first creates a new Integer instance from a String and then turns this into a String again!


Apart from the obvious refactoring (the “1” should be at the beginning of the comparison in order to avoid a npe) you don’t have upper/lower case digits, so the equalsIgnoreCase is unnecessary.

Categories: Java, WTF

There Will Be Code

30 September 2013 Leave a comment

“One might argue that a book about code is somehow behind the times—that code is no
longer the issue; that we should be concerned about models and requirements instead.
Indeed some have suggested that we are close to the end of code. That soon all code will
be generated instead of written. That programmers simply won’t be needed because business people will generate programs from specifications.

Nonsense! We will never be rid of code, because code represents the details of the
requirements. At some level those details cannot be ignored or abstracted; they have to be
specified. And specifying requirements in such detail that a machine can execute them is
programming. Such a specification is code.

I expect that the level of abstraction of our languages will continue to increase. I
also expect that the number of domain-specific languages will continue to grow. This
will be a good thing. But it will not eliminate code. Indeed, all the specifications written
in these higher level and domain-specific language will be code! It will still need to
be rigorous, accurate, and so formal and detailed that a machine can understand and
execute it.

The folks who think that code will one day disappear are like mathematicians who
hope one day to discover a mathematics that does not have to be formal. They are hoping
that one day we will discover a way to create machines that can do what we want rather
than what we say. These machines will have to be able to understand us so well that they
can translate vaguely specified needs into perfectly executing programs that precisely meet
those needs.

This will never happen. Not even humans, with all their intuition and creativity,
have been able to create successful systems from the vague feelings of their customers.
Indeed, if the discipline of requirements specification has taught us anything, it is that
well-specified requirements are as formal as code and can act as executable tests of that

Remember that code is really the language in which we ultimately express the requirements.
We may create languages that are closer to the requirements. We may create tools
that help us parse and assemble those requirements into formal structures. But we will
never eliminate necessary precision—so there will always be code.”

Robert C. Martin – Clean Code. A Handbook of Agile Software Craftmanship.

Well said Robert. This summarises, in a few paragraphs, how important code is in our every day activities.

Categories: Books, Java Tags: ,

How to programmatically add a a4j:commandButton and a4j:actionparam

2 April 2013 Leave a comment

After spending a few hours I finally managed to programmatically add an ajax command button and action parameter to JSF (1.2) components. So the following

<a4j:commandButton value="Click Me"
	styleClass="buttons" rendered="true" immediate="true"
	id="buttonId" actionListener="#{newRequestBean.doSomething}"
	<a4j:actionparam name="theVat" id="vatId" value="IComeFromTheBean" assignTo="#{newRequestBean.vat}" noEscape="false"/>

translates to

MethodExpression methodExpression = application.getExpressionFactory().createMethodExpression(
                                new Class[0]);
HtmlAjaxCommandButton button = (HtmlAjaxCommandButton) application.createComponent(HtmlAjaxCommandButton.COMPONENT_TYPE);
button.setValue("Click Me");

ValueBinding vb = context.getApplication().createValueBinding("#{newRequestBean.vat}");
HtmlActionParameter param = (HtmlActionParameter) application.createComponent(HtmlActionParameter.COMPONENT_TYPE);


Things to notice:

1) The last parameter of the method expression should be an empty array (new Class[0]), otherwise you will get the exception “java.lang.IllegalArgumentException: wrong number of arguments“. Your method should have no parameters.
2) You should add the HtmlActionParameter as the action listener of the command button. This is an absolutely essential step in order to make it work (well, this is only if you want to pass parameters to the call). It took me literally hours to figure this out.
3) The context variable is a FacesContext.

Categories: Java, JSF, RichFaces Tags: , ,

SOAPException: faultCode=SOAP-ENV:Client; msg=For input string: "3773 "; targetException=java.lang.NumberFormatException

7 December 2012 1 comment

I get this warning with JMeter

WARN - jmeter.protocol.http.sampler.WebServiceSampler: [SOAPException: faultCode=SOAP-ENV:Client; msg=For input string: "3773 "; targetException=java.lang.NumberFormatException: For input string: "3773 "]

every time I try to test a web service by running a WebService(SOAP) Request. Strange it might seem, but I found out that the error is actually a network error; to be more specific an HTTP/1.1 504 Proxy Timeout ( The connection timed out. ). The original error is totally misleading.

The connection times out, so I get no SOAP response back. What I get though is the headers, the content and the content length back. But for some reason the content length is padded with some spaces at the end and when the HTTPUtils (the class that handles the SOAP request/response) tries to parse it with this statement


it fails. I had to rebuild jmeter and step through it with breakpoints in order to see what’s going on. The solution is as simple as adding a trim to the statement (a couple of lines above the offending statement):

String value = valuebuf.toString().trim();

This fixes the issue and you get the actual response back which is

Error Code 10060: The gateway could not receive a timely response from the website you are trying to access. This might indicate that the network is congested, or that the website is experiencing technical difficulties..

Incorrect argument type encountered in function or method invocation. in main

21 November 2012 1 comment

I am working with ORACLE SOA & OSB version This error occurs if you use Oracle Business Rules and you forget to pass all the objects defined in your decision function. To elaborate: if in your decision function you have defined as inputs, let’s say, the objects Customer and Address, but in your code you only pass as input the object Customer, then you will get the error message above. To fix it either pass both objects, or remove the unused object from the input settings of your decision function.

The actual error oracle outputs is rather misleading. I spent three hours trying to find out what’s going on.

Categories: Oracle, OSB

Android INSTALL_FAILED_CONTAINER_ERROR on installing an application

28 April 2012 4 comments

I got this error while I rebooted my android device in the middle of installing an application (it was taking ages so I assumed that it was stuck). It seems that android did not have time to clean the file system, so every time i was trying to install an application I was getting the error:

ASEC file ‘/mnt/secure/asec/smdl2tmp1.asec’ currently exists – destroy it first! (Address already in use)

The solution to this is actually very simple. Make sure that you have connected your device to your computer and that it’s running on debug mode (it’s not mounted). Open a command window, go to your Android\android-sdk\platform-tools and type adb shell. This should open the adb shell and connect as root. Then simply type rm /mnt/secure/asec/smdl2tmp1.asec and the problem should go away.


Categories: Android Tags: , ,


21 April 2012 3 comments

Lately I have started doing some Android development. I have written a small application called “Lexicon” which you can find on Google Play. It works with Android version 2.2 and above. It’s a dictionary which you can use from any application that has “share text” capabilities. I’d appreciate if you can download it (it’s free) and test it on your device (I have only tested it with Android 2.2 and 2.3). If you do download it please read the release notes. Please let me know of any bugs or errors you find.

Thank you.

Categories: Android Tags: , ,