Tuesday, 29 January 2013

How to open 2 instances of Adobe Flash Builder 7 on Mac OSX

One of my clients creates a source code repository branch per feature being worked on, and sometimes the need comes up to have multiple instances of Adobe Flash Builder open, each on a different branch.

Childs play on other OS but in OSX if you double click on the Application icon it just brings your original instance to the front.  Terminal to the rescue!

Open Terminal and type (assuming you installed in the default location)

open -n /Applications/Adobe\ Flash\ Builder\ 4.7/Adobe\ Flash\ Builder\ 4.7.app/


(if you installed in non default, edit the above to suit your path, make sure to include the .app part).

Simples.

With thanks to Doug Simon's blog post on running multiple versions of Eclipse

Saturday, 17 March 2012

Fixing the "DeployTask cannot be found" error when using the Tomcat 7 Ant tasks on Mac OSX.

So you've got an Ant build.xml script for your Java web application and it works just fine compiling, testing and building your WAR or EAR file. And you manage to ignore your peers who whine on about that Maven thing.

You deploy your application to Tomcat 7, but you do that manually and that's getting boring now so you want to take that last step and script your deploy as well. You kind of like the one click done feel of it, its almost continuous deployment and that is what all the cool kids are into these days so you want some of that action yourself. You're only human.

So you went and Google'd and came across the Tomcat Ant task documentation and yea verily it looked good.

So now in your build.xml file you have something like this (I left out a bunch of other Tomcat commands, dont worry if you have those)
<taskdef name="deploy" 
    classname="org.apache.catalina.ant.DeployTask"/>

<taskdef name="undeploy" 
    classname="org.apache.catalina.ant.UndeployTask"/>

<target name="deploy" 
    description="Install web application"
    depends="war">
    <deploy url="${url}" 
        username="${username}" 
        password="${password}"
        path="${path}" 
        war="file:${build}${path}.war"/>
</target>

<target name="undeploy" 
    description="Remove web application">
    <undeploy url="${url}" 
        username="${username}"
        password="${password}"
        path="${path}"/>
</target>

But when you run it via Terminal like so

adrian$ ant -Dusername=adrian -Dpassword=pass -f build.xml deploy

you see this really annoying error (even though it worked in your IDE, or maybe it worked on the first machine but not now)

BUILD FAILED
build.xml:11: taskdef class org.apache.catalina.ant.DeployTask cannot be found
using the classloader AntClassLoader[]

Here's how I fixed this (on two machines now). Hopefully it will help you too.

First I have a symlink set up to point at my Tomcat installation, like so

ln -s /path/to/where/i/put/Tomcat /Tomcat


so you might do that too, but if not, just replace /Tomcat below with whatever your path to Tomcat is.

Then in Terminal run these 4 lines, supplying your admin password when prompted
sudo cp -p /Tomcat/lib/tomcat-util.jar /usr/share/ant/lib/
sudo cp -p /Tomcat/bin/tomcat-juli.jar /usr/share/ant/lib/
sudo cp -p /Tomcat/lib/tomcat-coyote.jar /usr/share/ant/lib/
sudo cp -p /Tomcat/lib/catalina-ant.jar /usr/share/ant/lib/

So we're just copying 4 JAR files to where your Mac has it's Ant installed.
Restart Terminal and this time you see
...
deploy:
[deploy] OK - Deployed application at context path /ReptileKingdom

BUILD SUCCESSFUL

Fantastic! Back to writing awesome code for you.


Oh and one last thing - if you instead see another error, much like this

build.xml:69: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/text/undeploy?path=%2YourApp

then you need to edit your /Tomcat/conf/tomcat-users.xml file and make sure you have a user in there who has at least manager-script role, but I generally just give all of them like so manager-script,manager-gui,manager-jmx,manager-status.
And of course, the username and password you specify in your deploy call should match those for the user with the roles.

Tuesday, 7 February 2012

Fixing "Incompatible JavaHL library loaded" error on Mac OSX

So you use Eclipse on your Mac and you want to work with a Subversion version control system, so you installed Subclipse and everything seemed fine... and maybe it even used to work OK last time..., but now, today, when you need it most - you get an error that says:
Incompatible javaHL library loaded
and it probably says version 1.7 too.

Whats happening is that the subversion files you are trying to work with are at a more recent version than you have available locally. Here's how to fix it.

  1. Make sure you have latest Subclipse installed, go to the Subclipse site, click on Download and Install, grab the appropriate Eclipse update URL, then in Eclipse, go to Help, Install New Software, and add that URL as a new update site. After it loads, select everything it offers and finish the install. Here is the Eclipse update site for version 1.8
    http://subclipse.tigris.org/update_1.8.x
  2. Now we need to install Subversion client binaries on your machine, Collabnet don't have the latest but luckily UberSVN do, so go to the UberSVN download page, select the OSX tab, then click to download the Subversion Client 1.7.2. Note: it's not that big blue call to action button! It's the links below. Once you have the client, go ahead and install it.

  3. Quickly add Subversion to your path, I do this by editing ~/.profile and adding
export PATH=/opt/subversion/bin:$PATH
Restart Eclipse, and with an ounce of good fortune, Subversion and Subclipse now work again.

One last note: if, just like me, you found that big blue call to action button on UberSVN's download page just too tempting to resist... there is an unofficial (but seems to be written by a UberSVN's developer) Mac OSX UberSVN uninstaller script to tidy that up.
Worked a treat for me.