Looks like that auto-deploy stuff is not compatible with
ContextApplication and deserialization. In a nutshell, the problem is that it’s trying to initialize the Spring application context outside of any Vaadin HTTP request thread. Because there’s no Vaadin HTTP request, there’s no way to know which Vaadin
Application we’re talking about. Obviously you need to know that to initialize the associated Vaadin Spring application context.
This might actually work someday in Vaadin 7.x if they ever fix
Issue #9953 .
I’m afraid we can’t switch to Vaadin 7 for the time being Is there any way to fix this? I realized that my auto-deploy method dosn’t do anything fancy - it simply redeploys the application and restarts the server, so in production the error will occur as well, won’t it? As soon, as the server has to be restarted, and there are any applications serialized into session, all of them will be invalidated, since they won’t be able to instantiate their “private” Spring context.
I’m not sure whether or how it can work. It may be that in production you will not see this problem… why go ahead and try it?
I don’t serialize any Vaadin sessions in my normal work so it’s not something I’m familiar with.
If somehow you can get the deserialization to happen within an invocation of
ContextApplication.invoke() , then that will fix the problem. Not sure how to do that though with your auto-deploy stuff.
Hi,
I’m having trouble wiring spring resources in my application using the springstuff addon. I used a existing backend and I’m building the frontend with Vaadin7. (Spring 3.1.1)
When I define my service like this:
Try adding @Required to your @Resource , or switch to @Autowired so it can’t be left null without an error.
You shouldn’t manually add those two
BeanPostProcessors because context:annotation-config/ does that for you.
It looks like you are using
metadblucht.xml as both the servlet-scope application context and the
VaadinSession -scope application context. This is wrong. You should define two separate application contexts, and the latter should have its location defined using the
configLocation servlet
init-param .
metadblucht-vaadin.xml contains only context:annotation-config/
metadblucht.xml same content as in previous post except for the two beanPostProcessors
VaadinServlet.getCurrent().getServletContext() return metadblucht.xml ← shouldnt this be metadblucht-vaadin.xml?
I deployed demo3 (eclipse 4.2, spring 3.1.1, tomcat 7.0.39) and I have the same problem
SEVERE:
java.lang.NullPointerException
at com.example.HelloUI.init(HelloUI.java:75)
Not sure what you mean.
getServletContext() returns a
ServletContext object, not an application context.
In any case, it is correct that the
metadblucht.xml application context is associated with the servlet context, while the
MetaBluchtVaadin.xml application context is associated with the
VaadinSession .
I just tried building and running the dellroad-stuff-vaadin-spring-demo3 using Spring 3.1.x and it worked fine.
Try building it using the supplied ant
build.xml file. I bet Eclipse is not running the AJC compiler.
Archie, not currently, but I will work on one this week. It is not a big issue, I just don’t want my Tomcat production instance administrator to be scared by some random exceptions
Hi Archie, I used your great addon successfully with Vaadin 6. But now I have to move to Vaadin 7. Is is supposed to work with 7.1.3? I cannot get it to work. I tried your sample application on github but that gives me an NPE in HelloUI when trying to access the HelloWorld bean, which should have been autowired at this point.
And by the way, how could I use the whole thing without autowiring? I prefer using the traditional approach via XML only and I have no idea how the UI class could get it’s properties then.
Best Regards
Ralph
It should work find with Vaadin 7.1.3. I just updated the demo to pull that version. When I run the demo locally it works fine.
Try updating from github and see if that helps.
Sure, autowiring is not required. Just define whatever beans you want in the Vaadin application’s XML file (in the demo, that’s the
HelloWorld.xml file).
Thanks Archie, using your git demo from scratch using pure ant/ivy worked now on 7.1.3 as well.
Must have been a problem with my manual eclipse setup.
Nevermind me asking
Hi Alexander,
don’t know if you still have problems to get it to run in eclipse.
I had similiar problems. After adding the dellroad-stuff jar to the aspectj Aspect Path (AspectJ tools->Configure AspectJ Build Path), it worked.
Did you think about using
UIProvider mechanism to add spring autowire capabilities?
You can have a look at a really simple example that uses this solution on github:
spring-vaadin-example