Updates from March, 2010 Toggle Comment Threads | Keyboard Shortcuts

  • Subinkrishna Gopi 2:57 pm on March 20, 2010 Permalink |
    Tags: , , serialization   

    Today’s read: How Java serialization works ! 

    Have you ever wondered what is happening behind the scenes of Java serialization ? If your answer is YES, this one is for you. This is a really good one. I will recommend all to read this.

    Read the article: http://www.javaworld.com/community/node/2915

    If you are interested in more details, you can read Sun’s Java object serialization specification. You can get the specification from here: http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf

  • Subinkrishna Gopi 12:53 am on January 22, 2010 Permalink |
    Tags: Book, Francesco Marchioni, , , packt publishing,   

    Book review – JBoss AS 5 Development 

    JBoss AS 5 Development
    Written by Francesco Marchioni 
    Published by Packt Publishing

    When I started reading this book my expectations were a little less as I was expecting a “1 + 1 = 2” kinda stuff! But after reading the very first chapter – Installing core components – I realized that this one is going to be different. The story in this book is very simple which even my 11 year old nephew can understand and enjoy. Yes, it’s indeed a story.

    The first three chapters tells us what JBoss is, from where to get it, how to install it, how to configure Eclipse & JBoss tools, the JBoss sub-systems, basic deployment configurations, the background story and a lot of things. It’s very detailed, simple. I had real fun reading it. Because we assume a lot of things which we think is right. These three chapters proved me wrong at many places.

    The following chapters deal more with EJB 3, JMS, JPA, Web Services, JBoss management, JBoss clustering & security. These chapters try to cover the basics as much as it can. It will be really helpful as the first step towards J2EE/JBoss.

    Okay, now it’s time for the final verdict.

    This book – with 400+ pages & 14 chapters – is very well written. This is for the common man. This book tells the whole story in the simplest possible way. This book tells us what all things we need to do to master JBoss. It may not help you in mastering JBoss, but can definitely show you a way with all possible sign boards, maps & guides.

    I really enjoyed reading this book. I am not an expert in JBoss, EJBs JPA or JTA, but a “modestly aware” coder. Yeah, this will be a first good step towards mastering the art 🙂

    What I liked about this book
    It’s very simple & well-organized.

    What I did not like about this book
    Lacks depth. I think the target audience is beginners & enthusiasts.

    So, do I recommend this?
    Yes. I do. It’s going to be an easy & good read.

    Check this link for more details.

    Useful links
    http://www.jboss.org/ – JBoss Home
    http://www.jboss.org/jbossas/downloads/ – JBoss downloads
    http://www.eclipse.org/ – Eclipse IDE Home
    http://www.eclipse.org/downloads/ – Eclipse downloads

  • Subinkrishna Gopi 3:26 pm on October 13, 2009 Permalink |
    Tags: , , , , , ,   

    How-to: Write web services using Axis2 (Part 2) 

    In my previous post I wrote about writing a web service provider using axis. But I did not mention a few things in that post.

    1. How to make the service accessible to the outside world
    2. How to write a Java client to avail the services

    1. How to make the service accessible to the outside world?

    As we are using the axis2.war as the way to deploy the services, we don’t really need to do anything. The deployment descriptor (web.xml) of axis2.war is equipped to handle it. But we need to make some URL mapping and stuffs like that.

    • Add appropriate URL-servlet mapping  in the web.xml
    • Add the name of the AAR in the service list

    a. Deployment descriptor changes:

       <display-name>Apache-Axis Servlet</display-name>

    b. Add the name of the AAR in WEB-INF/services/services.list.

    2. Writing a Java client to access the services

    We have several ways to create the client stubs – JiXB, ADB etc. I followed ADB – Axis Data Binding. Axis provides a WSDL2Java tool to create client stubs from an existing WSDL. We can get the WSDL from http://localhost/services/SampleWs?wsdl.

    WSDL2Java -uri SampleWs.wsdl -p subin.rnd.ws.client -d adb -s -o clientStubSrcDirectory_name

    This will create the stub in the specified directory with name SampleWsStub.java. Once the stub is ready, we can write a client module which tries to access the deployed services.


    package subin.rnd.ws.client;
    import subin.rnd.ws.client.SampleWsStub.WsInput;
    import subin.rnd.ws.client.SampleWsStub.WsOutput;
    public class WsClient
     public static void main(String[] args)
     throws Exception
       SampleWsStub stub = new SampleWsStub("http://localhost/services/SampleWs");
       // Send the request
       SampleWsStub.DoSomething request = new SampleWsStub.DoSomething();
       WsInput anInput = new WsInput();
       // Get the response
       SampleWsStub.DoSomethingResponse response = stub.doSomething(request);
       WsOutput anOutput = response.get_return();

    And that’s it !!!

  • Subinkrishna Gopi 3:45 pm on August 25, 2009 Permalink |
    Tags: , , , , , , ,   

    How-to: Write web services using Axis2 

    This is a very basic post on writing a web service provider and consumer using Axis2. You can find such posts anywhere in the web. Here I’ve tried to make it as simple as I can.

    Set up: What all we need to do?

    1. Axis2 runtime.
    I tried with WAR distribution from http://ws.apache.org/axis2/download/1_5/download.cgi
    2. A web/app server. I am using Tomcat.

    Using the Axis2 runtime & setting it up

    Extract the Axis2 WAR distribution and keep it in the deploy directory of the server. In case of Tomcat keep it in webapps. This is how my directory structure look like.


    The WEB-INF is the most important directory. Tell you why. Unlike our normal WEB-INF in archives, this directory hold some special sub-directories. Here goes which contains what.

    classes – compiled Java classes. We can find some Axis specific classes here.
    conf – axis.xml (Axis configuration file)
    lib – All necessary Axis2 libraries (JARs)
    modules – Don’t ask me. Even I’m not sure. Did I mention that I’m also a beginner? 🙂
    services – All web service archives & services.list

    Coding: What we need to write?

    1. The service provider. A Java class.
    2. service.xml. The web services descriptor.
    3. build.xml. To build and deploy the web services archive.
    4. The service consumer. Another Java class to consume the services offered

    And we are good to go now. Let’s make our hands dirty with some Java code. This is very simple and kudos to Axis2.

    The service provider: SampleService.java

    package subin.rnd.ws;
    public class SampleService
      public WsOutput doSomething(WsInput anInput)
        WsOutput anOutput = new WsOutput();
        anOutput.setResponseString("I did some thing to " + anInput.getName());
        return (anOutput);

    WsInput is a sample input class to demonstrate that we can have more complex IO is possible. Similarly WsOutput is the output class. Instead of using WsInput / WsOutput for IO, we can use normal data types like integer, float, string etc too.


    package subin.rnd.ws;
    import java.io.Serializable;
    public class WsInput implements Serializable
     private String name;
     public void setName(String name)
       this.name = name;
     public String getName()
       return (this.name);


    package subin.rnd.ws;
    import java.io.Serializable;
    public class WsOutput implements Serializable
     private String responseString;
     public void setResponseString(String response)
       this.responseString = response;
     public String getResponseString()
       return (this.responseString);

    We have the Java part of the web-service ready. But that’s not enough. We need to deploy the web-service as an AAR – Axis Archive – file. An AAR  is just another zip file (like a JAR) with a funky extension :D. The AAR should contain the class files along with the services.xml – web service descriptor.

    Web service descriptor: services.xml

    <service name="SampleWs" scope="application">
     <description>Subin's sample webs service</description>
     <messagereceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
     <messagereceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
     <operation name="doSomething" />
    <parameter name="ServiceClass">subin.rnd.ws.SampleService</parameter>

    The services.xml is the place where we define the details of the services being offered.

    Build file: build.xml

    <project name="my.webservice.test" default="build.aar">
    <property name="deploy.dir" value=".../webapps/axis2.war/WEB-INF/services" />
    <property name="file.name" value="subinws.aar" />
     <target name="build.aar">
       <javac srcdir="src" destdir="bin" />
       <echo>Copying services.xml to bin</echo>
       <copy file="META-INF/services.xml"
           tofile="bin/META-INF/services.xml" overwrite="true"/>
       <jar basedir="bin" destfile="${file.name}" />
       <echo>Deleting services.xml from bin</echo>
       <delete dir="bin/META-INF" />
       <copy file="${file.name}" tofile="${deploy.dir}/${file.name}"  />

    So I hope we have an AAR ready, which is copied to the services directory. But we’ve not done yet. Now we have to make an entry in services/services.list file. Just insert the name of the ARR file at the end of it – in this case “subinws.aar”.

    Please wait for part 2.

  • Subinkrishna Gopi 8:17 pm on August 2, 2009 Permalink |
    Tags: app engine, , free, , hosting, , , ,   

    An interesting find ! Google App Engine with Java support 


    I was just going through code.google.com, and just find a link titled “App Engine”. I was not at all surprised as they do this every time. With Google something is new every time. I went on reading. Oh God! Free J2EE app engine where we can host our archives ! This is one of the coolest things I was waiting to happen. The server where I hosted (and I’m still with them) my website does not have Java support and I spend many hours in writing Php codes after many hours of searching and testing, which I could have done in minutes with Java. And most importantly it’s almost FREE ! We have to pay them only if we are crossing the specified bandwidth & page view limits.

    We can write code with Google’s Eclipse plug-in (with GWT support !), test them with in Eclipse and deploy them from Eclipse! Isn’t that cool? All you need is to have a Google account and just get it done. We can have up to nine applications each with a unique URL to access and we can even link them with our Google Apps too.

    Check this video: Get an overview of App Engine’s new Java runtime and see a demo of a sample app from creation to deployment.

    URL: http://www.youtube.com/watch?v=P3GT4-m_6RQ

    • For me this is nicest offer from Google in the recent times. I don’t know whether all of you are going to agree with this. But at least I’m happy. Hope all of you will find it nice.

    Google App Engine: http://code.google.com/appengine/
    FAQ: http://code.google.com/appengine/kb/
    App Engine Blog: http://googleappengine.blogspot.com/
    Getting started: http://code.google.com/appengine/docs/java/gettingstarted/

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc