on 01-13-2015 2:34 AM
In attempting to read the user attributes as per:
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
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Exact same error in java web.
have the lines:
<resource-ref>
<res-ref-name>user/Provider</res-ref-name>
<res-type>com.sap.security.um.user.UserProvider</res-type>
</resource-ref>
in my web.xml
and referencing latest sdk in my pom.xml
<dependency> | |||
<groupId>com.sap.cloud</groupId> | |||
<artifactId>neo-java-web-api</artifactId> | |||
<version>${hcp.sdk.version}</version> | |||
</dependency |
<properties> | ||
<hcp.jdk.version>1.7</hcp.jdk.version> | ||
<hcp.sdk.version>2.15.7.3</hcp.sdk.version> | ||
<org.springframework-version>3.2.4.RELEASE</org.springframework-version> | ||
<org.springframework.data-version>1.3.0.RELEASE</org.springframework.data-version> | ||
<org.aspectj-version>1.6.9</org.aspectj-version> | ||
<org.apache.cxf-version>2.7.6</org.apache.cxf-version> | ||
<org.slf4j-version>1.7.2</org.slf4j-version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> |
perhaps the JDK version? although I can't see how that is going to cause an issue...
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.