我有两个Spring应用程序:客户端和服务器。在服务器应用程序上是服务,客户端应用程序是视图逻辑。这两个应用程序都应该通过Web服务进行通信,但由于错误
,这不起作用请求处理失败;嵌套异常是 org.springframework.remoting.jaxws.JaxWsSoapFaultException:错误 创建名为'scopedTarget.jcrSession'的bean:范围'session'是 对当前线程不活跃;考虑定义范围代理 对于这个bean,如果你打算从单身中引用它;嵌套 异常是java.lang.IllegalStateException:没有线程绑定请求 发现:您是指实际的请求属性吗? Web请求,或处理原始请求之外的请求 接收线程?如果您实际在Web请求中操作 并且仍然收到此消息,您的代码可能正在外面运行 DispatcherServlet / DispatcherPortlet:在这种情况下,请使用 RequestContextListener或RequestContextFilter公开当前 请求。
在服务器应用程序上我正在使用JCR会话(会话范围的bean)
<bean name="jcrSession" factory-bean="sessionFactory" factory-method="login" scope="session" destroy-method="logout" >
<aop:scoped-proxy/>
</bean>
在服务器应用程序的web.xml中我有
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
当我在浏览器中访问服务器应用程序生成的WSDL文件时,一切正常。当我在本地使用服务器应用程序服务时(例如在服务器应用程序的控制器中)一切都还可以那么,当我尝试通过远程应用程序的Web服务访问服务时,为什么会出现此错误?
UPDATE1
jcrSession
由SessionFactory
类创建。然后使用弹簧jcrSession
将此@Autowired
自动装配到DAO对象。
Example of simplified `JcrSessionFactory`:
public class JcrSessionFactory {
private Repository repository;
private Credentials credentials;
private Session session;
public Session login() {
session = repository.login(credentials);
return session;
}
public void logout() {
session.logout();
}
}
此外,当我尝试在同一个应用中自动装配服务并在@PostConstruct
注释的方法或方法InitializingBean
中的afterPropertiesSet()
的实现中使用它时发生同样的错误