Hi Ken,

Thanks for the pointer, In fact the app uses open session in view with a
custom interceptor, but does the REST Plugin changes the struts-default and
the json-default packages when you include the
struts2-rest-plugin-2.3.16.jar?


That could explain what is happening, but, how I assing the rest-default
stack to my Rest controllers ONLY, and the other 'old' actions continue to
work with the custom stack (Spring + Open_session_in_view +
paramsPrepareParamsStack), based on package json-default? It's a rather big
application and can't be refactored to be REST only.

Thanks for your time reading an replying the question.




Si quieres ser más positivo, pierde un electrón
Miguel Ruiz Velasco Sobrino


On Tue, Feb 11, 2014 at 3:42 PM, Ken McWilliams <ken.mcwilli...@gmail.com>wrote:

> Sounds like you have used the Open Session in View method... probably
> provided by a custom interceptor, when adding the rest plugin you have
> changed your action to the rest package and forgot to put your interceptor
> back in place, so now you don't have a hibernate session and the view
> generates this error.
>
>
> On Mon, Feb 10, 2014 at 10:40 PM, Miguel <miguel...@gmail.com> wrote:
>
> > Hi,
> >
> > A strange situation happens when I load *struts2-rest-plugin-2.3.16.jar*
> > With out the REST plugin my action and jsp's works as always has worked.
> > But with the mere inclusion of the REST Plugin, some jsp's stops finding
> > variables, because the variable name changes.
> > Here is the snippet:
> >
> > struts.xml
> >
> >     <constant name="struts.objectFactory"
> > value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> >     <constant name="struts.objectFactory.spring.autoWire" value="name" />
> >     <package name="proyectox" extends="json-default" >
> > <!-- Si no le pones este stack, pues no funciona...-->
> >         <interceptors>
> >             <interceptor name="strutsSpring"
> >
> >
> class="com.proyectox.ui.interceptor.HibernateOpenSessionInViewInterceptor"/>
> >             <interceptor name="viewuseragentselector"
> > class="com.proyectox.ui.interceptor.UserAgentResultInterceptor"/>
> >             <interceptor-stack name="strutsSpringPPPStack">
> >                 <interceptor-ref name="strutsSpring"/>
> >                 <interceptor-ref name="paramsPrepareParamsStack"/>
> >                 <interceptor-ref name="viewuseragentselector"/>
> >             </interceptor-stack>
> >         </interceptors>
> > ...
> >     </package>
> >
> >     <package name="cfdi" extends="proyectox" namespace="/cfdi">
> >         <action name="header_*" class="com.fcm.cfdi.ui.HeaderAction">
> >             <result type="redirectAction">
> >                 <param name="actionName">edit</param>
> >             </result>
> > <!--            <result >printHeader.jsp</result>-->
> >             <result name="input">headerEdit.jsp</result>
> >             <result name="error">/facturaerror.jsp</result>
> >             <interceptor-ref name="scope">
> >                 <param name="session">contribuyente</param>
> >                 <param name="autoCreateSession">true</param>
> >                 <param name="key">contribuyenteActual</param>
> >             </interceptor-ref>
> >             <interceptor-ref name="scope">
> >                 <param name="session">factura</param>
> >                 <param name="autoCreateSession">false</param>
> >                 <param name="key">cfdi</param>
> >             </interceptor-ref>
> >             <interceptor-ref name="strutsSpringPPPStack"/>
> >         </action>
> >
> >
> >
> > HeaderAction.java:
> >
> > public class HeaderAction extends ActionSupport implements Preparable {
> >     protected Contribuyente contribuyente;
> >     protected Long contribuyenteId;
> >
> >     public void prepare() throws Exception {
> >     ...
> >     }
> >
> >
> >     public String input(){
> >
> >         dirReceptorId = factura.getDomicilioReceptor().getId();
> >         dirEmisionId  = factura.getDomicilioEmision().getId();
> >         return INPUT;
> >     }
> > ...
> >     public Contribuyente getContribuyente() {
> >         return contribuyente;
> >     }
> >
> >     public void setContribuyente(Contribuyente contribuyente) {
> >         this.contribuyente = contribuyente;
> >     }
> > ...
> > }
> >
> > edit.jsp:
> > ...
> >     <s:select label="Direccion Emision"
> >        name="dirEmisionId"
> >        list="*contribuyente*.domicilios"
> >        listKey="id"
> >        listValue="nombre"
> >        multiple="false"
> >        size="1"
> >        required="true"
> >        key="factura.direccionEmision.id"
> >     />
> > ...
> >
> > After loading *struts2-rest-plugin-2.3.16.jar* it starts giving the
> > following exception:
> > Caused by: org.hibernate.LazyInitializationException: failed to lazily
> > initialize a collection of role: *contribuyentes.domicilios*, no session
> or
> > session was closed
> > ...
> >
> > I know that's a Hibernate exception, but the jsp works fine without the
> > REST Plugin.
> > It's like the REST Plugin appends that extra "s" after the variable name
> in
> > the .jsp or the value stack changes or something like that.
> >
> > The action is invoked without error in either case, and has into it's
> > fields the required values.
> >
> >
> > Does anyone has any pointer of what can be happening?
> >
> > Thanks
> >
> > Si quieres ser más positivo, pierde un electrón
> > Miguel Ruiz Velasco Sobrino
> >
>

Reply via email to