Spring integration

@Chris
Please see my updated original post.
Worth noting is that I even tried putting my SomeView class inside the same package as the MainUI, but that didn’t work.

@Roger: You cannot use autowired beans in constructor so that will never work. The method annotated with @PostConstruct should work but only if the view has been instantiated by Spring. How do you navigate to the view (Navigator-related code is not shown in the code snipped of MainUI)?

@Mika: Of course not. My bad. Please see the updated original post where I have added the Navigator-related code. As you can see I am using the DiscoveryNavigator, just like in the github-sample.

You should not call addView -method when using autowired views. The instantiated view is not Spring-managed when you call it.

@Mika: That makes perfect sense! I just didn’t think of it that way when using this servlet. Thank you so much, Mika. It works just fine now!

The solution mentioned here should work: https://vaadin.com/forum#!/thread/2207105

I have another (probably stupid) question. What is the use of…

@Autowired
private transient ApplicationContext applicationContext;

Things seem to work just fine without it and it’s not used anywhere in the “spring-integration” example.

Probably the “old” way of using vaadin with spring without this addon. It is not needed for the integration as its included in the addon.

Hi folks! Currently I use Spring a lot on my OSGi application with Vaadin, but I dont use this addon to acomplish this.

This is my settup:


public class UIProviderContextAware extends UIProvider {
	
	private static final long serialVersionUID = -3577120684280817902L;

	@Override
	public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
		return MainApplication.class;
	}

	@Override
	public UI createInstance(UICreateEvent event) {
		return AppContext.getApplicationContext().getBean(MainApplication.class);
	}
	

}

This is the only part when I access the Context Manually. After the Main Application, everything D.I.

LoginPresenter - A Bean that requires a LoginView
LoginViewImpl - The view implemented, injected into presenter
All the same with services, etc.

This addon can simplify this setup? Sorry by this noob question!

Hi Alexander,

Thanks for your answer, but I think i have a diferent problem because the application don’t show the MainUI, i’m trying to put this line in my security.xml

to force the URL but i got this message

Estado HTTP 500 - com.vaadin.server.ServiceException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘sv.com.vaadin.MainUI’ is defined

so I think the MainUI don’t load and i don’t know where can i defined that.

I’m running this project in tomcat 7.

Can you have another solution??

beanName

should be
UI

didn’t work.

I just upload the same Alexander Federov’s spring security project, with the only changed that I put all the dependecies in the pom.xml, I’m run it in a tomcat 7 and I use STS IDE.

The login page load fine.
When I complete the username and the password and click in the login button, the next error show up

Estado HTTP 404 - /j_spring_security_check

and the url in the browser show like this

http://localhost:8092/j_spring_security_check

I think that error show up because in tht url I don’t see the context path of my project (“vaadin-spring-security”)

this is the project

https://github.com/rgaaray/vaadin-spring-security/

any idea??

Hi,
Running “sping-integration” report following error :


2013-09-03T11:40:35.679+0200 javax.enterprise.system.container.web.com.sun.enterprise.web
WARNING: StandardWrapperValve[Vaadin Sample Application]
: PWC1406: Servlet.service() for servlet Vaadin Sample Application threw exception
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myUI' is defined
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:570)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1108)
	at org.springframework.beans.factory.support.AbstractBeanFactory.isPrototype(AbstractBeanFactory.java:431)
	at org.springframework.context.support.AbstractApplicationContext.isPrototype(AbstractApplicationContext.java:1141)
	at ru.xpoft.vaadin.SpringUIProvider.isSessionScopedUI(SpringUIProvider.java:69)

I’m using the sample available under
vaadin-samples
with vaadin 7.1.3, Spring Vaadin Integration 2.0.1, Spring 3.2.4, Glassfish 3.1.2. In Eclipse debug mode, I cannot get bean from type using Spring methods. This is strange. Any idea ?

Thanks.

The application uses the following CLASSPAH:

