有人在使用Vaadin @Push和Vaadin4Spring安全扩展吗?
下面是与我们的项目相关的Vaadin依赖关系:
compile 'com.vaadin:vaadin-client-compiled:7.5.8'
compile 'com.vaadin:vaadin-client:7.5.8'
compile 'com.vaadin:vaadin-themes:7.5.8'
compile 'com.vaadin:vaadin-server:7.5.8'
compile 'com.vaadin:vaadin-push:7.5.8'
// Official VaadinSpring Integration
compile("com.vaadin:vaadin-spring-boot-starter:1.0.0")
//Vaadin extentions - in the future more of those will go to official VaadinSpring Integration
compile("org.vaadin.spring.extensions:vaadin-spring-ext-security:0.0.6.RELEASE")
compile("org.vaadin.spring.extensions:vaadin-spring-ext-core:0.0.6.RELEASE")
compile("org.vaadin.spring.extensions:vaadin-spring-ext-boot:0.0.6.RELEASE")
compile("org.vaadin.spring.extensions:vaadin-spring-ext-test:0.0.6.RELEASE")下面是UI类的注释
@Theme("mytheme")
@Title(com.test.util.Constants.TITLE)
@EnableOAuth2Client
@SpringUI
@Push
public class MyVaadinUI extends UI {
...
}和,Application.java;
@EnableVaadinExtensions
@SpringBootApplication
@EnableConfigurationProperties
@EnableI18N
@EnableEventBus
@RestController
@EnableOAuth2Client
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
@Bean
public RequestContextListener requestContextListener(){
return new RequestContextListener();
}
@Bean
public FilterRegistrationBean hiddenHttpMethodFilter() {
HiddenHttpMethodFilter hiddenHttpMethodFilter = new HiddenHttpMethodFilter();
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(hiddenHttpMethodFilter);
return registrationBean;
}
@Bean(name = "messageSource")
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("messages/messages");
logger.debug("Returning messageSource: " + ((messageSource != null) ? messageSource.toString() : "NULL"));
return messageSource;
}
}一旦我们调用security.login(username.getValue(),password.getValue());(安全性是org.vaadin.spring.security.VaadinSecurity;)
我们得到以下例外;
16:36:35.272 http-nio-8080-exec-9错误C.b.g.c.s.v.views.login.LoginBox/登录登录错误发生在login.org.springframework.beans.factory.BeanCreationException:错误创建名为“作用域”的bean时,名称为“作用域”:Scope 'request‘对当前线程没有活动;如果您打算从单例引用该bean,请考虑为它定义一个作用域代理;嵌套的例外是java.lang.IllegalStateException:没有找到线程绑定请求:您是指实际web请求之外的请求属性,还是处理原始接收线程之外的请求?如果您实际上是在web请求中操作,并且仍然收到此消息,那么您的代码可能运行在DispatcherServlet/DispatcherPortlet之外:在本例中,使用RequestContextListener或RequestContextFilter公开当前请求。
我很感激你能提供的任何帮助。
发布于 2016-02-22 09:42:07
您使用的是Websockets,它不使用servlet请求,也不会自动激活“请求”范围。
如果您使用@Push(transport=WEBSOCKET_XHR),它应该可以工作,因为websockets通道将只用于服务器->客户端推送,而标准->请求将用于客户端->服务器消息。
https://stackoverflow.com/questions/35542514
复制相似问题