Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

java.lang.ClassCastException: cannot be cast to

In attempting to read the user attributes  as per:

SAP HANA Cloud Platform

I get a cast exception. it seems that the local UserProvider is not compatible with the general definition (is not a subclass)

  private String determineUserAttribute(HttpServletRequest request, String userName, String attributeName) {

  String attributeValue = "";

  try {

  InitialContext ctx = new InitialContext();

  Object userProvider;

  userProvider = ctx.lookup("java:comp/env/user/Provider");

  UserProvider usrProv = (UserProvider) userProvider;

  attributeValue = usrProv.getUser(request.getRemoteUser()).getAttribute("firstname");

  } catch (UnsupportedUserAttributeException e) {

  logger.error("UnsupportedUserException", e);

  } catch (PersistenceException e) {

  logger.error("PersistenceException", e);

  } catch (NamingException e) {

  logger.error("NamingException", e);


  return attributeValue;


any suggestions on how to proceed or what I might be missing?

Using I always get a "User Management is not initialized" exception

Is there a requirement to use the Java EE Web runtime?




OK got it!

problem is that maven dependency







needs to have the scope "provided" so that it doesn't get packed in the deployable and the runtime version of that api is provided by the platform not my application.

All working now!

Thanks for help!

0 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question