[jboss-user] [JBoss Seam] - Re: Using Seam as a simple IoC bean factory in console app
rhasselbaum
do-not-reply at jboss.com
Tue Jan 1 16:11:09 EST 2008
For what it's worth, I found a workable solution in my case. I'm using Spring anyway instead of EJB, and I really only need Spring beans for my console applications. The problem was that I configured Spring/Seam to use Seam-managed (conversation-scoped) Hibernate sessions via the SeamManagedSessionFactoryBean. But this was causing transactions to fail outside of the web container because Seam wasn't initialized.
The solution was to configure Spring's ApplicationContext to fall back to Spring-managed Hibernate sessions when running outside of the web container, which removes the dependency on Seam. One can set this up by creasing a bean alias (called, say, "sessionFactory") that points to the product of either SeamManagedSessionFactoryBean or Spring's AnnotationSessionFactoryBean. All Spring beans that need access to the session factory bind to the alias, and the implementation can be chosen at runtime (e.g. using a PropertyPlaceholderConfigurer).
Obviously, this won't work for everyone, and it kind of sidesteps the issue of bootstrapping Seam outside of a web container. (That would still be nice!) But if your application happens to use Spring anyway, it might be a workaround.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116272#4116272
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116272
More information about the jboss-user
mailing list