You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by dchicks <dh...@i-hicks.org> on 2008/10/10 20:02:43 UTC

Re: Struts2 startup service/action

Ron, this is a great tip!  Thanks!  I do have one question, though.  Any idea
how one might go about getting the Spring web context using this method?

Normally, I would have extended ContextLoaderServlet.  Our experience, so
far, has been that it's nearly impossible to get another servlet to play
nice with Struts, though.  I prefer the method that you've outlined, because
it blends well with the Struts environment.  I'm just not sure how I can get
the context for loading beans.

Thoughts?

Thanks,
Dave

-- 
View this message in context: http://www.nabble.com/Struts2-startup-service-action-tp19738655p19923169.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Struts2 startup service/action

Posted by Brad A Cupit <br...@lsu.edu>.
David C. Hicks [mailto:dhicks@i-hicks.org] wrote
> I'm stuck with version 2.0.3 due to dependencies - I
> think because spring-jpa hasn't caught up

Looks like spring-jpa has moved to spring-orm in 2.5
org.springframework
spring-orm

The ContextLoaderListener should work in Spring 2.0.x though.
Have you tried
WebApplicationContextUtils.getWebApplicationContext(sevletContext) ?

Brad Cupit
LSU - University Information Systems

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2 startup service/action

Posted by "David C. Hicks" <dh...@i-hicks.org>.
I've been working with ContextLoaderListener for a while this afternoon, 
but I think I have a problem with dependencies. The latest API docs on 
Spring indicate that you can get the current web application context 
from a static method on ContextLoader, but I'm stuck with version 2.0.3 
due to dependencies - I think because spring-jpa hasn't caught up. At 
least, that's my guess from looking at the Maven repository.

The end result is that I haven't found a way to get hold of the web 
application context, yet. Surely, I'm not the only one who needs to do 
this to initialize some things before the app gets going. I figured 
someone here would know the secret sauce.

Thanks,
Dave


Brad A Cupit wrote:
> From: dchicks [mailto:dhicks@i-hicks.org] 
> Sent: Friday, October 10, 2008 1:03 PM
>   
>> Our experience, so far, has been that it's nearly
>> impossible to get another servlet to play nice with
>> Struts, though.
>>     
>
> You could try Spring's
> org.springframework.web.context.ContextLoaderListener
> instead of the ContextLoaderServlet. 
>
> Brad Cupit
> LSU - University Information Systems
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Struts2 startup service/action

Posted by Brad A Cupit <br...@lsu.edu>.
From: dchicks [mailto:dhicks@i-hicks.org] 
Sent: Friday, October 10, 2008 1:03 PM
> Our experience, so far, has been that it's nearly
> impossible to get another servlet to play nice with
> Struts, though.

You could try Spring's
org.springframework.web.context.ContextLoaderListener
instead of the ContextLoaderServlet. 

Brad Cupit
LSU - University Information Systems

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2 startup service/action

Posted by "David C. Hicks" <dh...@i-hicks.org>.
I see. Thanks for the feedback.

Ron Chan wrote:
> I've not used Spring for a while so I can't answer your question directly.
>
> But all I'm trying to do is get access to something that would have been
> correctly initialized had I been under struts.  i.e.  my QuartzService
> example was already working under struts, I just wanted to make the
> scheduler automatically start on startup of the application, rather than
> having to hit an action.  So if you are after something similar do you need
> to have access to the spring context?  I'm not trying to get hold of the
> Guice injector.
>
> Hope this helps
> Ron
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2 startup service/action

Posted by Ron Chan <rc...@i-tao.com>.
I've not used Spring for a while so I can't answer your question directly.

But all I'm trying to do is get access to something that would have been
correctly initialized had I been under struts.  i.e.  my QuartzService
example was already working under struts, I just wanted to make the
scheduler automatically start on startup of the application, rather than
having to hit an action.  So if you are after something similar do you need
to have access to the spring context?  I'm not trying to get hold of the
Guice injector.

Hope this helps
Ron


-- 
View this message in context: http://www.nabble.com/Struts2-startup-service-action-tp19738655p19924529.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org