Mar 132014
 

As you probably know, Oracle stopped development of Glassfish’s commercial version and in doing so, prompted others to move. News of Glassfish being dead is greatly exaggerated according to some but myself being one who was already not happy with Glassfish’s Open Source version, steps were taken to move to WildFly. So far, the move has been well received in the team except for web based GUI administration panel which isn’t complete. Reliability of the admin panel is higher than Glassfish’s counterpart though and what WildFly’s web admin panel lacks, it’s CLI and Swing based GUI admin panel make up for allowing script writers (such as myself) to come up with automated ways to get things done.

A while back we discussed how you could use JNDI custom resources on Glassfish to set environment variables. Migration for our team meant information setup as environment variables need to be setup again.

Continue reading »

Mar 112014
 

The Atlassian suite of tools are a good way to have your organization’s workflow administered. If you’re using Atlassian Stash to manage your source code and are attempting to get Atlassian Bamboo to download code off Stash’s copy of git, the answer isn’t quite straight forward.

Having experience with Atlassian’s tools for over a year, one gets used to excellent integration wrapped up with beautiful UI but when it comes to setting up flawless CI with Bamboo, you’re let down (either that or my integration is non-standard; don’t see how). Continue reading »

Dec 032013
 

If you’re trying to create a Custom Project in Eclipse, you’ll eventually come to read a beautiful blog post over at Hidden Clause that documents quite well how to overlay your icon over Eclipse’s default folder icon to get the icon of your choice.

If you’re default project is an extension of an already existing project (I, for example, wanted a custom Java Project type so I extended Eclipse’s New Java project wizard to get desired effect), the default nature added is that of Java meaning Eclipse adds it’s icon and not the icon you’ve set up. The issue isn’t even in the step you’ve just followed to add the icon. The issue was inadvertenly induced in the last step while adding your custom project nature with code which looks something like this (reference code from Hidden Clause)

private static void addNature(IProject project) throws CoreException {
    if (!project.hasNature(ProjectNature.NATURE_ID)) {
        IProjectDescription description = project.getDescription();
        String[] prevNatures = description.getNatureIds();
        String[] newNatures = new String[prevNatures.length + 1];
        System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
        newNatures[prevNatures.length] = ProjectNature.NATURE_ID;
        description.setNatureIds(newNatures);

        IProgressMonitor monitor = null;
        project.setDescription(description, monitor);
    }
}

This can be remedied easily by ensuring your nature ID is added before that of your predecessors. Eclipse only applies the icon from one nature, not multiple ones. Here’s the code I ended up with

final IProjectDescription description = project.getDescription();
final List natures = new ArrayList<>(Arrays.asList(description.getNatureIds()));
natures.add(0, Database.NATURE_ID);
final String[] newNatures = natures.toArray(new String[natures.size()]);
final IStatus status = ResourcesPlugin.getWorkspace().validateNatureSet(newNatures);

// check the status and decide what to do
if (status.getCode() == IStatus.OK) {
    description.setNatureIds(newNatures);
    project.setDescription(description, null);
} else {
    // raise a user error
}

Next up, now to make the icon be used completely and not as a simple overlay..

Oct 082013
 

As a developer, I like to look at the source code for the libraries I use in order to understand if what I am doing is the best way to implement it or not. Though Eclipse, by default, comes with features to develop plugins, it doesn’t come with the source code for this. Getting the source is a simple, 3 step process!

  • Help > Install new Software
  • Work with ‘The Eclipse Project Updates’ (not the main site!)
  • Install the following items
    • Eclipse RCP Plug-in Developer Resources
    • Eclipse PDE Plug-in Developer Resources
    • Eclipse Platform Plug-in Developer Resources
    • Equinox p2 Core Function Source
    • Eclipse JDT Plug-in Developer Resources

Welcome to the source, Neo!

Updated (29/11/2013): More source projects added! Seems there is a nice StackOverflow question on the same (which doesn’t have an answer which meets my satisfaction). I’ll keep my post in sync with my answer on StackOverflow.

Oct 082013
 

Windows, at times, denies you the right to delete a file or a folder. I’ve noticed this happening especially when you copy the contents of the folder to empty it and later try to delete it. At this moment, you’ve got to ask yourself if you’ve got the necessary permissions to do so.

If you’re like many, you have admin privileges to your machine but you still can’t delete it. This is because Windows’ permissions table for this directory is broken and as a result, is denying you access. You can right click the folder, go to properties and look under the ‘Security’ tab to confirm who has permissions but, if you’re like me, this tab will look weird too because a regular tab shows a list of groups or users who have access and this one won’t. This post here shows you, quite clearly, how the permissions page should look.

The most popular solution is one I’ve already written about. The takeown method I’ve written about  in my previous post named “The Undeletables” is one which has existed since Vista and continues to work for many on Windows 7. The “Take Ownership” script  is an extension of this method and adds a “Take Ownership” option to the right click context menu of every file and folder in explorer. Last time I had this problem, it was because I had directories which were restricted ones (Windows directories) on a drive where an old Windows resided. This script helped me clear that. Alas, this time, it didn’t work.

