Monday Mar 26, 2007

First GlassFish v3 screencast

I took some time off coding to do a screencast on GlassFish v3, this should be interesting to many. GlassFish V3 started for me a few months back with the creation of the v3 cvs branch and since then, I have been happily coding some experimental pre-work.

Today, GlassFish v3 which will be a modular application server has reached a milestone. It supports four types of container :

  • Standard Web Applications
  • Ruby on Rails using JRuby 0.9.8
  • Phobos
  • PHP using the Quercus engine.

Startup time is under 1s (about 900 ms) on my MacBook pro, I am officially opening a competition on who can provide me with the best startup number using a commercially available processor...

But a good screencast is better than words so watch it, enjoy it, forward it but more importantly, talk to me about it if you have any feedback.

GlassFish v3 first screencast

As a reminder all the code you see demonstrated in the screencast is available today in cvs, if you are interested developing this outstanding application server, contact us !

Thursday Mar 09, 2006

GlassFish is Universal

Today, we are gathered to celebrate a new achievement of the GlassFish community.

After being used by a vibrant community around the world, GlassFish is the first application server officially adopted by Aliens. We are now Universal

The delegate from the Meelaneese race, a mate called "Robertoch Inni Ci" (nicely pictured here) has signed an extensive agreement to use and enhance the GlassFish Project.

You can learn more from our new GlassFisher friend from his blog, and although he talks about moons, his actual planet location remains a mystery.
Ok le'ts be serious for minute. Starting with build 40, the two native binaries used by the application server are now universal binaries which mean they run on PowerPC as well as the new exciting Intel based Macs.

Here are my findings and adventures on how to transition your JNI libraries to universal binaries.
One of these native component, the libcliutil.jnilib which is a JNI library used to implement one function so we don't echo the password when using the asadmin command in interactive mode. The other component, called the native launcher was used in 8.x to launch the application server with the right JVM parameters. It has since then been replaced with a Java Launcher but we keep this version for backward compatibility reasons.

The changes to support cross compilation were actually not that easy to find, the reason being that Apple's documentation (although being very nicely written and presented) rely too much on XCode to build your native binaries. Well, some folks still want to use good old makefiles to build their software and that was not easy to find the appropriate gcc flags :

-arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk

The -isysroot is very important when you use a PowerPC based Mac since they have the universal and PPC SDKs installed. With an Intel Mac, you only have the universal installed or at least it is the default one. If you do not add this option, you will get this kind of exception :

/usr/lib/libSystem.B.dylib does not contain an architecture that matches the specified -arch flag: i386

Now you may think that I am lucky to own all this Apple hardware, and indeed, my wife works at Apple afterall :).

This time however, I didn't get to own the Intel iMac I used to change the makefiles, I got the machine from James Gosling who was kind enough to lend me his iMac for some time so I could do this. And that machine (entry level 17inch iMac) really suprised me how fast it was. I am ready to trade my dual PowerMac G5 for those anytime !

I just wished that working on James Gosling's machine made me smarter... well that's a totally different story !

Tuesday Feb 21, 2006

Project GlassFish spins out a beta !

Rejoice !

This is a important day for the GlassFish community. Today, we officially released the Sun Java System Application Server 9.0 Beta which is based on the GlassFish project. Already confused with all these products terminology, I am with you, we could hardly have made it more complicated if we had really tried but consult Tony's wisdom, he will enlighten why everything has a place in the Sun (ah, I could not resist that one).

So what is the fuss about yet another beta... Well, first this is the first beta based on the GlassFish Open Source project, this is therefore the result of hundreds of developers working for at least 2 years. More importantly, this is the first beta of a Java EE 5.0 Application Server.

We worked with the specifications writers for two years to make the developer experience the center of all new features. For me, it really all started with a meeting every Monday evening at 4pm with me, Roberto Chinnici, Bill Shannon and Linda DeMichiel to resolve one of the most hated feature of J2EE 1.4 : XML deployment descriptors. The meeting was let's say always lively...

The first intimidating steps was JavaOne 2005, where Bill presented Java EE 5 during the technical keynote followed my own session to present the current state of affairs. After Abhijit's retirement, I became the GlassFish architect which is really a pompous title to say I am taking care of the stability and the future of the implementation.

