STRUTS2 and Spring2
Hi All, I am using RAD7.0, JDK 1.5, Struts2 and Spring 2.x. We have been using Struts1.x and Spring 1.x for a long time now and moving our app to Struts2 + Spring2 We are trying to have Spring manage all the value objects and action objects. And so followed steps in Struts document to add struts2-spring plugin jar and made necessary changes but getting errors when try to create a bean in session scope. Following are my configuration files: web.xml == . contextConfigLocation /WEB-INF/applicationContext.xml struts2 org.apache.struts2.dispatcher.FilterDispatcher struts2 /* org.springframework.web.context.ContextLoaderListener = Spring applicationContext.xml http://www.springframework.org/schema/beans"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:aop="http://www.springframework.org/schema/aop"; xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd";> ... === With this configuration, server starts up correct without any issues, but when I try to access my action class, I am getting following error: = [1/18/08 23:49:51:855 EST] 0032 WebAppE [Servlet Error]-[Error creating bean with name 'scopedTarget.mVO': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request? If you are actually operating within a web request and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.]: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.mVO': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request? If you are actually operating within a web request and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request? If you are actually operating within a web request and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes (RequestContextHolder.java:102) at org.springframework.web.context.request.SessionScope.get( SessionScope.java:88) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:283) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:160) at org.springframework.aop.target.SimpleBeanTargetSource.getTarget( SimpleBeanTargetSource.java:33) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.getTarget (Cglib2AopProxy.java:660) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept (Cglib2AopProxy.java:610) at com.foo.bar.vo.MyVO$$EnhancerByCGLIB$$d821bb7e.setClassName () at com.foo.bar.interceptors.MyInterceptor.intercept(MyInterceptor.java :56) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling( DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling( DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile( UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionI
Struts2 and Spring2 with session scoped beans
Hi All, We've are trying to use Struts2 with Spring2 on Webspher 6.1 and JDK 1.5. Basically we are trying to use session scoped beans from Spring applicationContext in to Struts2 using Spring DI. but running in to issue. Following are my config files: web.xml == struts2 org.apache.struts2.dispatcher.FilterDispatcher struts2 /* org.springframework.web.context.ContextLoaderListener == Spring applicationContext.xml == http://www.springframework.org/schema/beans"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:aop="http://www.springframework.org/schema/aop"; xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd";> .. = When I run this configuration, I am getting following error: == [1/18/08 23:49:51:855 EST] 0032 WebAppE [Servlet Error]-[Error creating bean with name 'scopedTarget.mVO': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request? If you are actually operating within a web request and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.]: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.mVO': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request? If you are actually operating within a web request and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request? If you are actually operating within a web request and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes (RequestContextHolder.java:102) at org.springframework.web.context.request.SessionScope.get( SessionScope.java:88) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean( AbstractBeanFactory.java:283) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean( AbstractBeanFactory.java:160) at org.springframework.aop.target.SimpleBeanTargetSource.getTarget( SimpleBeanTargetSource.java:33) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.getTarget (Cglib2AopProxy.java:660) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept (Cglib2AopProxy.java:610) at com.foo.bar.vo.MyVO$$EnhancerByCGLIB$$d821bb7e.setClassName() at com.foo.bar.interceptors.MyInterceptor.intercept(MyInterceptor.java:56) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling( DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling( DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile( UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke( DefaultActionInvocation.java:221) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java :50) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java :504) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter( FilterDispatcher.java:419) at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter( FilterInstanceWrapper.java:190) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter( WebAppFilterChain.java:130) at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter( WebAppFilterChain.java:87) at com.i
Re: STRUTS2 and Spring2
Hi Dave, I have looked up api and spring doc for both the listeners. But I was trying to say, if I add RequestContextListener then Struts2 plugin gives error saying that You have to add ContextLoaderListener. And if I add ContextLoaderListener, spring gives error saying add RequestContextListener. Can I have both listener at same time? I haven't tried doing that but will try and see if that works.. Thank you. On Jan 19, 2008 8:57 AM, Dave Newton <[EMAIL PROTECTED]> wrote: > --- Niral Trivedi <[EMAIL PROTECTED]> wrote: > > We are trying to have Spring manage all the value objects and action > > objects. And so followed steps in Struts document to add struts2-spring > > plugin jar and made necessary changes but getting errors when try to > create > > a bean in session scope. Following are my configuration files: > > [...] > > [1/18/08 23:49:51:855 EST] 0032 WebAppE [Servlet > > Error]-[Error > > creating bean with name 'scopedTarget.mVO': Scope 'session' is not > active > > for the current thread; consider defining a scoped proxy for this bean > if > > you intend to refer to it from a singleton; nested exception is > > java.lang.IllegalStateException: No thread-bound request found: Are you > > referring to request attributes outside of an actual web request? If you > are > > actually operating within a web request and still receive this > message,your > > code is probably running outside of DispatcherServlet/DispatcherPortlet: > In > > this case, use RequestContextListener or RequestContextFilter to expose > the > > current request.]: > > [...] > > So, I tried changing web.xml and replace > > org.springframework.web.context.ContextLoaderListener with > > org.springframework.web.context.request.RequestContextListener. At that > > point, server starts up correctly, but while accessing action class, I > am > > getting error message saying : > > The reference manuals for both 2.0 and 2.5 say to *add* the > RequestContextListener [1,2], not to remove the listener that sets up your > application context. > > I'd recommend perusing the reference doc a bit more and also checking the > API > documentation for both ContextLoaderListener [3] and > RequestContextListener > [4] to understand what each of them do. > > d. > > [1] > > http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#beans-factory-scopes-other > [2] > > http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-scopes-other > [3] > > http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/context/ContextLoaderListener.html > [4] > > http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/context/request/RequestContextListener.html > [tags: s2, spring, config, scope] > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
customization
Hi All, I am successfully able to use S2 validators using validation.xml file and also able to display field error messages on the page. But I want to customize the error messages. For example, by default tag will put errors using html tags. but instead I want to wrap the errors in tag and put some warning image kind of thing. Is there anyway to achieve this? If so, how to do that and also, can you please point me to any websites where I can find such examples? Thank you.
mapped back property equivalent in struts2
Hi All, Is there anyway we can implement mapped back property ActionForm implementation from Struts1.x in to Struts2? We've been using mapped back property feature so easily to create and populate dynamic property name/value using Struts 1.x that we are not sure how to implement that in Struts2? Any help is greatly appreciated. TIA.
issue
Hi All, I am using Struts 2.0.11 on RAD7, Webspher 6.1, JDK 1.5. I am trying to create radio buttons using a dynamic Map as below: But when I try to load the page, it is giving Freemaker Template exception as below(I haven't pasted entire stack trace for readability) : * FreeMarker template error!* Error on line 31, column 9 in template/simple/radiomap.ftl stack.findString(parameters.listValue) is undefined. It cannot be assigned to itemValue The problematic instruction: -- ==> assignment: itemValue=stack.findString(parameters.listValue) [on line 31, column 9 in template/simple/radiomap.ftl] in user-directive s.iterator [on line 23, column 1 in template/simple/radiomap.ftl] -- Java backtrace for programmers: -- freemarker.core.InvalidReferenceException: Error on line 31, column 9 in template/simple/radiomap.ftl stack.findString(parameters.listValue) is undefined. It cannot be assigned to itemValue at freemarker.core.Assignment.accept(Assignment.java:111) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.IfBlock.accept(IfBlock.java:82) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.Environment.visit(Environment.java:233) at freemarker.core.UnifiedCall.accept(UnifiedCall.java:116) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.Environment.process(Environment.java:176) at freemarker.template.Template.process(Template.java:232) at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:168) at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:530) at org.apache.struts2.components.UIBean.end(UIBean.java:484) at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43) at com.ibm._jsp._features_5F_form_5F_content._jspx_meth_s_radio_1(_features_5F_form_5F_content.java:1806) at com.ibm._jsp._features_5F_form_5F_content._jspx_meth_s_if_12(_features_5F_form_5F_content.java:1847) at com.ibm._jsp._features_5F_form_5F_content._jspx_meth_s_iterator_1(_features_5F_form_5F_content.java:1956) at com.ibm._jsp._features_5F_form_5F_content._jspx_meth_s_if_2(_features_5F_form_5F_content.java:1994) at com.ibm._jsp._features_5F_form_5F_content._jspx_meth_s_if_1(_features_5F_form_5F_content.java:2031) at com.ibm._jsp._features_5F_form_5F_content._jspx_meth_s_iterator_0(_features_5F_form_5F_content.java:3493) at com.ibm._jsp._features_5F_form_5F_content._jspService(_features_5F_form_5F_content.java:273) at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) But If I change the value for value attribute in tag to '01' or '02' or something then it works fine and display 1 and 2 instead of '01' and '02' for label. So, is this some bug in in Struts2? What is the solution if I want to dynamically create Map and assign it to list attribute of ? Thanks a lot in advance for the help one more time..
Re: issue
Hi Dave, Thanks for the reply. I've actually tried with #keepRemoveRadio as well but got same result. In fact, I got it working by putting "john" or "doe" as below for property: Moving ahead, now stuck with a different issue. Actually, I want to create name of the param dynamically by concatenating two strings. One is already a struts2 property and other is a static value. For example, I want to do something like this: Line 1: * * But I could not get the lines in bold working. Do you have any idea how to concatenate two strings and assing it to a third variable? I tried but that doesn't work either. Using that I can only iterate and print the values but cant assign to third variable. Thanks On Thu, Apr 3, 2008 at 8:40 AM, Dave Newton <[EMAIL PROTECTED]> wrote: > --- Niral Trivedi <[EMAIL PROTECTED]> wrote: > > I am using Struts 2.0.11 on RAD7, Webspher 6.1, JDK 1.5. > > Hey, me too. My sympathies. > > > I am trying to create radio buttons using a dynamic Map as below: > > > > > > > > > > > > > > > > > "changeKeep1()" theme="simple"/> > > > > > > But when I try to load the page, it is giving Freemaker Template > exception > > as below(I haven't pasted entire stack trace for readability) : > > What happens if you use list="#keepRemoveRadioMap"? > > While I've never used the tag, normally when you create an > object > in the OGNL context like that you need to refer to it with a leading "#" > meaning that it's a named object, not a property of an object on the value > stack. > > Dave > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
redirect-action and redirect
Hi All, I am facing a strange issue. I am using Struts 2.0.11 on Websphere 6.1 with JDK 1.5. Thing is, I am using result type "redirect-action" and "redirect" to redirect to a different action for certain scenarios in my action class. This works fine from my local workstation. But when we deploy our app in the test environment, it still works, but the url that we see after redirection is of the app server url and not the web server url. For example, I invoked action as http://www.somedomain.com/appContext/some.action at this point, some.action will be invoked and I do some processing inside my execute method and I return result which is of type "redirect-action" and the action name is redirectFile.action So, after redirection, I expect to see the url as http://www.somedomain.com/appContext/redirectFile.action but instead, I see as http://www.appServer.com/appContext/redirectFile.action I mean, the flow works without any issues but why does the url changing? We do have a webserver running on app server box but this never happend with Struts 1.x. So, what is Struts2 redirect-action result type doing special that is causing this? And any idea how to resolve this? Thanks in advance.
Accessing Map of Map in struts 2.3.1.2
Hi All, I have just now upgraded from Struts 2.0.11 to struts 2.3.1.2 version and running in to weird issue. Basically, I have Object having HashMap holding HashMap. Something like below : public class TestVO { private HashMap firstMap; //I've setter/getter in real code but omitting here for simplicity. } My Action class goes as below : public class MyAction extends ActionSupport { public TestVO testVO; public TestVO getTestVO() { return this.testVO; } public void setTestVO(TestVO testVO) { this.testVO = testVO; } public String execute() { HashMap firstMap = new HashMap(); HashMap secondMap = new HashMap(); secondMap.put("FIRST_KEY", "firstValue"); secondMap.put("SECOND_KEY", "secondValue"); firstMap.put("KEY1", secondMap); testVO.setFirstMap(firstMap); return "success"; } } Now with above VO and class, I am doing below in my JSP and it is not working after upgrade. Now above code was perfectly working fine with old struts 2.0.11 jar but after upgrading this doesn't seem to be working. I have tried doing and but to no luck. Am I missing something here ? Is there a different way to access Map of Map with latest version ? Please let me know if anyone has any idea. Thank you.
Re: Accessing Map of Map in struts 2.3.1.2
I do not see anything in logs. Also, I find this link https://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-RefactorusageofstaticmethodsviaOGNL but in my case it's not a static method. and the internal link from here to jira issue couldn't open. So, is this related to my issue ? 2012/4/14 Łukasz Lenart > 2012/4/14 Niral Trivedi : > > Am I missing something here ? Is there a different way to access Map of > Map > > with latest version ? > > It can be a side effect of security changes to OGNL and Struts2, do > you see anything unusual in logs ? Try to increase log level to Debug. > > > Regards > -- > Łukasz http://www.lenart.org.pl/ > mobile +48 606 323 122, office +27 11 0838747 > Warszawa JUG conference - Confitura http://confitura.pl/ > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: Accessing Map of Map in struts 2.3.1.2
yes. i m accessing map. But I was just browsing struts site and found that article so wondering whether this could be related to my issue as this link also states that some OGNL security issue fixed. On Sat, Apr 14, 2012 at 3:51 PM, Dave Newton wrote: > No, that's related to static methods; I thought you were accessing a map. > > On Sat, Apr 14, 2012 at 3:49 PM, Niral Trivedi wrote: > > > I do not see anything in logs. > > > > Also, I find this link > > > > > https://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-RefactorusageofstaticmethodsviaOGNL > > but in my case it's not a static method. and the internal link from here > to > > jira issue couldn't open. > > > > So, is this related to my issue ? > > > > 2012/4/14 Łukasz Lenart > > > > > 2012/4/14 Niral Trivedi : > > > > Am I missing something here ? Is there a different way to access Map > of > > > Map > > > > with latest version ? > > > > > > It can be a side effect of security changes to OGNL and Struts2, do > > > you see anything unusual in logs ? Try to increase log level to Debug. > > > > > > > > > Regards > > > -- > > > Łukasz http://www.lenart.org.pl/ > > > mobile +48 606 323 122, office +27 11 0838747 > > > Warszawa JUG conference - Confitura http://confitura.pl/ > > > > > > - > > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > > > >