WSO2版本5.0.0自定义用户存储管理器引发NoClassDefFoundError

时间:2015-09-29 08:24:14

标签: wso2 wso2is

我正在尝试在WSO2IS 5.0.0版中设置自定义主用户存储管理器。

基于WSO2IS 5.0.0版的文档,我必须扩展UserStoreManager:

import org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager;

public class CustomUserStoreManager extends JDBCUserStoreManager {
...

在user-mgmt.xml中,我更改UserStoreManager以引用此类:

<UserStoreManager class="com.abc.identity.CustomUserStoreManager">
...

在pom.xml中,我将其构建为一个包:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abc.asset</groupId>
<artifactId>asset-identity</artifactId>
<packaging>bundle</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>asset-identity</name>
<description>asset-identity</description>

<dependencies>
    <dependency>
        <groupId>org.wso2.carbon</groupId>
        <artifactId>org.wso2.carbon.identity.application.authentication.framework</artifactId>
        <version>4.2.7</version>
    </dependency>
    <dependency>
        <groupId>org.wso2.carbon</groupId>
        <artifactId>org.wso2.carbon.user.core</artifactId>
        <version>4.4.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>1.4.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.5.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Name>${project.artifactId}</Bundle-Name>
                    <Bundle-Version>0.0.1</Bundle-Version>
                    <Private-Package>com.abc.ecommerce.identity</Private-Package>
                    <Import-Package>
                        *
                    </Import-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

但是当我启动WSO2IS时,它会出现以下异常:

[2015-09-29 14:55:07,805] ERROR {org.wso2.carbon.user.core.common.DefaultRealm} -  Cannot create com.abc.identity.CustomUserStoreManager
java.lang.NoClassDefFoundError: org/wso2/carbon/user/core/jdbc/JDBCUserStoreManager

WSO2IS 5.0.0版的文档没有提供有关如何设置pom.xml的详细信息。

2 个答案:

答案 0 :(得分:1)

这个pom.xml可以解决NoClassDefFoundError异常。关键是要匹配WSO2IS 5.0.0附带的软件包版本。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abc.asset</groupId>
<artifactId>asset-identity</artifactId>
<packaging>bundle</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>asset-identity</name>
<description>asset-identity</description>

<dependencies>
    <dependency>
        <groupId>org.wso2.carbon</groupId>
        <artifactId>org.wso2.carbon.identity.application.authentication.framework</artifactId>
        <version>4.2.2</version>
    </dependency>
    <dependency>
        <groupId>org.wso2.carbon</groupId>
        <artifactId>org.wso2.carbon.user.core</artifactId>
        <version>4.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>1.4.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.5.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Name>${project.artifactId}</Bundle-Name>
                    <Bundle-Version>0.0.1</Bundle-Version>
                    <Export-Package>com.abc.asset.identity</Export-Package>
                    <Import-Package>
                        *
                    </Import-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>wso2-nexus</id>
        <name>WSO2 internal Repository</name>
        <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
        </releases>
    </repository>
</repositories>
</project>

答案 1 :(得分:0)

请尝试添加插件配置的导出部分

g1$WMA = ifelse ( (( as.numeric(as.character(g1$max_num) ) )> (N/2)), g1$max_res, g1$bdest)