Vraptor3: Injeção de HttpServletRequest em componente [resolvido]

1 resposta
G

Tenho um bean qualquer que preciso ter o IP na inicialização do mesmo. Porém dá um erro indicando que não é possível injetar HttpServletRequest.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userSessionHolderInterceptor' 
defined in file [esim.web.session.UserSessionHolderInterceptor.class]: Unsatisfied dependency expressed through constructor 
argument with index 0 of type [esim.web.session.UserSession]: 
	java.rmi.RemoteException: null; nested exception is: 
	javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean;
@Component
@SessionScoped
public class UserSession
    implements Serializable {

    private final UserCredential myCredential;

    public UserSession(HttpServletRequest request)
        throws PolicyContextException {
        final AuthenticationService service = ServiceLocator.getEJB(AuthenticationService.class);
        myCredential = service.postJaasAuthentication(request.getUserPrincipal().getName(), request.getRemoteAddr());
    }

    @PreDestroy
    public void destroy()
        throws PolicyContextException {
        ServiceLocator.getEJB(AuthenticationService.class).unauthenticate(myCredential.getEmail());
    }
}
public class UserSessionHolderInterceptor
    implements Interceptor {

	private final UserSession userSession;

	public UserSessionHolderInterceptor(UserSession userSession) {
		this.userSession = userSession;
	}

	@Override
	public boolean accepts(ResourceMethod method) {
		return true;
	}

	@Override
	public void intercept(InterceptorStack stack, ResourceMethod method, Object object)
	    throws InterceptionException {
		[...]
		stack.next(method, object);
	}
}

1 Resposta

G

Oops, falha minha. Na verdade estava ocorrendo um erro na camada EJB, e como a exception estava sendo enjaulada em RmiException me confundi

:smiley:

Criado 22 de outubro de 2009
Ultima resposta 22 de out. de 2009
Respostas 1
Participantes 1