Wednesday 25 January 2012

Spring Roo & GWT - Missing dependency: com.googlecode.gwt.inject:gin:jar:1.5

It's always annoying when the "Hello World" example that is supposed to sell a new tool to you fails - at build time! Thankfully this one's an easy fix thanks to a solution posted to the springsource forums:

If you open pom.xml, and search for:  <artifactId>gin</artifactId>
which will take you to the gin dependency definition.

Now, if you change the groupId from:
<groupId>com.googlecode.gwt.inject</groupId>

to this:
<groupId>com.google.gwt.inject</groupId>

and change the version from:
<version>1.5</version>

to this:
<version>1.5.0</version>

That should fix it.


Spring Roo - My First Thoughts

I've spent the last day investigating Spring Roo, which looks really good. I've never been a big fan of code generators, but since it follows best practices and you can fold-in its generated code into the main classes at anytime - something i've yet to try - it seems less of a risky option.

As someone who's spent way to much of my life mashing various frameworks together - sometimes giving up out of shear frustration with certain combinations - Spring Roo is going to come in very handy.

It hasn't been all plain sailing tho, there have been a few issues to do with dependencies and odd issues with some of the generated bits, but thanks to a quick google search i've sorted most of my problems.

All in all though, its a very impressive tool, and if you haven't yet tried it, and you work with Java/Spring/Hibernate etc - its really worth a look.

Sunday 22 January 2012

Setting JAVA_HOME on MAC OS X


There are two parts to this problem - figuring out where Java is installed in your system and then setting up the environment variable in a reliable way so its always available.

There is a command you can use to find the actual path of Java on your system:

/usr/libexec/java_home

on my system this gives:

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

on your system it may be different and of course it will change with every release of Java installed.

Apple recommends in this article that instead of referencing this path directly you point your Java_Home environment variable to this symbolic link instead:

/Library/Java/Home

This link actually points to a chain of links which ultimately end up in the /System/Library/Java... path above.

So that's step one sorted, what about step two: setting up the environment variable?

A discussion here seems to favour setting the variable in /etc/launchd.conf, the reasoning for this is made clear in the discussion. I took their word for it, and it worked for me, if your happy to do the same go ahead and edit the following file:

/etc/launchd.conf

this file may not exist already on your system, in which case editing it will cause it to be created. 

Add this line:

setenv JAVA_HOME /Library/Java/Home

That should do it, but you'll need to restart your system for the change to take effect.

After the restart open up a terminal and enter the following command to see a list of the currently defined environment variables:

export

you should see JAVA_HOME listed and the value should be /Library/Java/Home.

if you want to refer to the environment variable in scripts or from the terminal you need to prepend $ to the environment variable, for example:

echo $JAVA_HOME

will display the value of the variable, while the following will take you to the Java directory:

cd $JAVA_HOME

Well that's two hours of my life i'm not getting back - I hope this post saved you a bit of yours!

Saturday 21 January 2012

Changing the text of modules e.g. mod_login

The standard text for the login module is specified in C:\xampp\htdocs\myproject\language\en-GB\en-GB.mod_login.ini

I didn't have enough room for all the text in my design, so I decided to shorten the information:

from:

FORGOT_YOUR_PASSWORD=Forgot your password?
FORGOT_YOUR_USERNAME=Forgot your username?

to:

FORGOT_YOUR_PASSWORD=Forgot password?
FORGOT_YOUR_USERNAME=Forgot username?

It's only a little change but it made a difference to my design where space was tight. But more importantly it opens up the possibilities to change lots of core module functionality. If you've gone to the trouble of creating a html folder to modify content... use it!

How to add a default value to Joomla mod_login

I spent ages modifying the mod_login default.php file to no avail.

I deleted my cache under Tools > Clean Cache, restarted Apache, nothing was working.

Then I remembered that I had overridden the standard output from the Joomla! Core Modules and Components by adding code to the html directory of my template.

I made the change in C:\xampp\htdocs\myproject\templates\myproject\html\mod_login\default.php by adding a value="" attribute to the input tag:

<fieldset>
        <label for="mod_login_username">
            <?php echo JText::_('Username'); ?>
        </label>
        <input name="username" id="mod_login_username" 

               type="text" 
           class="inputbox" 
           value="<?php echo JText::_('Username'); ?>" 
           alt="<?php echo JText::_('Username'); ?>" />
        <label for="mod_login_password">
            <?php echo JText::_('Password'); ?>
        </label>
        <input type="password" id="mod_login_password" 

               name="passwd" 
           class="inputbox" 
           value="<?php echo JText::_('Password'); ?>" 
           alt="<?php echo JText::_('Password'); ?>" /> 
</fieldset>

Friday 20 January 2012

Fixing missing Jar files from WEB-INF/lib when you import a web project into Eclipse

If you import an existing web project into Eclipse you may see various errors reporting missing libraries in the WEB-INF/lib directory. 

The simplest way to fix the issue is to just right-click on one of the errors and select the Quick Fix option:

Quick fix -> Synchronize <WAR>/WEB-INF/lib with SDK libraries

This will copy the jar files into WEB-INF/lib.

Thursday 19 January 2012

How To Verify a SHA1 Checksum on OS X

Its so simple you'd be silly not to...

Download the file to somewhere close to hand such as the Desktop or Downloads folder

Open a Terminal from Applications->Utilities->Terminal.app

In the terminal enter the path to the sha1 command:

/usr/bin/openssl sha1

Enter an extra space at the end of the command - Don't press Enter yet!

now drag the downloaded file from wherever you stored it into the terminal window and OS X will kindly enter the path to the file for you - nice :)

Now press enter and the sha1 program will generate the sha1 checksum.

Compare the output from sha1 with the checksum on the download site - as long as they match you can be confident the file is authentic. If not send it to the trashcan!