Skip to Content

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

java.lang.ClassCastException: com.sap.security.um.provider.neo.local.UserProviderImpl cannot be cast to com.sap.security.um.user.UserProvider

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 com.sap.security.um.user.UserManagementAccessor I always get a "User Management is not initialized" exception

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

Thanks,

Chris

replied

OK got it!

problem is that maven dependency

    <dependency>

      <groupId>com.sap.cloud</groupId>

      <artifactId>neo-java-web-api</artifactId>

      <version>2.15.7.3</version>

      <scope>provided</scope>

    </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

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