Wednesday, 19 September 2007

Buildr: Using ruby to build java.. hmmm...

http://blog.labnotes.org/2007/05/03/buildr-or-when-ruby-is-faster-than-java/

http://buildr.rubyforge.org/

I've just started getting comfortable with using Maven, and
appreciating all the goodies that cam be used from it, then this comes
along... I wonder how much traction they'll get though, considering
the number of people already using Maven. I guess Ant didn't
disappear when Maven came along, so Maven probably won't disappear
with the appearance of Buildr.

Tuesday, 18 September 2007

Pardon the splatter, I just had my mind blown again...



DJ Sara (8 yrs old) and DJ Ryusei (5 yrs old) tearing it up on the turntable. I wonder if there's a DMC Junior competition somewhere.

Friday, 14 September 2007

Converting a DOS text file into Unix format

I was working on a config file in Ubuntu that had those nasty ^M
carriage returns at the end, and dos2unix doesn't seem to be around
anymore. So came across this info in Wikipedia:

http://en.wikipedia.org/wiki/Newline


The same tasks can be performed with sed, or in Perl if the platform
has a Perl interpreter:

sed -e 's/$/\r/' inputfile > outputfile # UNIX to
DOS (adding CRs)

sed -e 's/\r$//' inputfile > outputfile # DOS to
UNIX (removing CRs)

perl -p -e 's/(\r\n|\n|\r)/\r\n/g' inputfile > outputfile # Convert to DOS

perl -p -e 's/(\r\n|\n|\r)/\n/g' inputfile > outputfile # Convert to UNIX

perl -p -e 's/(\r\n|\n|\r)/\r/g' inputfile > outputfile # Convert to old Mac


It's probably the first time I've used sed!

Fixed: Maven 2 plugin problems with Bamboo/ Hudson + Tomcat setup on Windows

I've been tasked with setting up a continuous integration system at
work, and I've been evaluating - or trying to at least run - these
packages:

- Continuum
- Hudson
- Bamboo


I've yet to try these out:

- Luntbuild
- Cruisecontrol

From the looks of things, I proably should have tried out other two
before the other ones, given the lack of success I've had so far. :(

After a few emails exchanged with Atlassian Support re: Bamboo, I've
fixed a problem I was having with Bamboo and Hudson on my PC. I was
running them under Tomcat, which was installed as a Windows service.
My Ant builds were working fine, but my Maven2 builds were failing,
and would constantly complain that the 'maven-clean-plugin' was
missing, with errors like this:

Bamboo:

12-Sep-2007 16:48:01 [INFO]
----------------------------------------------------------------------------
12-Sep-2007 16:48:01 [INFO] Building AppFuse Core Application
12-Sep-2007 16:48:01 [INFO] task-segment: [clean, test]
12-Sep-2007 16:48:01 [INFO]
----------------------------------------------------------------------------
12-Sep-2007 16:48:01 [INFO] artifact
org.apache.maven.plugins:maven-clean-plugin: checking for updates from
appfuse
12-Sep-2007 16:48:02 [WARNING] repository metadata for: 'artifact
org.apache.maven.plugins:maven-clean-plugin' could not be retrieved
from repository: appfuse due to an error: Error transferring file
12-Sep-2007 16:48:02 [INFO] Repository 'appfuse' will be blacklisted
12-Sep-2007 16:48:03 [INFO]
------------------------------------------------------------------------
12-Sep-2007 16:48:03 [ERROR] BUILD ERROR
12-Sep-2007 16:48:03 [INFO]
------------------------------------------------------------------------
12-Sep-2007 16:48:03 [INFO] The plugin
'org.apache.maven.plugins:maven-clean-plugin' does not exist or no
valid version could be found
12-Sep-2007 16:48:03 [INFO]
------------------------------------------------------------------------
12-Sep-2007 16:48:03 [INFO] For more information, run Maven with the -e switch
12-Sep-2007 16:48:03 [INFO]
------------------------------------------------------------------------
12-Sep-2007 16:48:03 [INFO] Total time: 1 second
12-Sep-2007 16:48:03 [INFO] Finished at: Wed Sep 12 16:48:03 EST 2007
12-Sep-2007 16:48:03 [INFO] Final Memory: 1M/?4M
12-Sep-2007 16:48:03 [INFO]
------------------------------------------------------------------------