We received very positive feedback during JavaOne and continued to work hard to push the specifications and the implementation to beta quality. But let's look at what is new to get you started with Java EE 5 :

  • AJAX : Java EE 5 with Java Server Faces has all the qualities to accomodate the specific requirements of an AJAXified application. Consult our local expert Greg Murray in this interview or the Aquarium page
  • JSF : Talking about JSF, you need to go check Ed's blog for the latest news on the web tier.
  • Persistence : A new persistence API based on Plain Old Java Objects (POJO) has been worked on by Linda and Mike Keith. This API will be available in Java SE as well as Java EE environments. I recommend you follow Sahoo's blogpage for tips and details on how to use this new technology. or the Aquarium persistence
  • EJB3 : The persistence APIs being separated from the EJBs definition will give a new life to this component model : simplified, lean and powerful, the new EJBs should be considered for all back end tasks. Look at Ken's samples, they are a great way to get you up to speed.
  • JAX-WS : the JAX-RPC APIs have came and gone. There were numerous issues with their evolution or ease of use, Roberto Chinnici came up with a new API for Web Services. Of course, Dhiru updated the JSR 109 to include such technologies in the Java EE environment. Go to my blog or to Vijay's blog to details and tricks on web services.
  •  JAXB, StaX and other XML goodies. There are plenty of web resources on how to use XML apis in Java, but I have to recommend the prolific Kohsuke's  train of thoughts

But wait, if you think we stopped at just implementing the specifications, heck no, we also have a full list of product features that will make your experience with our application server easy and complete.

  • Grizzly connector : check Jean Francois's blog on the optimized HTTP path we have in SJS Application Server.
  • Tools integration : we have plugins ! That's right, whether you use NetBeans 5.0 or better NetBeans 5.5 preview, they integrate with GlassFish. That's not all, you like Eclipse, we support that too. Ludo and Vince both maintain active blogs that talk about tools.
  • Admin framework : all administrative tasks of the application server can be done either through a CLI command, an API, or the admin GUI. One reference for administration : Kedar.
  • Web Services : there is life beyong basic web services. First for performance related information, FastInfoset is what you are looking for, Paul has also a blog to get you started. Then there is JBI with this how-to. Also remember to check WebServices Management with this tip
  • Deployment : from autodeploy to Java Web Start, deployment is faster than ever and packed with features, start with Tim's blog.

And we have documentation too, check the download page for the update SJS Application Server 9.0 documentation.

Well that's it, I hope I got you all excited about this new beta, one last thing, there is where you can download it. Please use it, write your ideas and experiences to the beta forum (user forum) or the GlassFish forum (more developer centric). We are looking for your feedbacks.

Wednesday Feb 15, 2006

GlassFish with Mustang


  No I am not playing with genetics to mix horses and fish DNA... I am just going to explain how to run the GlassFish application server with Mustang which is the JDK 1.6 codename.


The Beta2 of the Java SE 6 was released today. This is an exiting release, especially for folks like me who were never impressed with how previous JDK displayed fonts or obeyed to the native platform look and feel. Now when you install JDK 1.6, you get the native look and feel and font antialiasing. This makes Java applications look as neat as any other native applications now !     
Download the Java SE 6 beta from there and take the Glassfish bits. You can either take the beta or the active development version from the download page. I am on Solaris 10 running on one of these awsome AMD machine but the following intructions should be easily transferable to Windows.

I installed the JDK bits in /Users/applications/jdk1.6.0, let's check my installation and set my environment to use JDK 1.6
-bash-3.00$ which java
/usr/bin/java
-bash-3.00$ export JAVA_HOME=/Users/applications/jdk1.6.0
-bash-3.00$ $JAVA_HOME/bin/java -version
java version "1.6.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta-b59g)
Java HotSpot(TM) Client VM (build 1.6.0-beta-b59g, mixed mode)

Ok, we are all set on the JDK side (you could also update your PATH but that's not necessary), now I am going to install the GlassFish bits in say ~dochez/glassfish.
-bash-3.00$ java -Xmx250m -jar~/Desktop/glassfish-installer-9.0-b32g.jar 
-bash-3.00$ cd glassfish/
-bash-3.00$ ant -f setup.xml
Buildfile: setup.xml
....
validate-java:
     [echo] Current Java Version1.6.0-beta
....

That's it, pretty simple.

Now how can you change the version of the JDK used when you have already installed GlassFish. That's equally simple. The JDK path is stored in one location : <GlassFish_home>/config/asenv.conf
AS_JAVA="/Users/applications/jdk1.6.0"
you can replace this value with another path (as long as it is at least JDK 1.5) to play with different JDKs.


Friday Jan 27, 2006

Spring and Hibernate in GlassFish

Few days back, Matt Raible complained in his blog that Spring and Hibernate do not work in GlassFish. Being the GlassFish architect, he sparkled my interest ;-) Since I am always in for a good technical challenge, I decided to prove him wrong :

