Yeah I ran into this a long time ago, fortunately a simple extension does the 
trick

public class SpringActionBeanContextFactory extends
                DefaultActionBeanContextFactory {

        @Override
        public ActionBeanContext getContextInstance(HttpServletRequest request,
                        HttpServletResponse response) throws ServletException {
                ActionBeanContext context = super.getContextInstance(request, 
response);
                SpringHelper.injectBeans(context, request.getSession()
                                .getServletContext());
                return context;
        }
}

Then you'll have to wire that in web.xml

<init-param>
        <name>ActionBeanContextFactory.class</name>
        <value>your.package.SpringActionBeanContextFactory</value>
</init-param>

Again my proposal for configurable class instantiation cleanly solves this 
problem
http://www.nabble.com/Idea-regarding-use-of-class.newInstance%28%29-and-spring-integration-to17254970.html#a17254970




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Szymon Zeslawski
Sent: Tuesday, July 08, 2008 8:06 AM
To: [email protected]
Subject: [Stripes-users] @SpringBean not working in ActionBeanContext?

Hi,

is the @SpringBean annotation designed to work
in custom ActionBeanContext? I get a NPE
when I try to access the Spring bean. It binds
correctly in ActionBeans...

Sometime ago I ran into a problem of using the
same Spring bean in ActionBeans which inherited
from one another - this would not work for
obvious reason and gave me a NPE but AFAIK
ActionBeanContext is not in any way
hierarchically bound to any of the ActionBeans?


code is simple as hell:

public class BaseActionBeanContext
        extends ActionBeanContext {

@SpringBean
private UserService userService;

public void method(String username) {
//line below throws NPE
User user = userService.findByName(username);
}

any ideas or suggestions please?

Regards,
Szymon


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to