Example usage for org.springframework.transaction CannotCreateTransactionException getMessage

List of usage examples for org.springframework.transaction CannotCreateTransactionException getMessage

Introduction

In this page you can find the example usage for org.springframework.transaction CannotCreateTransactionException getMessage.

Prototype

@Override
@Nullable
public String getMessage() 

Source Link

Document

Return the detail message, including the message from the nested exception if there is one.

Usage

From source file:org.atomsphere.management.authentication.UserDetailsServiceImpl.java

@Override
public UserDetails loadUserByUsername(String userName) throws AuthenticationException, DataAccessException {
    User user = null;/*from   w w w. ja  v  a2 s  .  c  o  m*/

    try {
        // Return member from DB and populate roles.
        user = (User) userService.getUserByUserName(userName);

        if (user == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("User name " + userName + " is missing in database !!!");
            }
            throw new BadCredentialsException(MessageSourceUtils.getMessage(authenticationMessageSource,
                    AuthenticationMessages.class, AuthenticationMessages.AUTHENTICATION_FAILED.name()));
        }

        user.setAuthorities(AuthenticationUtils.toGrantedAuthority((User) user));

        logger.trace("User: " + user.getUsername() + " grantedAuthorities: " + user.getAuthorities());
    } catch (CannotCreateTransactionException e) {

        logger.error("No connection to the database. Exception: " + e.getMessage());
        if (logger.isDebugEnabled()) {
            logger.debug("No connection to the database. Exception: " + e.getMessage(), e);
        }

        throw new NoDBConnectionException("No connection to the database. Exception: ", e);
    }
    return user;
}