Part 1 : Spring

Here I am going to demonstrate the following :
    - how to get the Spring binaries
    - how to install them in the application
    - demonstrate how the Spring tutorial can work with the GlassFish/Spring combination.

First of all, go to the Spring website and download the latest version 1.2.6, I chose the fat download with all bunch of dependency jar files you will probably never need but at least, you are sure to have what you need.

Now, as I mentioned, I decided to try to run the Tutorial application which is also found on the Spring website. This is the link to the original tutorial, find below the updated instructions targeted to GlassFish, you will still need to reference the original article as I don't repeat everything...

Also, because I am not a big fan of complicated build scripts and being naturally lazy, I decided to use Netbeans 5.0 as my development tool. You can adapt the tutorial scripts to work with GlassFish if you prefer command line interfaces. Also, GlassFish has a plug in for Eclipse so you should be able to easily translate this effort for Eclipse (and maybe post the instructions as a comment...)

Next thing to do, go get yourself the NetBeans 5.0 RC2 and install it. Once you have done that, go get the latest GlassFish build, here I am using Build35. Install it in say $home/glassfish :

simplified instructions to install glassfish :

    jar -Xmx256m -jar glassfish<>.jar
    cd glassfish
    ant -f setup.xml

Now reading from the Spring tutorial steps, all you need to make your  Spring app work are three files located in the unzipped distribution we downloaded earlier
  • dist/spring.jar
  • lib/jakarta-commons/commons-logging.jar
  • lib/log4j/log4j-1.2.9.jar
To simplify things, I will make Spring available to the entire application server installation, which mean that all domains will have access to it and applications will not be required to bundle these jars inside their war files.

To do that, just copy the above three files in your glassfish installation lib directory ($home/glassfish/lib) and you are done ! I will explain later how you can actually restrict this to a particular domain or even a particular application.

So now you can start NetBeans 5.0 and add the Glassfish server to it :Tools Menu, Server Manager, Add Server

Adding a server to NetBeans 5.0

Once you have added the server to NetBeans, you can actually start GlassFish.

Now let's build our first Spring application ! The Spring Tutorial steps1 to 4 is just about building a simple WebApplication with a .jsp file. In NetBeans, it is very easy to do that in a couple of clicks  :
  1. From the file menu, choose "New Project"
  2. Choose Web Category
  3. Choose Web Application, Click Next
  4. Call you new project springapp, ensure that "Sun Java System Application Server" is the targeted server
  5. Click Finish
Select Web Pages, right-click and add a new JSP hello.jsp with this content :

      
<html>
<head><title>Example :: Spring Application</title></head>
<body>
<h1>Example - Spring Application</h1>
<p>This is my test.</p>
</body>
</html>
Now you have your project opened,  From the Run Menu, select "Run Main Project" you should see your browser showing you a "Hello World" type of page if you browse index.jsp (given by Netbeans for free) or hello.jsp

At this point you are done with step 1 to 5 of the Spring Tutorial, without typing a line of code or script...

On to Step 6, add the following
 <servlet>
<servlet-name>springapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>springapp</servlet-name>
<url-pattern>\*.htm</url-pattern>
</servlet-mapping>
to your WEB-INF/web.xml, you can either use the nice UI or you can select XML category on top of your editor to have direct access to the XML content.

Adding the servlet to the XML

Step 7, add you springapp-servlet.xml to the WEB-INF directory

Step 8, add the SpringappController java class to the "Source Packages" category of your project.

Now your IDE should look like this
complete project

Something interesting here : With red underlining, NetBeans is telling you that the first two imports are illegal and that's because NetBeans does not know anything about the Spring Framework. Let's fix that :
  1. Tools menu, select Library Manager
  2. Add a new Library, call it "Spring"
  3. Add the 3 Jars we copied to $home/glassfish/lib
Done with adding the new Library, now change your project properties to add the new Spring library...
  1. Right click on your "springapp"
  2. Select Librairies, Add Library
  3. Select Spring Library from the list
Now when netBeans is done scanning the new jar, those red lines under the import statements should disappear...
Time to rebuild and deploy to check we are right on course with Step 11.