I was about to format my drive (because I had enough space to move data around and do that, quite rare if you ask me :)) but decided to try one last thing. Windows’ error correction option. You might know this screen from when you pull out a flash drive without safely disconnecting it. Weirdly enough, running Error Check on the drive actually worked! :D

Error Checking optionRight click on the drive, go to properties, open the “Tools” tab and under the error checking section, click “Check now”. 

check disk window

You should be able to select the default options on the check disk window and run the scan. “Scan for and attempt recovery of bad sectors” is only recommended to be used when you’re actually dealing with bad sectors. It’s going to take a while to run that scan. The regular scan, however, should be done in 5-10 seconds on a 2TB HDD.

These steps did work out for me. Let me know if they work for you too! :)

Jul 182013
 

Earlier this week, I was maintaining a web-application when I noticed something weird. Some images were not shown on my browser at times. The application dynamically displayed images based on certain conditions using java script and every once in a while, an image would disappear. This only happened to me and would occur on Safari and Chrome.

Looking at the dev console told me that the browser couldn’t set new images to the img tag on the page since it “disappeared”. Investigation showed that the image that the tag disappeared after the image tag tried to show “ad.gif“.

I kept reading this as “aay dee dot gif” (because that’s what it was, based on the application’s context.. that’s certainly why the original, rather unsuspecting developer meant it to be).

What struck me later was that the div was being eaten up by adblock on those browsers and that’s what caused the error. When I tried to access the images directly, they worked. If I embedded them into a HTML page, they wouldn’t.

Conclusion: If you’re a web developer, don’t name images ad.* (or any other image type) because that will cause Adblock Plus to block a rather legitimate image..

May 142013
 

Custom resources allow you to store server side values that are available to different J2EE applications on your server. This is an extremely useful feature that one should use.

Head on over to the Glassfish admin panel (should be at localhost:4848 for most of you), go to Resources > JNDI > Custom Resources and create a new entry which looks like the following:

Glassfish Custom Resource

It is important to note here that if the name isn’t “value” (exactly), you will not be able to read this value via a InitialContext lookup in your Java code. You will get an exception as follows:

javax.naming.CommunicationException: Communication exception for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is java.lang.IllegalAccessException: value cannot be null]
...
Caused by: java.lang.IllegalAccessException: value cannot be null at org.glassfish.resources.custom.factory.PrimitivesAndStringFactory.getObjectInstance(PrimitivesAndStringFactory.java:99)

Essentially, the InitialContext code attempts to read a property named “value” by default.

Here is the code you can use to read the constant you’ve added:

new javax.naming.InitialContext().lookup("mailConfig");

If you want to use a JNDI entry in a not so direct way (not name it “value”), you can read it using the following code:

javax.naming.InitialContext c = new javax.naming.InitialContext();
javax.naming.NamingEnumeration neb = c.listBindings("");
while (neb.hasMore()) {
  javax.naming.Binding b = neb.next();
  if (b.getName().equals("mailConfig")) {
    javax.naming.Reference obj = (javax.naming.Reference) b.getObject();
    java.util.Enumeration en = obj.getAll();
    while (en.hasMoreElements()) {
      javax.naming.RefAddr ra = en.nextElement();
      System.out.println(ra.getType() + "=" + ra.getContent());
    }
  }
}

Took me a while to get these code samples working. Doesn’t seem to be clearly documented. Hope this helps someone else :)

May 012013
 

Most people don’t know about this but if you head on over to the Google I/O, their 2013 event website shows big I/O images that you can click and it reads out the letters ‘I’ and ‘O’. Enter the right code and you get nice effects. Here’s a list of codes you can try out.

  • Cat Mode: IIIOOIII
  • Space Mode: OOIOIOIO (doesn’t work on Android)
  • Pong Mode: IOOOOOOI
  • Bacon Mode: IOOIOOOO
  • Simone Mode: IIOIOOII
  • Eightbit Mode: OIOIOOII
  • Synth Mode: IOOOIOOO
  • Song Mode: IIOIIOII
  • ASCII Mode: OIIIIIII
  • Bowling Mode: OIIIOIOI
  • Rocket Mode: OIOOOIOI
  • Burger Mode: OOIIIOOI

So head on over to the Google I/O 2013 website and try these out :) Note that Synth Mode will work only if you have audio enabled and Space Mode will not work on Android devices.

Source: http://zakelfassi.com/2013/03/08/all-googleio-easter-eggs/

Apr 292013
 

TeraCopy is an amazing tool for Windows which allows users to queue up copy requests, pause them, re-order them and change copy file lists at run time. It’s got a lot of power and great integration with Windows. It’s a tool which I highly recommend.

Go check it out! I bet that you’ll love it so much that you wouldn’t mind paying $20 for it! ;)