Exception occurs when using Custom user integration

While using the custom user integration using JDBCUserProvider. Below is the code which throws a UnsupportedOperationException which is never caught.

public User createUser(String username, String password, String name, String email)
     throws UserAlreadyExistsException {
     // Reject the operation since the provider is read-only
     throw new UnsupportedOperationException();
}

For the purpose of chating the user details must be loaded as below.

public User createUser(String username, String password, String name, String email)
            throws UserAlreadyExistsException {
     User user = new User();
     try {
         user = loadUser(username);
     } catch (UserNotFoundException unfe) { }
     return user;
}

thanks,

vinay

Vinay, (funny seeing you here )

The JDBC user manager is readonly and if you note from the UserProvider interface which this implements

Creates a new user. This method should throw an UnsupportedOperationException if this operation is not supporte by the backend user store.
So the code changes you suggest may also need to take that into account with a check

if (isReadOnly()) throw UnsupportedOperationException;

I don’t know the historical reason why this provider was set to read-only. Note the loadUser() call you reference is a SQL select as well…so that would not create the user in the backend.