2012-03-27 3 views
0
임은 회색 곰, 봄 저지 프로젝트에 참여하고 난 발생했습니다

: 스택 트레이스를 바탕으로의 web.xml없이 리스너를 등록하는 방법

Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. 
    at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131) 
    at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:40) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328) 
    ... 32 more 

(그리고 내가 구글 때 결과에 ​​의해), 난

<web-app ...> 
    <listener> 
    <listener-class> 
     org.springframework.web.context.request.RequestContextListener 
    </listener-class> 
    </listener> 
</web-app> 

그래서 제 질문은, 어떻게 내가 web.xml 파일을 해달라고 주어진 회색 서버에 리스너를 등록합니다있는 web.xml을에 리스너를 등록해야합니까?

+0

당신이 당신의 web.xml을 더 보여줄 수 - 다른 청취자와 서블릿 정의는 –

+0

안녕하세요 크리스 .. 내 프로젝트는 web.xml 파일이 없습니다 .. org.glassfish.grizzly.http.server.HttpServer – geneqew

답변

0

코드의 자세한 내용을 보지 않고, 내 생각은 ServletHandler을 사용하는 것 -이 클래스의 Javadoc과의 정상에있는 예제 소스를 체크 아웃 :

정상적인에게 스프링 애플리케이션은 컨텍스트 시작을 위해 리스너를 등록한 다음 대부분의 다른 것들에 대한 디스패치 서블릿을 가지므로 예제 코드를 수정해야합니다. (완전히 테스트되지 않은) 같은

뭔가 :

sa.setServlet(new org.springframework.web.servlet.DispatcherServlet()); 
sa.addListener(org.springframework.web.context.ContextLoaderListener.class.getName()); 
sa.addContextParameter("contextConfigLocation", "beans.xml"); 
sa.setServletPath("/*"); 
+0

또는 청취자를 추가 할 때 org.springframework.web.context.request.RequestContextListener.class.getName() 일 수도 있습니다 - –

+0

감사합니다. 버전 2.2에 대한 ServletHandler에 약간의 차이가있는 것으로 보인다. (질문에 의존 버전을 포함하지 않았다면 미안하다.) 현재 [link] (http://grizzly.1045725.n5.nabble.com/Grizzly-2-2-ServletHandler-changes-td5092753.html)에 감사합니다. – geneqew

+0

@ChrisWhite 참고로, 그 링크는 지금 404입니다. –