Step 12 : create a view
From the "Web Pages" sub element of your springapp project, select "new" and in the wizard, select "other" and "empty file", call this new file "hello.jsp"

<html>
<head><title>Example :: Spring Application</title></head>
<body>
<h1>Hello - Spring Application</h1>
<p>Greetings.</p>
</body>
</html>
Change the controller to now handle this new view :

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class SpringappController implements Controller {

/\*\* Logger for this class and subclasses \*/
protected final Log logger = LogFactory.getLog(getClass());

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

logger.info("SpringappController - returning hello view");

return new ModelAndView("hello.jsp");
}
}

Run the project and you should get something like this when browsing http://localhost:8080/springapp/hello.htm

successful running


On to Step 13, there is a mistake in the Spring Framework tutorial, It specifies that you need to change the include.jsp like this
<%@ page session="false"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
In fact, it should be
<%@ page session="false"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
Otherwise you can basically continue until step 16 and get the same results...

Ok, I think I have made my point : Spring runs unmodified in the unmodified GlassFish freshly downloaded from our web site.

Part 2 : Hibernate

For hibernate, things are a little more complicated depending on what youwant to do :
  • Use Hibernate APIs from a EJB Session bean, this is working since Sun Java System Application Server 8.1 and well documented here
    This integration is however far from complete as far as the TransactionManager is concerned  
  • Use Hibernate as an EJB3 Persistence Provider :
    This is not easy to make it work but doable, I have been working with Emanuel Bernard (ah.. the french connection, always easier) to get this done and he will be updating his wiki page with steps. The reason why this is not easily working is that both products are in active development and the windows for integration are not always overlapping. This will get resolved in the next day or so and I will publish a new blog. Today, what you have to do is described in another Hibernate wiki.
So running Hibernate in GlassFish is today difficult, granted but we are working hard to change this and you should hear soon when the integration will be completed. Now remember that we have a persistence provider in GlassFish (TopLink) which will allow you to start working with Spring+EJB3 Persistence. You may not have the persistence provider you want today but Emmanuel and I will ensure that we will provide a easy solution very soon. You can also follow Sahoo's blog for updated information.

Conclusion

Well, in all honesty, Matt had asked for some help on the glassfish forum and he did not get a satisfying answer which probably led him to believe that it just does not work but I hope I have dismissed all misunderstandings, we support Spring and Hibernate, we will work closely with all willing Open Source communities to integrate each others technologies. Finally, I hope that we will get more and more folks excited about GlassFish.

Post Script-um :

In his attempt to run Spring in the GlassFish application server, Matt got into trouble with the SecurityManager. What he did was probably to cobundle the Spring archives within his war files. I know some folks love to do that, but honestly this is not the right way of integrating framework libraries in any application server. My approach described above made the framework available to all the deployed applications. If you want to restrict its availability to a particular domain, just copy the 3 jars files in your domain/lib directory (like$user/glassfish/domains/domain1/lib) and edit your server.policy to not get into the same issue than Tom :

grant codeBase "file:${com.sun.aas.installRoot}/domains/domain1/lib/spring.jar" {
        permission java.security.AllPermission;
};   

Same solution (with a different path) can be applied for jar files that are bundled within your war file, this is actually documented here.

Tuesday Jan 10, 2006

GlassFish runs JWSDP samples...again...

So I decided to revert the deployment check that we added in the GlassFish build32 reported by ias The issue was that we added a deployment check for pre-Java EE 5 applications to ensure that classes were not containing Java EE 5 annotations.

I decided to add the check because I anticipated that many folks would want to try the new cool features of Java EE 5 the cheap way : they would just take an existing J2EE 1.4 applications and add a couple of annotations to their sources to try injection. The result of such an experiment is always a NullPointerException since injection is not supported for pre-Java EE 5 applications. For injection to work, they also need to also update their deployment descriptor version to Java EE 5 so annotation processing can happen.

Well, little I knew that JWSDP 2.0 samples needed to run on top of the Application Server 8.1 (with the updated JWSDP bits), therefore that's exactly what they wanted : J2EE 1.4 xml and annotations...

As it turns out, they are using JSR 181 annotations which only their runtime would interpret. Well, JSR 181 being part of Java EE 5, we flagged those and failed deployment.

Here goes my safeguard idea...

