How to determine the Buildversion of a webapplication out of a JAR Manifest file

Another Post because I need this code snippet sometimes and don’t want to search the whole internet every time. The following code snippet opens the Manifest file an reads the Implementation properties:

	public String getBuildVersion() {

		FacesContext facesContext = FacesContext.getCurrentInstance();

		if (facesContext != null) {
			if (facesContext.getExternalContext().getContext() instanceof ServletContext) {
				ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();

				if (servletContext != null) {

					Properties prop = new Properties();
					try {
					} catch (IOException e) {
						String msg = "Could not read the MANIFEST.MF for getting the VersionInfo";
						LOG.error(msg, e);
						return msg;

					String implementationTitle = prop.getProperty("Implementation-Title");
					String implementationVendor = prop.getProperty("Implementation-Vendor");
					String implementationVersion = prop.getProperty("Implementation-Version");

					return implementationTitle + " Build-Id:" + implementationVersion + " by:" + implementationVendor;

		return "Unable to determine Softwareversion";



Custom Loginpage with SpringSecurity 3, JSF2 and Facelets

These days I tried to integrate a custom login page into my Web Application. I found a lot of hints in the Web
using a a plain form tag for the Login page but nothing was working and I always got a errors like “No navigation case match for viewId action j_spring_security_check and outcome…” I didn’t get it work by using the j_security_check mechanism, therefore I used a custom bean and controller.

Here is the solution:

my web.xml:



the applicationContext.xml:

        <bean scope="session" id="loginBean" class="">
		<aop:scoped-proxy />
	<bean scope="singleton" id="loginController"
		<property name="loginBean" ref="loginBean" />
		<property name="authenticationManager" ref="authenticationManager" />

the applicationContext-Security.xml:

	<sec:http auto-config='true' use-expressions="true">

		<sec:intercept-url pattern="/xhtml/loggedout.xhtml" access="permitAll" />
		<sec:intercept-url pattern="/xhtml/timeout.xhtml" access="permitAll" />
		<sec:intercept-url pattern="/xhtml/login.xhtml" access="permitAll" />
		<sec:intercept-url pattern="/xhtml/**" access="isAuthenticated()" />
		<sec:form-login login-page="/xhtml/login.xhtml"  />

	<!-- AuthenticationManager - add your User-Service-->
	<authentication-manager alias="authenticationManager">
		<authentication-provider user-service-ref="XXXXXX">
			<password-encoder hash="md5" />

the Form: /xhtml/login.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns=""

<my:myMainTemplate title="Login" class="mainContent" >
       <h:form id="loginForm" prependId="false">
            <h:panelGrid columns="2">  
                <h:outputLabel for="j_username" value="User: " />  
                <h:inputText id="j_username" value="#{loginBean.userName}" required="true" requiredMessage="Username !"/>  
                <h:outputLabel for="j_password" value="Password: " />  
                <h:inputSecret id="j_password" value="#{loginBean.password}" required="true" requiredMessage="Passwort !"/>  
				<h:commandButton id="submitButton" value="Start" action="#{loginController.login}" />  

my beans –


public class LoginBean  implements Serializable{

	private static final long serialVersionUID = 6175255537226165236L;

	private String userName;
	private String password;
	public void reset(){
		userName = "";
		password = "";
... getter/setter...




import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

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

public class LoginController {
	private static final Log LOG = LogFactory.getLog(LoginController.class);

        // beans used by this controller, injected by spring
	private LoginBean loginBean;
	private AuthenticationManager authenticationManager;
	 * the login action called by the view
	 * @return
	public String login() {
		try{"Login started for User with Name: "+getLoginBean().getUserName());
		 // check if userdata is given 
		 if (getLoginBean().getUserName() == null || getLoginBean().getPassword() == null) {
	            FacesMessage facesMsg = new FacesMessage(
	            FacesMessage.SEVERITY_ERROR, "Error", "login.failed" );
	            FacesContext.getCurrentInstance().addMessage(null, facesMsg);
	  "Login not started because userName or Password is empty: "+getLoginBean().getUserName());
	            return null;
		 // authenticate afainst spring security
		 Authentication request = new UsernamePasswordAuthenticationToken(
				 getLoginBean().getUserName(), getLoginBean().getPassword());            
	        Authentication result = authenticationManager.authenticate(request);
	    } catch (AuthenticationException e) {"Login failed: " + e.getMessage());
	        FacesMessage facesMsg = new FacesMessage(
	            FacesMessage.SEVERITY_ERROR, "Error", "login.failed") ;
	        FacesContext.getCurrentInstance().addMessage(null, facesMsg);
	        return null;
	    return "success";

	 * @return the loginBean
	public LoginBean getLoginBean() {
		return loginBean;

	 * @param loginBean the loginBean to set
	public void setLoginBean(LoginBean loginBean) {
		this.loginBean = loginBean;

	 * @return the authenticationManager
	public AuthenticationManager getAuthenticationManager() {
		return authenticationManager;

	 * @param authenticationManager the authenticationManager to set
	public void setAuthenticationManager(AuthenticationManager authenticationManager) {
		this.authenticationManager = authenticationManager;

and Last but not least, add navigationRules to your