Spring aop scoped-proxy不能在linux上安装

时间:2014-03-07 13:07:34

标签: linux spring aop session-scope

我有一个声明为会话作用域的bean。我必须在我的配置中启用aop才能在其他bean中使用它(默认情况下是单例)。

CONFI

<?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:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:tx="http://www.springframework.org/schema/tx" 
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/mvc 
         http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
         http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context.xsd
         http://www.springframework.org/schema/jdbc
         http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
         http://www.springframework.org/schema/jee
         http://www.springframework.org/schema/jee/spring-jee.xsd
         http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
         http://www.springframework.org/schema/aop
         http://www.springframework.org/schema/aop/spring-aop.xsd
         ">
    ...
    <bean id="localeResolver" class="com.my.pack.MySessionLocaleResolver" scope="session">
        <property name="defaultLocale" value="en" />
        <aop:scoped-proxy/>
    </bean>

当我从eclipse启动它时,在我的Windows桌面计算机上,它正常工作,因为它被宣布。 但是,当我在我的测试,linux环境中发布它时,它会以某种方式忽略aop的东西,并抛出错误

Linux环境中的

异常

11:09:24,928 ERROR {localhost-startStop-1} [org.springframework.web.servlet.FrameworkServlet:initServletBean] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.localeResolver': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is 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.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:343)

日志文件中没有其他错误。也不是在web-app日志中,也不是在catalina.out中。 我在tomcat 7.0.42和“CentOS release 6.5”上使用spring 3.2.4。

1 个答案:

答案 0 :(得分:0)

仔细阅读这些错误消息,始终包含失败的原因。

在这种情况下:

Scope 'session' is not active for the current thread

表示在请求bean时没有活动的HTTP会话。