So we could still do it, making a small exception case for JSR 181 annotations (since they are optional in J2EE 1.4). However, we also found out that doing this check has a deployment time cost (about 10% performance degradation for pre Java EE 5 applications) but can be turned off if necessary.

Should we do it ?

I would like to hear from the community...

Thursday Dec 08, 2005

Ecto and other blog clients

Ok I am so tired of the web interface of blogger, I have decided to give a try to the blogger clients. this is my first post from ecto on OS X, let's see how it goes. Right, it worked, excellent, I am going to blog a lot more often

Tuesday Oct 04, 2005

Dead Can Dance

I finally realized a long dream, I went to see Dead Can Dance live in Oakland. It has been about 18 years ago that I discovered then with the help of my friend, Christian Conti, aka Looping. They splitted but then reunified and went on a tour. Few people know them and it always baffles me. This group have made some of the most innovative music I have ever heard. They are composed of 2 main members, Lisa Gerrard and Brendan Perry. Lisa has enjoyed a lot of success lately since she started her solo career mainly with the help of hollywood.
Look at all the movie she provided the soundtrack for :

http://www.imdb.com/name/nm0314713/

You probably remember her songs in Gladiator or in the magnificient movie "The whale rider".

I have always been touched by her voice, their music in absolutely outstanding and nothing is remotely close to them. If you like Enya, and classical music, you will for sure enjoy them.

I recommend all their albums, although I have to say that her last Solo "Immortal Memory" is fantastic.

It was such a great evening, my wife was absolutely astonished how good they are, and that made me so glad since unlike me, she understands music. She graduated from the conservatory and can play Chopin like I program Java which makes me quite jealous ;-)

We left the theater so excited, that was truely a steal at 45$ to see such artists. I would have easily spent twice the amount. If you do not know Dead Can Dance or Lisa Gerrard, try to listen to them, rent "The  Whale Rider", it's a beautiful movie with a beautiful music. Get touched by the humanity of that little girl struggling with her father, it's only 4$ at blockbuster, and almost free on Netflix ;-)

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 !

  • Saturday Sep 10, 2005

    The Constant Gardener

    Last week end, I went to see the movie titled "The Constant Gardener" and I want to highly recommend this feature to everyone. I will not talk about the story in details but to introduce the rest of my blog, I am forced to mention that the movie is about poor neighborhoods of Nigeria, where local citizens are used as guinea pigs by British pharmaceutical companies for their new medication human trials. Now as I was leaving silently the theater, among weeping women and embarrassed men that were starting to think that upgrading their mercedes might not be that urgent after all, I came to question myself... what a great english movie. right, the main actors, the theme, the companies, all British and then it came to me so violently : Why do Hollywood never produce such movies ? Such movies can raise awareness of the common people so far more than books, tv adds or such. Why is it acceptable that Hollywood make such great movie on the Holocaust but nothing of the troubling subjects of our time. But of course, you will tell me that indeed some innovative movies come out from US studios that do tackle various difficult society issues, I have to question why those movies stay as innovative or distributed by sub channels (like Fox searchlight and others). Why don't they use their most famous actors, their best directors to once in a while do an expensive movie that carry more humanity than the Wedding Crashers (nothing personal, I am sure it's funny). As America discover that we have left the poor behind in the south to face the consequences of Katrina, we do not like to see what we see on CNN. As we discover that our backyard is not that safe, we need to all raise from our couches and start thinking that maybe living in a world of permanent brainless entertainment is transforming us into ignorants of the real matters of our planet. One of the thing I really love at my work, at Sun, is the permanent questions we live in while working. Why, Why not ? Why doing things this way, why not doing things differently... Right, I wished I could extrapolate those practices in my everyday life to continue question myself on the path our society is taking us. I do it today, but will I do it tomorrow, and what is depressing, I feel alone doing it...

    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;

    @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/jaxrpc-impl.java:$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 {

            @WebServiceRef
            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) {
                    e.printStackTrace();
                }
           }
    }

    Conclusion

    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 http://glassfish.dev.java.net.
    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 :

    JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home
    PATH=.:$JAVA_HOME/bin:$PATH

    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...

      foo

    Once finished with the installation. you can go to /Users/JohnDoe/Applications/NetBeans4.1.app/Contents/Resources/NetBeans/SunAppServer8.1 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 !

    log


    et Voila !
    , , , ,
    About

    dochez

    Search

    Categories
    Archives
    « April 2014
    SunMonTueWedThuFriSat
      
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
       
           
    Today