我有一个在JBoss 6.4 EAP上运行的Java EE应用程序并使用Spring Security。显然,所有Maven依赖项都已映射。但是,在加载无状态bean时,将显示以下消息:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'autenticacaoBO': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: ajg2/AutenticacaoBO -- service jboss.naming.context.java.app."ajg2-0.0.1-SNAPSHOT".ajg2.AutenticacaoBO
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) [spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
... 26 more
Caused by: javax.naming.NameNotFoundException: ajg2/AutenticacaoBO -- service jboss.naming.context.java.app."ajg2-0.0.1-SNAPSHOT".ajg2.AutenticacaoBO
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:174)
at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:245)
文件spring-security.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<jee:local-slsb id="autenticacaoBO" jndi-name="java:app/ajg2/AutenticacaoBO" business-interface="br.jus.ajg.bo.IAutenticacaoBO"/>
<bean id="appInternetAuthenticationProvider" class="br.jus.ajg.seguranca.AppInternetAuthenticationProvider">
<property name="autenticacaoBO" ref="autenticacaoBO"/>
</bean>
<bean id="appIntranetAuthenticationProvider" class="br.jus.ajg.seguranca.AppIntranetAuthenticationProvider">
<property name="autenticacaoBO" ref="autenticacaoBO"/>
</bean>
</beans>
文件AppInternetAuthenticationProvider.java:
package br.jus.ajg.seguranca;
import java.io.IOException;
import java.io.Serializable;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;
import br.jus.ajg.bo.IAutenticacaoBO;
import br.jus.ajg.modelo.Profissional;
import br.jus.ajg.util.VerifyRecaptcha;
@Component
public class AppInternetAuthenticationProvider implements AuthenticationProvider, Serializable {
private IAutenticacaoBO autenticacaoBO;
/**
* Este set é usado para injeção do EJB
*/
public void setAutenticacaoBO(IAutenticacaoBO autenticacaoBO) {
this.autenticacaoBO = autenticacaoBO;
}
public AppInternetAuthenticationProvider() {
}
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (!autenticacaoBO.isSistemaEmManutencao()) {
AppWebAuthenticationDetails webAuthDetail = (AppWebAuthenticationDetails) authentication.getDetails();
String gRecaptchaResponse = webAuthDetail.getRecaptcha_response();
boolean validouRecaptcha = false;
try {
validouRecaptcha = VerifyRecaptcha.verify(gRecaptchaResponse);
} catch (IOException e) {
new AuthenticationServiceException("Problema na validação do recaptcha", e);
}
if (validouRecaptcha) {
String login = authentication.getName();
String senha = authentication.getCredentials().toString();
String infoNavegador = ((AppWebAuthenticationDetails) authentication.getDetails()).getHeaderRequest();
Profissional p = autenticacaoBO.getProfissionalBO().autenticaProfissional(login, senha, infoNavegador);
if (p != null) {
return autenticacaoBO.geraTokenProfissional(p, senha);
} else {
throw new AuthenticationServiceException("CPF ou senha inválidos");
}
} else {
throw new AuthenticationServiceException("O desafio reCAPTCHA foi respondido incorretamente!");
}
} else {
throw new AuthenticationServiceException("Sistema em manutenção. Tente mais tarde.");
}
}
@Override
public boolean supports(Class<?> authentication) {
return authentication.equals(UsernamePasswordAuthenticationToken.class);
}
}
有人可以帮忙吗?
答案 0 :(得分:0)
谢谢帕维尔。事实上,我忘记了这个项目的原始开发者发送的提示。只需将项目库添加到&#39;打开laucnh配置的类路径选项卡中即可。 JBoss选项。
JBoss开始没有错误,应用程序正常运行。