Skip to Content

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Jan 15, 2015 at 01:48 AM

    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!

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 14, 2015 at 05:04 AM

    pinging security guru @Martin Raepple to see if he has an answer...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 14, 2015 at 03:22 PM

    Are you packaging the app with the jar containing the class com.sap.security.um.provider.neo.local.UserProvider or is it available in the runtime ?

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 15, 2015 at 01:44 AM

    Interestingly when I run the application on HCP rather than locally, I get:

    HTTP Status 500 - Request processing failed; nested exception is java.lang.ClassCastException: class com.sap.security.um.provider.trust.internal.TrustUserProvider:java.net.URLClassLoader@2cdc7b4e incompatible with interface com.sap.security.um.user.UserProvider:WebappClassLoader

    my definition of the interface  com.sap.security.um.user.UserProvider is coming from the neo-java-web-api-2.15.7.3.jar which is pulled from my maven dependency. (as deployed to Maven Central)  - The Central Repository Search Engine

    seems like that version is incompatible with runtime versions?

    Add comment
    10|10000 characters needed characters exceeded