/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/logback-classic-1.0.6.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/cssparser-0.9.5.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/atmosphere-compat-tomcat-1.0.14.vaadin4.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/atmosphere-compat-tomcat7-1.0.14.vaadin4.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/aopalliance-1.0.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/atmosphere-runtime-1.0.14.vaadin4.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/spring-expression-3.2.4.RELEASE.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/slf4j-api-1.6.6.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/log4j-over-slf4j-1.6.6.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/jsoup-1.6.3.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/vaadin-client-compiled-7.1.3.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/commons-lang3-3.1.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/spring-aop-3.2.4.RELEASE.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/commons-logging-1.1.1.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/vaadin-client-7.1.3.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/validation-api-1.0.0.GA.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/atmosphere-compat-jbossweb-1.0.14.vaadin4.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/sac-1.3.jar
/opt/glassfish/domains/domain1/generated/spring-integration/
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/spring-context-3.2.4.RELEASE.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/vaadin-theme-compiler-7.1.3.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/vaadin-themes-7.1.3.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/spring-beans-3.2.4.RELEASE.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/jcl-over-slf4j-1.6.6.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/freemarker-2.3.18.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/vaadin-server-7.1.3.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/spring-webmvc-3.2.4.RELEASE.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/spring-web-3.2.4.RELEASE.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/logback-core-1.0.6.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/spring-core-3.2.4.RELEASE.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/vaadin-shared-deps-1.0.2.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/vaadin-push-7.1.3.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/commons-cli-1.2.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/vaadin-shared-7.1.3.jar
/opt/glassfish/domains/domain1/generated/ejb/spring-integration/
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/validation-api-1.0.0.GA-sources.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/vaadin-slf4j-jdk14-1.6.1.jar
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/classes/
/opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/lib/commons-jexl-2.1.1.jar

Bean classes are in </opt/glassfish/domains/domain1/autodeploy/spring-integration.war/WEB-INF/classes/>

The problem was in Eclipse project configuration. Update default output directory to “target/classes” for maven project.

Using tomcat 7 en eclipse the login works when commenting out the navigator in the UI en uncommenting


       <init-param>
            <description>Vaadin UI to display</description>
            <param-name>UI</param-name>
            <param-value>sv.com.vaadin.MainUI</param-value>
        </init-param>

in the web.xml

Using http://localhost:8080/vaadin-prueba-gestor I get forwared to

http://localhost:8080/vaadin-prueba-gestor/login/;jsessionid=219E38AC4349ADC48C674CF89EB9BE89

Thanks for help me up Alexander, what you said in this post i get it, i can see the login page, my problem is after, when you click in the login button you get forwared to the same login page and not to my MenuView. How can i get forwared to my MenuView??

When I enter the credentials user:user I get forwarded to the MainUI

then add something like this when the MainUI is loaded


 Navigator navigator = new Navigator(this, this);
        navigator.addView(MenuView.NAME, MenuView.class);
        navigator.navigateTo(MenuView.NAME);

Really??? I still get forwarded to the same login page the only changed is the “jsessionid” in the url, but i can’t get forwarded to the MainUI and then to the MenuView, i put a breakpoint in the MainUI and i debug the project but never enter to the MainUI. Can you send me the project you’re running??? maybe had something different. Sorry for bother you so much.

I added my export from eclipse.
13169.zip (31.2 KB)

i have a question about autowiring.
i succeeded in developing.
but i can autowired at mainUI only. that means some view class(extended vaadin view) can`t autowried.
the property is null.

so… how can i autowiring with sub view pages?

i want to use DAO classes in sub view pages…
i can. by using mainUI. and when make sub view pages i assiged the dao instance.

but i don`t want to use mainUI.

can i? if can. how can i?

plz tell me. how does it work.

thanks guys.

ps. i posted some of my source.
13170.xml (1.6 KB)
13171.xml (3.56 KB)
13172.java (15 KB)
13173.java (5.59 KB)
13174.java (1.14 KB)
13175.java (838 Bytes)