HUDSON:

[struts2-starter] $ C:\javatools\maven-2.0.6\bin\mvn.bat package
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building Struts 2 Starter
[INFO] task-segment: [package]
[INFO] ----------------------------------------------------------------------------
[INFO] artifact org.apache.maven.plugins:maven-resources-plugin:
checking for updates from central
[WARNING] repository metadata for: 'artifact
org.apache.maven.plugins:maven-resources-plugin' could not be
retrieved from repository: central due to an error: Error transferring
file
[INFO] Repository 'central' will be blacklisted
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-resources-plugin'
does not exist or no valid version could be found


I had already come across an issue raised for Hudson concerning this,
but didn't completely figure out what it meant:

https://hudson.dev.java.net/issues/show_bug.cgi?id=470

"The current workaround is to have hudson run under a new user with
its own .m2 directory and have whichever profiles are necessary
activated by default. That way, the profiles are picked up as part of
the alignWithUserInstallation mechanism in the embedder."

Atlassian support was able to replicate the error I was getting by
running the Bamboo standalone running under the SYSTEM directory, and
asked me to check if Tomcat was running as SYSTEM, which it was, as I
that is the default when you install Tomcat as a Windows service.
Ah, of course! <lightbulb moment>

When these packages do their continous integration, Bamboo and Hudson
are calling outside the web application to an external batch file. So
when Maven gets run by Bamboo or Hudson, Maven will run as *that*
user, which in this case is the SYSTEM user. I guess SYSTEM user will
try to get its settings from C:\Documents and Settings\Default User\
and not my own user account with the correct maven settings.

So the solution was to go into Services, look for "Apache Tomcat" then
in the "Log On As" column, get it to run as a user with the correct
Maven settings.

Now I don't know if I would have gotten this problem if I was running
under Linux. I think I would still have, because if Tomcat was running
under the user "tomcat", but my maven settings were under a
"autobuild" directory, it would be the same scenario, and the fix
would be to run Tomcat - or whatever app server you're using - under
the "autobuild" account.

Friday, 7 September 2007

Unable to mount .dmg files in OS X - "Device not configured" error. How to fix it.

I had downloaded some DMG files to install some software and kept
getting these error messages:

Unable to attach "Foo.dmg" - Device not configured.

It was happening for more than one .dmg file, and I'm sure the
download was not corrupted.

At first, I tried using the Disk Utility, thinking it was related to
disk permissions, but the option wasn't present when I selected the
DMG. Clicking on "Verify disk" didn't help either, and resulted in the
same error "Device not configured".

Tried the instructions below and they worked.

1. Go into terminal

2. type

su [username that has admin rights]

you will be asked for your admin password.

3. Then run these commands. (I don't know what they do but they worked)

sudo kextunload -c com.apple.AppleDiskImageController

sudo kextload -b com.apple.AppleDiskImageController

4. Now try to mount those .dmg files.

Addendum: It's still not fixed. Now I'm just getting a new error message - "no mountable file systems". Oh great.

Do I believe in Free Markets? Why Sure I do!

http://www.theonion.com/content/news/u_s_to_give_every_iraqi_3_544_91

Tuesday, 4 September 2007

Set up Tomcat to redirect HTTP requests to HTTPS

We had JIRA installed and using the built-in Tomcat app server,
accepting both HTTP and HTTPS requests. We wanted to restrict it so
that all JIRA access was only via SSL. The config changes were pretty
simple.
1. Change Tomcat's server.xml.
Edit the non-SSL <Connector> entry listening on port 80 and add or
edit the redirectPort atribute to point to the port on which the SSL
<Connector> is listening. By default, the redirectPort was pointing
to port 443.
Was:
<Connector port="80"
enableLookups="false" redirectPort="8443"
maxThreads="100" minSpareThreads="100" maxSpareThreads="100"/>

Changed to:
<Connector port="80"
enableLookups="false" redirectPort="443"
maxThreads="100" minSpareThreads="100" maxSpareThreads="100"/>
Because the SSL entry was:


2. In the Tomcat web.xml file the following <security-constraint> has
to be added within the <web-app> element. This new element must be
added after the <servlet-mapping> element:

<!-- SSL settings. only allow HTTPS access to JIRA -->
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>