How to easily switch the default Java version on Mac OSX
After installing Netbeans and Java7 for some JavaFX tinkering several of my other apps stopped working.
A lot of the solutions I found online involve writing scripts or changing startup scripts for specific programs, but I found none of them easy or maintainable enough. I ended up altering the symbolic link named “Current” in /System/Library/Frameworks/JavaVM.framework/Versions
A link called CurrentJDK in the same directory still pointed at a 1.6 version, so I simply changed the Current link to point to the CurrentJDK link. That way I can simply change it back when I want 1.7 to be the default.
sudo ln -s CurrentJDK/ Current
How to install Glassfish 3.1 Clustering on multiple hosts using linux command line
Today a colleague needed help with setting up a Glassfish cluster and I remembered having read a very good tutorial that created the entire cluster using only asadmin commands. In my experience using only asadmin commands not only gives you a greater understanding of the way Glassfish works internally but also enables you to create scripts for Glassfish administration commands.
Anyway, I managed to find the blogpost that I read about a year ago and decided that it was a good link to share with the world: http://www.randombugs.com/java/glassfish/installing-glassfish-31-cluster-debian-60-command-line.html
How to connect Glassfish 3 to an external ActiveMQ 5 broker
Introduction
Here at ONVZ we’re using Glassfish 3 as our development and production application server, and we’re quite happy with its performance and stability, as well as the large community surrounding it. I rarely run into a problem that does not have a matching solution on stackoverflow or java.net. As part of our open source strategy we also run a customized ActiveMQ cluster called “ONVZ Message Bus”.
To enable Message Driven Beans and other EJBs to consume and produce messages to and from the ActiveMQ message brokers, ignoring the internal OpenMQ broker that comes shipped with Glassfish, an ActiveMQ Resource Adapter has to be installed. Luckily for me Sven Hafner wrote a blog post about running an embedded ActiveMQ 5 broker in Glassfish 3, and I was able to distill the information I needed to connect to an external broker instead. This blog post describes what I did to get it to work.
Maven best practices
Although Maven offers a “convention over configuration” solution, there is still more then enough configuration necessary to cause some serious headache. In this post I will share some best practices with you that will ease maintenance of your POM files.
How to post nice looking source code on WordPress.com
If you want to post source code and want to make it easy for your audience to read it, use Syntax Highlighter. Blogs on WordPress.com can use this without having to install anything. See http://en.support.wordpress.com/code/posting-source-code for more information.
How to add jars to your Maven project
If you want to physically add jar files to your maven project, so they don’t have to be downloaded from a repository, you can use the system dependency scope, and point to a location in your project:
<dependency>
<groupId>com.missionmode</groupId>
<artifactId>missionmode-api</artifactId>
<version>3.6.51</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/MMAPI-3.6.51.jar</systemPath>
</dependency>
How to create a webservice client with Maven and JAX-WS
Maven allows you to integrate the generation of a JAX-WS webservice client into your build process. To do this, do the following:
1. Create a new module for the webservice client in your maven project.
2. Add the following configuration to the pom.xml of the new module:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>nl.interact.ipds.agentvi.connector.schema</packageName>
<wsdlUrls>
<wsdlUrl>http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl</wsdlUrl>
</wsdlUrls>
<extension>true</extension>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.jvnet</groupId>
<artifactId>mimepull</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
3. The jar that maven generates with the above config, can be used to write a client program like the following:
MovieInformation info = new MovieInformation();
ArrayOfTheater theaters = info.getMovieInformationSoap12().getTheatersAndMovies(“10001″, 1);
for (Theater t : theaters.getTheater()) {
System.out.println(“Theatre: “+t.getName()+”, “+t.getAddress());
ArrayOfMovie movies = t.getMovies();
for (Movie m : movies.getMovie()) {
System.out.println(” -”+m.getName()+”, (Rating: “+m.getRating()+”)”);
}
}