2013-03-29 70 views
0

我一直在尝试seam3安全Jboss7.1.3与Maven原型生成耳项目(javaee6-jboss-ear),但我无法绕过错误其中我的自定义类无法加载。煤层3安全不工作JBoss7自定义鉴别器类没有找到

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] 

我的项目的结构为: myProject的 -ear -jar(其中的beans.xml和认证器被定义) -war

我的身份验证类: 包com.czetsuya.javaee6。安全;

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的,我已经定义缝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中,我定义了煤层的安全性:

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

范围提供,否则我会得到编译问题:缺少类。

奇怪的是,当我部署战争项目时,同样的设置工作,任何想法?我只是把这场战争放在耳朵里:-)

我也是这样做的,只需添加Authenticator和seam-security依赖关系。我遇到错误的项目最大的区别是我用javaee-api替换了大多数jboss jar,因为它是标准。我认为JBoss是标准的:-),似乎有一些神奇的事情发生在自己的罐子里。

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

回答

0

什么工作对我来说是不包括在战争pom.xml中缝安全罐子,喜欢的东西:

<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>