wso2/samples-is

The spring application try to create a bean for SAML2SSOManager .but throws class not found exception

jofisiva opened this issue · 3 comments

import org.wso2.carbon.identity.sso.agent.exception.SSOAgentException;
import org.wso2.carbon.identity.sso.agent.saml.SAML2SSOManager;
import org.wso2.carbon.identity.sso.agent.util.SSOAgentUtils;

/**
*
*/
@RestController
@RequestMapping("/saml")
public class SSORestController {

private static final XLogger LOGGER = XLoggerFactory.getXLogger(SSORestController.class);

@Autowired
public SAML2SSOManager saml2SSOManager;

@bean(name = "saml2SSOManager")
public SAML2SSOManager saml2SSOManager() {
try {
SSOAgentConfig ssoAgentConfig = this.ssoAgentConfig();
ssoAgentConfig.initConfig(this.samlProperties());

        return new SAML2SSOManager(ssoAgentConfig);
    } catch (Exception ex) {
        LOGGER.debug("SAML2SSOManager error " + ex.getMessage());
    }
    return null;
}

@Bean
public SSOAgentConfig ssoAgentConfig() {
    return new SSOAgentConfig();
}

@Bean
public Properties samlProperties() {
    try {
        return PropertiesLoaderUtils.loadProperties(new ClassPathResource("/config/travelocity.properties"));
    } catch (IOException ex) {
        LOGGER.info("Could not load properties from " + ex.getMessage());
    }
    return null;
}

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.wso2.carbon.identity.sso.agent.saml.SAML2SSOManager]: Factory method 'saml2SSOManager' threw exception; nested exception is java.lang.NoClassDefFoundError: org/wso2/carbon/user/api/UserStoreException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579)
... 35 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/wso2/carbon/user/api/UserStoreException
at com.aimia.aip.identity.config.AppServiceConfig.saml2SSOManager(AppServiceConfig.java:269)
at com.aimia.aip.identity.config.AppServiceConfig$$EnhancerBySpringCGLIB$$1eb8fcb9.CGLIB$saml2SSOManager$5()
at com.aimia.aip.identity.config.AppServiceConfig$$EnhancerBySpringCGLIB$$1eb8fcb9$$FastClassBySpringCGLIB$$8a5dee81.invoke()
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
at com.aimia.aip.identity.config.AppServiceConfig$$EnhancerBySpringCGLIB$$1eb8fcb9.saml2SSOManager()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 36 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.wso2.carbon.user.api.UserStoreException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 47 common frames omitted

Can you please mention which jar package to include in pom.xml ?

org.wso2.carbon.identity.agent.sso.java
org.wso2.carbon.identity.sso.agent
5.1.18


opensaml.wso2
opensaml2


commons-collections.wso2
commons-collections


Can you anyone please confirm what is the pom.xml entries for these three classes?

import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.core.UserStoreManager;

public class SAML2SSOManager {