Try using the DiscoveryNavigator instead of the default Vaadin navigator.
Then add the views using addBeanView
Alexander thanks for your time really help me up, I finally find my problem, it was the param value of my beanName in the web.xml. It was like this
<init-param>
<param-name>beanName</param-name>
<param-value>sv.com.vaadin.MainUI</param-value>
<load-on-startup>5</load-on-startup>
</init-param>
then I changed to
<init-param>
<param-name>beanName</param-name>
<param-value>mainUI</param-value>
<load-on-startup>0</load-on-startup>
</init-param>
and it’s works.`
addionaly also added the default target url at this line in the security.xml
<form-login login-page="/login/" always-use-default-target="true" default-target-url="/" />
Thanks.
Hello, I have a problem with the spring security integration with vaadin, the login page works fine, I enter the credentials and got forwarded to the MainView, in this view I can see the authoritys, then when I click the link “ROLE_ADMIN View (throw exception, if user doesn’t have access)” I got the next error and lose the user and his roles, and dont do the validation to the view, ignore the @Secured annotation.
09-10-2013 02:19:45 PM com.vaadin.server.DefaultErrorHandler doDefault
GRAVE:
com.vaadin.event.ListenerMethod$MethodException: Invocation of method uriFragmentChanged in com.vaadin.navigator.Navigator$UriFragmentManager failed.
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:528)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:167)
at com.vaadin.server.Page.fireEvent(Page.java:555)
at com.vaadin.server.Page.updateLocation(Page.java:854)
at com.vaadin.ui.UI.changeVariables(UI.java:355)
at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:403)
at com.vaadin.server.communication.ServerRpcHandler.handleBurst(ServerRpcHandler.java:228)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:111)
at com.vaadin.server.communication.PushHandler$2.run(PushHandler.java:158)
at com.vaadin.server.communication.PushHandler.callWithUi(PushHandler.java:289)
at com.vaadin.server.communication.PushHandler.onRequest(PushHandler.java:308)
at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:259)
at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:166)
at org.atmosphere.container.TomcatWebSocketUtil.doService(TomcatWebSocketUtil.java:137)
at org.atmosphere.container.Tomcat7AsyncSupportWithWebSocket.service(Tomcat7AsyncSupportWithWebSocket.java:59)
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1448)
at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:219)
at org.atmosphere.websocket.DefaultWebSocketProcessor$2.run(DefaultWebSocketProcessor.java:183)
at org.atmosphere.util.VoidExecutorService.execute(VoidExecutorService.java:101)
at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:178)
at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:167)
at org.atmosphere.container.TomcatWebSocketHandler.onTextMessage(TomcatWebSocketHandler.java:92)
at org.apache.catalina.websocket.MessageInbound.onTextData(MessageInbound.java:74)
at org.apache.catalina.websocket.StreamInbound.doOnTextData(StreamInbound.java:186)
at org.apache.catalina.websocket.StreamInbound.onData(StreamInbound.java:134)
at org.apache.coyote.http11.upgrade.UpgradeProcessor.upgradeDispatch(UpgradeProcessor.java:83)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext
at org.springframework.security.access.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:339)
at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:198)
at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:60)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy20.enter(Unknown Source)
at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:571)
at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:526)
at ru.xpoft.vaadin.DiscoveryNavigator.navigateTo(DiscoveryNavigator.java:198)
at com.vaadin.navigator.Navigator$UriFragmentManager.uriFragmentChanged(Navigator.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
... 30 more
How can I resolved it?? any idea??
I’m running the project in tomcat 7
This is the project: https://github.com/rgaaray/vaadin-spring-security
Is Spring Java Configuration instead of XML configuration supported?
If you mean the annotation-based-configuration then it is possible. But you still need a small application context where you configure spring to use annotations.
applicationContext.xml[code]
<?xml version="1.0" encoding="UTF-8"?><context:annotation-config/>
<context:component-scan base-package="de.test"/>
[/code]
simple bean[code]
package de.test;
@Component
@Scope(“session”)
public class TestBean {
// some code
}
[/code]
simple vaadinview[code]
package de.test;
@Component
@Scope(“session”)
@VaadinView(value=“test”)
public class TestView extends CustomComponent implements View{
@Autowired
private TestBean bean;
@Override
public void enter(ViewChangeEvent event) {
// some code
}
}
[/code]
I mean annotation based config instead of an applicationContext.xml, or do I need always an XML?
package com.foo.bar.conf;
@Configuration
@Profile("test")
public class TestProfileConfig {
@Bean
public Person employee() {
return new Person("John", "Smith", 55);
}
}
Hello, I have a problem when create framework project with maven, vaadin version 7.1.4, adds on spring integration and hibernate3. I cannot config it work with MVC. I need simple project for it.
Please help me.
Yes this is possible without an xml.
Configuration classes:
package de.test;
// Load this property file
@PropertySource("classpath:database.properties")
// Spring context configuration
@Configuration
public class DataConfig {
@Autowired
Environment env;
// For classes which don't have a "@Component" annotation
@Bean
public DataSource dataSource(){
BasicDataSource dataSource = new BasicDataSource();
dataSource.setUrl(env.getProperty("jdbc.url"));
dataSource.setUsername(env.getProperty("jdbc.username"));
dataSource.setPassword(env.getProperty("jdbc.password"));
return dataSource;
}
@Bean
public PlatformTransactionManager transactionManager(){
return new DataSourceTransactionManager(dataSource());
}
}
package de.test;
@EnableTransactionManagement
// Import the other configuration
@Import(DataConfig.class)
// This does the same as
// <context:annotation-config/>
// <context:component-scan base-package="de.test"/>
@ComponentScan("de.test")
@Configuration
public class AppConfig {
@Autowired
DataConfig dataConfig;
}
web.xml[code]
Test
Vaadin production mode
productionMode
false
<servlet>
<servlet-name>Test Application</servlet-name>
<servlet-class>ru.xpoft.vaadin.SpringVaadinServlet</servlet-class>
<init-param>
<param-name>beanName</param-name>
<param-value>testUI</param-value>
</init-param>
</servlet>
<!-- Bind as an ordinary VaadingServlet -->
<servlet-mapping>
<servlet-name>Test Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- Configure ContextLoaderListener to use AnnotationConfigWebApplicationContext
instead of the default XmlWebApplicationContext -->
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</context-param>
<!-- Configuration locations must consist of one or more comma- or space-delimited
fully-qualified @Configuration classes. Fully-qualified packages may also be
specified for component-scanning -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>de.test.AppConfig</param-value>
</context-param>
<!-- Bootstrap the root application context as usual using ContextLoaderListener -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
[/code]
I don’t test this code but it should work. And I hope this will help you. ![]()
Hi!
I have my Vaadin 7 web project and my widgetset in separate locations, using maven 3.
My widgetset project pom contains other Vaadin addons and is working fine since before I added spring-vaadin-integration.
My Vaadin web project pom contains the spring-vaadin-integration addon.
When I run the application I get this message:
INFO: Requested resource
[/VAADIN/widgetsets/com.example.application.common.widgetset.AppWidgetSet/com.example.application.common.widgetset.AppWidgetSet.nocache.js]
not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
… and this error message when I hit refresh in my browser:
Failed to load the widgetset: ./VAADIN/widgetsets/com.example.application.common.widgetset.AppWidgetSet/com.example.application.common.widgetset.AppWidgetSet.nocache.js?1380183315479
When I unpack the widgetset.jar the widgetset and the “missing” file are at the correct location.
My web.xml contains the correct path too…
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<!-- Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<!-- To allow session-scoped beans -->
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/web-context.xml</param-value>
</context-param>
<!-- Vaadin servlet -->
<servlet>
<servlet-name>Spring-Vaadin Servlet</servlet-name>
<servlet-class>ru.xpoft.vaadin.SpringVaadinServlet</servlet-class>
<init-param>
<description>Vaadin UI to display</description>
<param-name>beanName</param-name>
<param-value>mainUI</param-value>
</init-param>
<init-param>
<description>Application widgetset</description>
<param-name>widgetset</param-name>
<param-value>com.example.application.common.widgetset.AppWidgetSet</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Spring-Vaadin Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Spring-Vaadin Servlet</servlet-name>
<url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>
<context-param>
<description>Vaadin production mode</description>
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>
</web-app>
Is there anything else wrong with my web.xml?
Try to run maven clean and then recompile your widgetset and application.
Hi Marius! I have tried cleaning and recompiling, and cleaning everything in Tomcat. Unfortunately I end up with the same error.
Perhaps this is not related to spring-vaadin-integration. I just had a look in my Tomcat Deployment directory and found that the application-common-widgetset-0.0.11-SNAPSHOT.jar in there was only 6kb, containing only the /com and /META-INF directories.
I went to my workspace/…/lib folder and copied the application-common-widgetset-0.0.11-20130926.124257-7.jar in there (>20Mb) to the Tomcat Deployment directory and it worked.
It seems like I have some problems with my widgetset pom-structure.
I have a same problem if I want to implement a login page .
Can u help me. If UiProvider is solution, how it is configured to launch login page (#!loginView)
Thx
I’ve downloaded Vaadin sample projects from xpoft’s github and they work fine, except the spring-security example. Whenever I type the login and password (did not change anything, so default user/user or admin/admin) it just gives me 404 error. Anyone know how to fix it?
Hi, I’m trying to use your plugin under Vaadin 7.0.1 and Spring 3.2.2.
I can’t get Spring to see the main UI bean registered with the “beanName” in the web.xml, even if I’ve annotated it correctly (@Component and @Scope).
The applicationContext.xml has both the context:annotation-config and context:component-scan tags.
It seems that Spring isn’t looking at the annotations: NoSuchBeanDefinitionException
Could you help me?
Can you post your web.xml?
It seems that you define the wrong name for your UI.
[code]
@Component
public class
MainUI
… {
…
}
<…>
beanName
mainUI
</…>
[/code]In this example it is important that the bean name is “mainUI” and not e.g. “mainUi”. Be sure that this is not the problem. Otherwise post your web.xml.
Thanks, it was exactly a wrong name problem in the web.xml.
My beanName’s param-value had its first letter capitalized, and this doesn’t work.
I have been having a very difficult time trying to use the spring integration. Basically, the main UI is working and wired up with spring, However, I can not get any of the navigational views working with Spring. I have tried the normal navigation and the DiscoveryNavigator without much luck. The classes are loaded, but not controlled by spring.
@Component
@Scope(“prototype”)
@VaadinView(LoginViewComponent.NAME)
public class LoginViewComponent extends CustomComponent implements View,
Button.ClickListener {
@Autowired
private transient ApplicationContext applicationContext;
@Transient
@PersistenceContext(name="model")
EntityManager entityManager;
I expected the applicationContext and entityManager to have been populated but both are null.
any help?
thx
Vaadin 7.1.0 and SpringVaadinIntegration 2.0.2
@Component
@Scope(value = “session” , proxyMode = ScopedProxyMode.TARGET_CLASS)
MyCOmponent extennds AbstractComponent
on detach() doesn’t clears connectorId
UI has Request Scope
So, on reinitializng UI throws RuntimeException: A connector with id 9 is already registered!
Repoducing: using SpringSecurity.
- log in
- log out (close session)
- log in
The same problem found in article: http://ttlnews.blogspot.com/2013/07/vaadin-error-connector-with-id-7-is.html
@Ed Ross
It can be possible that Spring didn’t find your class. Is your view class in a package which is scanned by Spring? Otherwise Spring cannot find your view class and autowiring isn’t working.