A Developers Perspective on Spring vs JavaEE

In Java community Spring vs JavaEE is a never ending debate. In such debates people form two groups consisting of evangelists, architects and hard core fans of one platform and debate endlessly. Those who participate in the debates may be architects who are responsible for platform selection. But what would developers think about this Spring vs JavaEE debate? I am a Java developer who uses both Spring and JavaEE and I am not part of Spring or JavaEE fan club. Here I would like to share my own thoughts on this epic Spring vs JavaEE debate. 1. Business(sometimes political) AspectsIn

Continue reading »

Solution for JDK6 + JBoss-5.1.0GA + JAX-WS integration error: java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage

1.     Copy the following jars from JBOSS_HOME/client to JBOSS_HOME/lib/endorsed dir.        a.     jbossws-native-jaxrpc.jar        b.     jbossws-native-jaxws.jar        c.     jbossws-native-jaxws-ext.jar        d.     jbossws-native-saaj.jar 2.     Delete saaj-impl.jar(if its already there) from JBOSS_HOME/lib/endorsed dir.

Continue reading »

Developing WebServices using JDK6/JAX-WS is simple. Is it true?

In many articles, blogs we can see how to develop WebServices using with JDK6’s JAX-WS in-built support in just 5 minutes. We can simply write a POJO and annotate it with @WebService, publish it with Endpoint.publish(…) and you can see the generated wsdl by pointing your browser to http://localhost:8080/JAXWS/helloService?wsdl. Immediately we can write a client and call helloPort.sayHello(“siva”) and you will get “Hello Siva!!!” response from your HelloWebService. In the first look it feels like developing web services is very simple using JDK6’s in-built JAX-WS support. With that confidence immediately I thought of writing a bit more complex WebService and

Continue reading »

Deploying JAX-WS WebService on Tomcat-6

Now we are going to see how to deploy JAX-WS WebService on Tomcat Server.We are going to deploy The AuthenticationService developed in http://sivalabs.blogspot.com/2011/09/developing-webservices-using-jax-ws.html on apache-tomcat-6.0.32. To deploy our AuthenticationService we need to add the following configuration. 1.web.xml <web-app> <listener> <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class> </listener> <servlet> <servlet-name>authenticationService</servlet-name> <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>authenticationService</servlet-name> <url-pattern>/services/AuthenticationService</url-pattern> </servlet-mapping></web-app> 2. Create a new file WEB-INF/sun-jax-ws.xml <?xml version="1.0" encoding="UTF-8"?><endpoints  xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"  version="2.0">    <endpoint      name="AuthenticationService"      implementation="com.sivalabs.caas.services.AuthenticationServiceImpl"      url-pattern="/services/AuthenticationService"/>      </endpoints> 3. Download the JAX-WS Reference Implementation from http://jax-ws.java.net/Copy all the jar files from jaxws-ri/lib folder to WEB-INF/lib. Now deploy the application on Tomcat server.You don’t need to publish the Service by our-self as we did using EndpointPublisher.Once the tomcat is up and running

Continue reading »

Developing WebServices using JAX-WS

Let us assume an enterprise is maintaining user authentication details in a centralized system. We need to create an AuthenticationService which will take credentials, validate them and return the status. The rest of the applications will use the AuthenticationService to authenticate the Users. Create AuthenticationService interface as follows: package com.sivalabs.caas.services;import javax.jws.WebService;import com.sivalabs.caas.domain.AuthenticationStatus;import com.sivalabs.caas.domain.Credentials;import com.sivalabs.caas.exceptions.AuthenticationServiceException;@WebServicepublic interface AuthenticationService{public AuthenticationStatus authenticate(Credentials credentials) throws AuthenticationServiceException;} package com.sivalabs.caas.domain;/** * @author siva * */public class Credentials { private String userName; private String password; public Credentials() { } public Credentials(String userName, String password) { super(); this.userName = userName; this.password = password; } //setters and getters } package

Continue reading »

CustomTag to generate and tags with absolute path

Generally we write our javascript and css styles in separate file and include them in JSPs using <script> and <style> tags. To include those resource we can use either relative URL or absolute URL. If you use absolute URL you need to include the context root name which is not a good practice. Later if you want to change the context root name you need to update in several places. If you use relative URL you may need to prefix the path with ../ or ../../ depending on your current URL which tedious process. To get rid of this problem

Continue reading »

When to use RequestDispatcher.forward() and response.sendRedirect()?

Many people know about how RequestDispatcher.forward() and response.sendRedirect() works. RequestDispatcher.forward() is generally called Server side redirection and is used to forward to a resource within the same application. That resource could be a JSP or another Servlet. response.sendRedirect() is generally called as Client side redirection as it issues a new request from the browser. This method is used to redirect to another resource within the same application or to the resource in some other application running in the same web container or can redirect to any other resource running in someother web container. There is one more important thing to

Continue reading »

PrimeFaces QuickStart Tutorial-Part1

PrimeFaces is an open source component library for JSF 2.0 with morethan 100 rich components. PrimeFaces is far better than many other JSF component libraries because of the following reasons:     1. Rich set of UI components (DataTable, AutoComplete, HtmlEditor, Charts etc).    2. No extra xml configuration is required and there is no required dependencies.    3. Built-in Ajax based on standard JSF 2.0 Ajax APIs.    4. Skinning Framework with 25+ built-in themes.    5. Awesome documentation with code examples.    Let us build a sample application using PrimeFaces with the following features:1. A Login screen which accepts username and password and authenticate

Continue reading »

Struts1 Vs Struts2 Vs JSF Vs SpringMVC

Hi, Recently I have done some research on J2EE Web frameworks usability and features to decide the framework to be used for one of my new projects.I consider Struts 1, Struts2, JSF and Spring MVC. After spending some hours on going through each of the frameworks features and some more hours to do a simple application(Proof Of Concept).In this process i was excited looking at some of the features, become a fan of one of the frameworks, felt home sick to leave my all time favourite framework and irritated with some of the frameworks. Struts1: This is my all time

Continue reading »