struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken McWilliams <ken.mcwilli...@gmail.com>
Subject Re: REST question
Date Tue, 11 Feb 2014 21:42:47 GMT
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 <miguelrvs@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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message