Re: Different results with spring
On Fri, Jan 29, 2010 at 19:09, Miguel wrote: > Hi, > Thanks for answering!! > I'll post my relevant configurations. I'm using spring 2.5.6 and struts > 2.1.8.1. > I have the spring plugin in the struts.conf, and my actions are > correctly autowired by name. > I also have an include in struts.conf where the relevant action is called. > The thing here is I have two beans of the same type but configured to > access different hibernate entity-names (a DAO), and in the part that > misbehaves, i need to access the second one that has a different name, > but is of the same type. > When I make spring instanciate the action, the prepare() method in the > action is called correctly, and it uses the autowired DAO, it gets the > desired data but the details() method is not called and the result is > automatically redirected to INPUT result. > When I make struts (using the spring factory( instanciate the action, > the prepare() method in the action is called correctly, and it uses > the autowired DAO, it gets the desired data, the details() method is > called and the result is shown correctlly. > Curiosly the browse method is correctly called en each config. > The thing here is I have replicated some part of the system, and I > have identical class names in different packages (the code in the > classes is not the same), and those classes are called from different > urls in struts.conf. The action has no validators but it's twin class > in a different package does. > > struts.conf: > > value="org.apache.struts2.spring.StrutsSpringObjectFactory" /> > > > > > > class="com.proyectox.ui.interceptor.HibernateOpenSessionInViewInterceptor"/> > > > > > > > > > > com/fcm/sectorPrimario2009/sectorPrimario.struts.xml: > namespace="/sectorprimario/receptor"> > > class="com.fcm.sectorPrimario2009.ui.ReceptorAction"> > listaReceptor.jsp > listaReceptor.jsp > > contribuyente > true > contribuyenteActual > > > > > class="com.fcm.sectorPrimario2009.ui.ReceptorAction"> > receptorDetail.jsp > receptorDetail.jsp > receptorNuevo.jsp > receptorNuevo.jsp > > lista > > /error.jsp > > contribuyente > true > contribuyenteActual > > > receptor > true > receptorActualSP > > > > ... > > > sectorPrimario.spring.xml: > > http://www.springframework.org/schema/beans"; > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; > xmlns:jee="http://www.springframework.org/schema/jee"; > xmlns:sec="http://www.springframework.org/schema/security"; > xmlns:tx="http://www.springframework.org/schema/tx"; > 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.5.xsd > http://www.springframework.org/schema/jee > http://www.springframework.org/schema/jee/spring-jee-2.5.xsd > http://www.springframework.org/schema/security > http://www.springframework.org/schema/security/spring-security-2.0.xsd > http://www.springframework.org/schema/tx > http://www.springframework.org/schema/tx/spring-tx-2.5.xsd > http://www.springframework.org/schema/aop > http://www.springframework.org/schema/aop/spring-aop-2.5.xsd > " > default-autowire="autodetect"> > > class="com.fcm.sectorPrimario2009.dao.ReceptorDAOImpl"> > > > > > > > > > > > > > class="com.fcm.repository.Nom151RepositoryAdaptor"> > ref="nom151Repository"/> > > > > > class="com.fcm.sectorPrimario2009.ui.ReceptorAction" > scope="prototype"> > local="receptorDAOSectorPrimario"/> > > > > ReceptorAction.java > > public class ReceptorAction extends ActionSupport implements Preparable { > private static final long serialVersionUID = 4361713845701104303L; > ... > public void prepare() throws Exception { > // msg = pais+" Pais: "+pais.getN
Re: Different results with spring
Hi, Thanks for answering!! I'll post my relevant configurations. I'm using spring 2.5.6 and struts 2.1.8.1. I have the spring plugin in the struts.conf, and my actions are correctly autowired by name. I also have an include in struts.conf where the relevant action is called. The thing here is I have two beans of the same type but configured to access different hibernate entity-names (a DAO), and in the part that misbehaves, i need to access the second one that has a different name, but is of the same type. When I make spring instanciate the action, the prepare() method in the action is called correctly, and it uses the autowired DAO, it gets the desired data but the details() method is not called and the result is automatically redirected to INPUT result. When I make struts (using the spring factory( instanciate the action, the prepare() method in the action is called correctly, and it uses the autowired DAO, it gets the desired data, the details() method is called and the result is shown correctlly. Curiosly the browse method is correctly called en each config. The thing here is I have replicated some part of the system, and I have identical class names in different packages (the code in the classes is not the same), and those classes are called from different urls in struts.conf. The action has no validators but it's twin class in a different package does. struts.conf: com/fcm/sectorPrimario2009/sectorPrimario.struts.xml: listaReceptor.jsp listaReceptor.jsp contribuyente true contribuyenteActual receptorDetail.jsp receptorDetail.jsp receptorNuevo.jsp receptorNuevo.jsp lista /error.jsp contribuyente true contribuyenteActual receptor true receptorActualSP ... sectorPrimario.spring.xml: http://www.springframework.org/schema/beans"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:jee="http://www.springframework.org/schema/jee"; xmlns:sec="http://www.springframework.org/schema/security"; xmlns:tx="http://www.springframework.org/schema/tx"; 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.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd " default-autowire="autodetect"> ReceptorAction.java public class ReceptorAction extends ActionSupport implements Preparable { private static final long serialVersionUID = 4361713845701104303L; ... public void prepare() throws Exception { // msg = pais+" Pais: "+pais.getNombre()+" idobt: "+id; if ((receptor == null && id != null) || (receptor != null && id != null && receptor.getId() != id)){ receptor = (ReceptorPrimario)receptorDAO.find(id); } else if (receptor == null && id == null){ receptor = new ReceptorPrimario(); } @org.apache.struts2.interceptor.validation.SkipValidation public String browse(){ // receptores = receptorDAO.findAll(); receptores = receptorDAO.findByContribuyente(contribuyente); if (receptores == null ){ msg ="Algo funciono mal";
Re: Different results with spring
What you are doing should work the way you expect... I use the Spring integration all the time :) A few simple questions, do you have the spring-plugin installed? Do you have the Spring ContextLoaderListener setup in the web.xml? Do you have any non-default configuration settings in any of web.xml, applicationContext.xml or struts.xml? Are you using any plugins other than the Spring plugin? What version of Spring and Struts are you using? -Wes On Fri, Jan 29, 2010 at 1:19 AM, Miguel wrote: > Hello all, > I have a problem when using spring and the spring aplication context. > If I configure the action class directly from struts.conf, my action > does just the correct behavior. (1) > But if I configure the action in a spring file and in struts.conf put > only the spring bean name everything gets piped to the input result > (the prepare method is executed, but not the action method).(2) > I would benefit if the second scenario worked, because in the spring > configuration is quite complex and have more than one bean of the same > type > > (1) class="com.fcm.sectorPrimario2009.ui.ReceptorAction"> (struts.conf) > > (2) > (struts.conf) > > class="com.fcm.sectorPrimario2009.ui.ReceptorAction" > scope="prototype"> (spring.xml) > local="receptorDAOSectorPrimario"/> > > > I hope someone can help me > > > > > Si quieres ser más positivo, pierde un electrón > Miguel Ruiz Velasco Sobrino > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Different results with spring
Hello all, I have a problem when using spring and the spring aplication context. If I configure the action class directly from struts.conf, my action does just the correct behavior. (1) But if I configure the action in a spring file and in struts.conf put only the spring bean name everything gets piped to the input result (the prepare method is executed, but not the action method).(2) I would benefit if the second scenario worked, because in the spring configuration is quite complex and have more than one bean of the same type (1) (struts.conf) (2) (struts.conf) (spring.xml) I hope someone can help me Si quieres ser más positivo, pierde un electrón Miguel Ruiz Velasco Sobrino - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org