Monday Sep 26, 2005

Glassfish on Mac OS X

I finally got to spend a bit of time on the Mac OS X build of the glassfish project. Truth is that nightly builds for Darwin had been posted to the glassfish Web Site for quite some time now, however, there was never a posted promoted build. This was due to the 3 security tests of the Quicklook suite failing on the Mac.

I looked into it and the issue was deceptively simple, the domain.xml is setting the java.ext.dirs property (known as the extension directories). Sadly, the JDK ext/lib was not set correctly on the Mac since there is no jre directory under JAVA_HOME.

On most platforms the directory layout is JAVA_HOME/jre/lib/ext but not on the Mac where Apple has decided that the jre directory was superfluous, so the path is JAVA_HOME/lib/ext...

Anyway, the SunJCE.jar is located in the JDK lib/ext and provide the DESede algorithm, and guess what, the 3 tests failing were using this algorigthm...

Quick survival instructions on how to use glassfish on mac ?

  • Go to the glassfish web site Glassfish Web Site
  • Download the latest promoted build
  • Go to your target directory and do a jar -xvf
  • ant -f setup.xml

    Et Voila !

  • Thursday Jun 30, 2005

    Web Services and vi !

    Web Services and vi

    Yesterday, I spoke at JavaOne, presenting the Sun Java System Application Server Platform Edition 9.0 to the general public. People were excited to hear about the new features but most importantly people loved to hear that we were now a commercially supported open source project. The project Glassfish is as far as I know one of the few commercially supported open source project. I think this is an exciting development to see the code and the expertise shared. We released the source code so people can fix bugs, provide features or just participate to discussions. And this is all free, including the docs, unlike JBOSS who charges for docs for instance. But what I think really differentiate us is the fact we have a support infrastructure in place which can be used when applications go into production, we have great field engineers and market development engineers who are ready to help with customers, on top of what all open source projects do, mailing lists and forums.

    Now let's dive into the real issues that brought me here today. How can you develop a WebService in 5 minutes chrono with vi (or notepad...). I did this demo yesterday at JavaOne and for those of you who missed it, I am now bringing it to you...

    Web Service implementation

    First you need a editor, I used vi, take the one you like. The simplest web service you can think is of course the "hello world" example. This is the complete code below, just a few line of code and that's all you need.

    package endpoint;

    import javax.jws.WebService;

    public class Hello {

        public String sayHello(String param) {
            return "Hello " + param;

    now to deploy this powerful web service in glassfish, you just need to do

    javac -cp $GLASSFIH_HOME/lib/$GLASSFISH_HOME/lib/j2ee.jar:. -d $GLASSFISH_HOME/domains/domain/autodeploy

    By compiling directly into the autodeploy directory (-d option), you have in fact deployed this web service. you should ensure that the deployment went fine by controlling the log file ($GLASSFISH_HOME/domains/domains/logs/server.log).

    You can browse the wsdl by accessing the following URL [http://localhost:8080/Hello/HelloService?WSDL Be aware that the URL could be different in your environment, again study the log file mentioned above, it tells you the URL for the deployed endpoint in one of the messages that popped up during deployment.

    That's it ! You wrote your first jax-ws 2.0 web service and deployed, on to testing it...

    Web Service Client

    The client side of things is a bit more complicated... First you need to remember that with Web Services, the WSDL is the interface against which you can program your clients. There is not such a thing like in EJB where you have a java interface. Since Web Services is about interoperablity, WSDL is the reference and the description of your endpoint capabilities. So what you need to do to be able to program your client access code at ease is generate a java interface from the WSDL (that's right, the exact one that was published when you deployed your web service earlier). You could use the wsimport tool and study the resulting artifacts but since I have little customized my @WebService annotation, I can make from the jax-ws docs a few educated guesses :

    • the package name for the client classes will be the same as the server with "jaxws" appended (in our case, it becomes endpoint.jaxws)
    • the Service interface is the web service implementation simple class name + "Service"
    • the port is the web service implementation simple class name
    So below is the code for the simple client example, the @WebServiceRef will be used to point to the WSDL file defining the web service. The service static variable will be injected by the application client container and the rest of the code is pretty much straightforward.

    Now do the following :
    • wsimport http://localhost:8080/Hello/HelloService?WSDL
      this will create the client artifacts
    • compile the class below (remember to resuse the same classpath).
    • run the application client container : appclient client.Client

    And you should see the result of the invocations !

    package client;

    import javax.jws.WebServiceRef;

    import endpoint.jaxws.HelloService;
    import endpoint.jaxws.Hello;

    public class Client {

            static HelloService service;

            public static void main(String[] args) {

                try {
                    Hello port = service.getHello();
                    for (int i=0;i<10;i++) {
                        System.out.println(port.sayHello("blog readers !"));

                } catch(Exception e) {


    That was easy ! few things to remember :
    • I basically just compiled and run both the web service server and clients. We now have the same developer experience in Java EE 5 and with Java SE. No more packaging, no more stubs, no real deployment either...
    • Everything is ready on the glassfish website to get you started. The implementation is not finished of course but you can start today and give us our feedback, you can help in many ways.
    , ,

    Monday Jun 27, 2005

    Sun's Java System Application Server on Mac OS X

    SJS Application Server

    on Mac OS X

    What is this about : SJS AppServer 9.0 is the Java EE implementation at Sun Microsystems, Inc, it can also run on Mac OS X !

    For the past year, I have been quite busy, at work with various unrelated projects and at home with a new baby. One of my favourite project -which, unlike others, did not keep me awake at night- was to port the Sun Java System Application Server PE to the Mac OS X platform. Now the Appserver is a massive piece of software, and since it is now open source, one could count the lines of code for me. In the meantime, without exagerating, it sounds very scary to port an Java EE Application Server. But when my director sweetened the deal with a Powerbook, I -one could say- gladly accepted the challenge.

    Already dreading having to give this jewel back after just a few weeks, crawling like a decripit wreck after nights of hacking, I prudently started on the task, not knowing really what I embarked onto. Afterall, I was a complete OS X novice ! Right, let's talk about my background : I have no loyalty. I have worked with Solaris, JDS Linux and even Windows for many years but never really touched a Mac (outside of some dribbling visits at various Apple stores). So, it took me a few hours to get around the new OS, find the develpment tools I needed and create all the proper unix settings to checkout the workspace from our CVS server.

    After that, I can honestly say it took me about the 2 working days to get the application server to start, but don't tell my manager, I spend three more days playing with panther... Anyhow, most of the problems I ran into where :
        - use of makefiles : yep, that's right, we used some good old fashion makefiles that knew nothing about that Darwin name.
        - jni libraries : oh well, to store our encrypted passwords, we used a C library invoked using JNI. As it turn out, that one file (yes 1 file) kept me busy half a day because of some differences in the way environment variables can be retrieved with Darwin. Now that's pretty bad, we had only 1 C file, and I ended up spending 4 hours on it.
        - JDK file layout differences, the Apple folks have organized their JDK very differently than us at Sun, so I had to change a few things in code that was being to smart about where the java compiler would be for instance.

    To finish the job, I had to spend few more days to iron out some issues around class loading, CORBA integration and other goodies I could live without, but it was so easy, getting a Powerbook out of it was a complete steal ! And with it, I could even create DVDs of the offspring for the grannies, life was beautiful !
    As a conclusion, I can honestly say the Java is a fantastic cross platform development tool (outside of being a great language with the best class library), because for 99% of our code, it just worked. And yes, we had some Swing apps and other GUI goodies, and that worked too ! To be completely fair, it is true that our appserver was already running on Solaris and Windows but still, after spending the last 9 years at Sun developping Java, I was amazed and proud how easy it was.

    Ok, I am on the edge of boring you all now, so let's dive into why you all came to read my little essay, AppServer on OS X !

    First thing to do, decide which version you want to use :
    • Project Glassfish : This is the open source project for the Sun Java Enterprise System Application Server 9.0 Platform Edition. You can download nightly builds, checkout the code from CVS directly and start contributing with the Java EE community. This one requires Tiger since you must use Java SE 5.
    • Sun Java Enterprise System Application Server 8.1 : This is the last version we released, it passes all CTS tests on the mac and it is free to use, develop and deploy. To get it, you need to install the cobundle with Netbeans or Creator since it was not released unbundled. It works on Panther and Tiger with JDK 1.4.2 or 1.5.

    Project Glassfish

    Fantastic ! you are ready to live on the leading edge of Java EE 5 development as it happens, and participate to the excitment of seeing it happening.

    Well, there is not much I need to say in this blog, just go to
    There you will have the ability to join the growing community of glassfish developers, you just need to either download the latest nightly or promoted build or even better, you can checkout the code directly from our cvs server and get to operate on the code, including mine (talk to me first, so we can be all productive)...

    This is exciting development, to have this free product becoming now an real Open Source project under CDDL. Plenty of other blogs will explain how to use Netbeans and alternate tools to develop with Glassfish, so don't hesitate joining forces.

    Glassfish Home Page

    The only trick is that you need JDK 5 installed on your Tiger, and since by default, JDK 1.4.2 is enabled, I have updated the FAQ on the glassfish project website but basically you need to set tow environment variables :


    that's all you need to build your version of this OpenSource Application server.

    How to install 8.1 on Mac OS X

    The Appserver was released as part of the Netbeans or Java Creator bundles so let's get it from them !
    1. Go to Netbeans Homepage and download Netbeans 4.1, choose the bundled version with SJES Appserver 8.1
    2. double click on the jar file ;-)
    3. you should get this

      Installation Welcome Screen
    4. follow the instructions to install the bundle... make a note where you install the Netbeans bundle

      Choose installation directory
    5. strolling along... remember to choose the right JDK in case you have more than one installed...


    Once finished with the installation. you can go to /Users/JohnDoe/Applications/ or wherever you have installed your Netbeans bundle, this is the standard installation of your application server.

    you can go to the bin directory and do
        asadmin start-domain

    you can also look at the startup log, see below the end of the startup procedure !


    et Voila !
    , , , ,



    « April 2014