Build Number

One of the most important thing during the SDLC (for sure apart from the other stuff) is to keep control over deployed artifacts to all environments at any given time. Lack of control leads to chaos and generates a lot of extra work to the team, degrades throughput, morale and motivation. No need to even mention that arguments among team members regarding deployed features or fixes definitely do not contribute well to the team spirit.
One of the common approaches mitigating this risk is generating a build number to every single build fully automatically. Let’s take a look at how to accomplish this in common project set up – maven project build on build server e.g. TeamCIty. Sample web application follows.
Common place where to store such kind of info is MANIFEST.MF file. All kind of archives have this file located in /META-INF/MANIFEST.MF. Various technologies like OSGi use this location for various metadata. Taking advantage of maven-war-plugin the content of MANIFEST.MF can be easily customized as follows (${xx} are maven variables):
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: ${}
Build-Jdk: ${java.version}
Specification-Title: ${}
Specification-Version: ${project.version}
Specification-Vendor: ${}
Implementation-Title: ${}
Implementation-Version: ${project.version}
Implementation-Vendor-Id: ${project.groupId}
Implementation-Vendor: ${}

To set up a maven project pom file is pretty easy:


Where build.number variable gets supplied by build server in arbitrary format, e.g. for TeamCity build server:

Build number is visible in build queue status page as well:
To access these project build specific information simple jsp page can be created:
The controller accessing these information using Spring MVC (simplified example) can look like:
 public class ProjectInfoController {

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

         ModelAndView modelAndView = new ModelAndView("projectInfoView");

         ServletContext servletContext = request.getSession().getServletContext();

         Properties properties = new Properties();
         InputStream is = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF");



         return modelAndView;

Accessing MANIFEST.MF in JAR file has a different approach. Motivation taken from Spring source code:

Package  package = someClass.getPackage( );
String version = package.getImplementationVersion();

JSP page or other presentation layer shouldn’t be a problem for anyone.

Spring JAX-WS timeout

When building up a reliable predictable solution you need to manage a “response time” as one of the core principles. This is accomplished by implementing time out policy. You don’t wanna clients hanging on connection forever. Nowadays very common approach to integration is taking advantage of Spring framework.

Spring JAX-WS web service proxies (JaxWsPortProxyFactoryBean) doesn’t offer a direct possibility to set a service timeout via one of their properties. Following lines documents one of the possibilities how to cope with that requirement.

Java implementation:

public class AbstractJaxWsPortProxyFactoryBean extends JaxWsPortProxyFactoryBean {

    public static final int CONNECT_TIMEOUT = 2500;

    public void setTimeout(final int timeout) {
        // JAX WS
        addCustomProperty("", CONNECT_TIMEOUT);
        addCustomProperty("", timeout);
        // Sun JAX WS
        addCustomProperty("", CONNECT_TIMEOUT);
        addCustomProperty("", timeout);

    public void afterPropertiesSet() {

Spring configuration:

     <bean id="abstractWsClient" class="AbstractJaxWsPortProxyFactoryBean" abstract="true">
        <property name="timeout" value="10000"/>

    <bean id="LocalServiceBinding" parent="abstractWsClient">
        <property name="serviceInterface" value="cz.Sample.Example.ServiceInterface"/>
        <property name="wsdlDocumentUrl" value="classpath:ServiceInterface.wsdl"/>

        <property name="namespaceUri" value="http://cz/Sample/Example/ServiceInterface"/>

        <property name="serviceName" value="ServiceInterface"/>
        <property name="endpointAddress" value="${localservice.url}"/>
        <property name="timeout" value="${localservice.timeout}"/>
        <property name="username" value="${localservice.user}"/>
        <property name="password" value="${localservice.password}"/>