Seam 3安全性无法在JBoss7自定义身份验证器类上找不到

时间:2013-03-29 06:00:31

标签: jboss7.x seam3

我一直在使用maven archetype(javaee6-jboss-ear)生成的ear项目在Jboss7.1.3中尝试seam3安全性,但我无法解决无法加载自定义类的错误。

Caused by: java.lang.ClassNotFoundException: com.czetsuya.javaee6.security.Authenticator from [Module "deployment.javaee6-demo.ear.javaee6-demo-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader]

我的项目结构如下: 我的项目 -耳 -jar(其中定义了beans.xml和authenticator) -war

My Authenticator类: 包com.czetsuya.javaee6.security;

import javax.enterprise.inject.Model; import javax.inject.Inject;

import org.jboss.seam.security.BaseAuthenticator; import org.jboss.seam.security.Credentials; import org.picketlink.idm.impl.api.PasswordCredential; import org.picketlink.idm.impl.api.model.SimpleUser;

@Model
public class Authenticator extends BaseAuthenticator {
    @Inject
    Credentials credentials;

    public Authenticator() { }

    @Override
    public void authenticate() {
        if ("demo".equals(credentials.getUsername())
                && credentials.getCredential() instanceof PasswordCredential
                && "demo".equals(((PasswordCredential) credentials.getCredential()).getValue())) {    
            setStatus(AuthenticationStatus.SUCCESS);
            setUser(new SimpleUser("demo"));    
        }    
    }    
}

我的beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:s="urn:java:ee" xmlns:security="urn:java:org.jboss.seam.security"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">

    <interceptors>
        <class>org.jboss.seam.security.SecurityInterceptor</class>
    </interceptors>

    <security:IdentityImpl>
        <s:modifies />
        <security:authenticatorClass>com.czetsuya.javaee6.security.Authenticator
        </security:authenticatorClass>
    </security:IdentityImpl>

</beans>

在myProject中,我定义了seam-bom:

<dependency>
    <groupId>org.jboss.seam</groupId>
    <artifactId>seam-bom</artifactId>
    <version>3.1.0.Final</version>
    <scope>import</scope>
    <type>pom</type>
</dependency>

在ejb / pom.xml中,我定义了seam-security:

<dependency>
    <groupId>org.jboss.seam.security</groupId>
    <artifactId>seam-security</artifactId>
    <scope>provided</scope>
</dependency>

提供了范围,否则我将收到编译问题:缺少类。

奇怪的是,当我部署战争项目时,同样的设置有效吗?我把战争放在耳边: - )

我也使用maven原型生成的耳朵做了同样的改动,我只添加了Authenticator和seam-security依赖。我遇到错误的项目的最大区别是我用javaee-api替换了大部分的jboss jar,因为它是标准的。而且我认为JBoss是标准的:-),似乎有一些神奇的东西再次发生在它自己的罐子里。

*工作的纯jboss项目在这里上传: https://code.google.com/p/czetsuya/source/browse/#svn%2Ftrunk%2Fjboss7-seam3-security

1 个答案:

答案 0 :(得分:0)

对我有用的是在war pom.xml中排除seam-security jar,如:

<dependency>
    <groupId>com.czetsuya</groupId>
    <artifactId>javaee7-ejb</artifactId>
    <type>ejb</type>
    <scope>provided</scope>
    <exclusions>
        <exclusion>
            <artifactId>seam-security</artifactId>
            <groupId>org.jboss.seam.security</groupId>
        </exclusion>
    </exclusions>
</dependency>