Vraptor e JQGrid

E ai pessoal,

Estou tentando usar o JQGrid com vraptor mas não estou conseguindo, aparece no grid a quantidade de linhas que tenho no banco só que em branco.

Apresenta o seguinte erro:
16:12:15,521 WARN [CommonAnnotationBeanPostProcessor] Invocation of destroy method failed on bean with name ‘entityManagerCreator’: java.lang.IllegalStateException: EntityManager is closed

Segue os códigos:
Meu Dao

	public List<Chamado> listaTodos(){
		return dao.listaTodos();
	}

Minha classe JQgrid

[code]package br.com.xray.helpers;

import java.util.Collection;
import java.util.List;

import br.com.caelum.vraptor.ioc.Component;
import br.com.xray.modelo.Chamado;
@Component
public class JQgrid {

private int page;
private int total;
private int records;
private List rows;

public int getPage() {
    return page;
}

public void setPage(int page) {
    this.page = page;
}

public int getTotal() {
    return total;
}

public void setTotal(int total) {
    this.total = total;
}

public int getRecords() {
    return records;
}

public void setRecords(int records) {
    this.records = records;
}

public List getRows() {
    return rows;
}

public void setRows(List rows) {
    this.rows =  rows;
}

}
[/code]

JQGridRow

package br.com.xray.helpers;

import java.util.List;

import br.com.caelum.vraptor.ioc.Component;
@Component
public class JQGridRow {

	private Long id;  
    private List<?> cell;  
      
    public Long getId() {  
        return id;  
    }  
    public void setId(Long id) {  
        this.id = id;  
    }  
    public List<?> getCell() {  
        return cell;  
    }  
    public void setCell(List<?> cell) {  
        this.cell = cell;  
    }  
}

Meu Controller

	//testes
    @Path("/chamados/load-grid")
    public void loadGrid(){
    	JQgrid jqgrid = new JQgrid();  

        List rows = new ArrayList<JQGridRow>();  
    	List<Chamado> lista = chamadoDao.listaTodos();

        for (Chamado c : lista) {  
            JQGridRow row = new JQGridRow();  
            row.setId(c.getChamado_id());  
            
            List cells = new ArrayList();  

            cells.add(c.getChamado_id());
            System.out.println(cells);
            
            cells.add(c.getSolicitante());

            cells.add(c.getEquipamento());  
            System.out.println(cells);

            cells.add(c.getOcorrencia());
            System.out.println(cells);

            cells.add(c.getPrioridade());
            System.out.println(cells);

            
            row.setCell(cells);  
            rows.add(row);  
        }  
  
        jqgrid.setRows(rows);  
        jqgrid.setTotal(10);  
        jqgrid.setPage(1);  
        jqgrid.setRecords(10);  
        System.out.println(jqgrid);
        
        result.use(json())
        .withoutRoot()
        .from(jqgrid)
//        .exclude("usuario_logado_id","data")
        .include("rows").serialize();    
        System.out.println(jqgrid);
    }

Meu JSP

<script type="text/javascript">
function Busca() 
{

    $("#grid-user").jqGrid({
        url : "../chamados/load-grid",
        ajaxGridOptions: { contentType: 'application/json; charset=utf-8' }, //modificado  
        datatype : "json",
        colNames : [ 'Código', 'Solicitante', 'Ocorrência', 'Prioridade', 'Tipo' ],
        colModel : [ {
            name : 'chamado_id',
            index : 'chamado_id',
            width : 80,
            align : 'center'
        },
        {
            name : 'solicitante_id',
            index : 'solicitante_id',
            width : 230
        },
        {
            name : 'ocorrencia',
            index : 'ocorrencia',
            width : 150
        },
        {
            name : 'prioridade',
            index : 'prioridade',
            width : 100
        },
        {
            name : 'tipo',
            index : 'tipo',
            width : 80
        }
        ],
        rowNum : 10,
        pager : '#pager-user',
        height : 200,
        viewrecords : true,
        sortorder : "desc",
        jsonReader : {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            cell: "",
            id: "codigo"

        }
        
    });
    JQuery(grid-user).jqGrid('navGrid','#pager-user',{edit:false,add:false,del:false});
	  
}
</script>

						<input type="button" value="Pesquisar" onclick="Busca()"/> 


 <table id="grid-user" >
 </div> 
 </table>
 <div id="pager-user"></div>		

funciona colocar o .recursive() no result json?

Lucas, tudo bem!

coloquei o recursive() ai apresentou o erro abaixo.

 result.use(Results.json())
        .withoutRoot()
        .from(jqgrid)
        .include("rows")
        .recursive()
        .serialize(); 
[br.com.xray.helpers.JQGridRow@f67d81, br.com.xray.helpers.JQGridRow@a9a1ac, br.com.xray.helpers.JQGridRow@b52598, br.com.xray.helpers.JQGridRow@b72ce1, br.com.xray.helpers.JQGridRow@1e384de, br.com.xray.helpers.JQGridRow@280bca, br.com.xray.helpers.JQGridRow@11dfada, br.com.xray.helpers.JQGridRow@14021a9, br.com.xray.helpers.JQGridRow@161f888, br.com.xray.helpers.JQGridRow@103c520, br.com.xray.helpers.JQGridRow@82b865, br.com.xray.helpers.JQGridRow@17fe89]
30/10/2012 22:29:33 org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet default threw exception
br.com.caelum.vraptor.InterceptionException: exception raised, check root cause for details: java.lang.NullPointerException
	at br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:96)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
	at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
	at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
	at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
	at br.com.caelum.vraptor.util.jpa.JPATransactionInterceptor.intercept(JPATransactionInterceptor.java:51)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
	at br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:48)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
	at br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:71)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
	at br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:83)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
	at br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
	at br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:44)
	at br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:91)
	at br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
	at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:88)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
	at java.lang.Class.isAssignableFrom(Native Method)
	at br.com.caelum.vraptor.serialization.xstream.VRaptorClassMapper.serializedClass(VRaptorClassMapper.java:78)
	at com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass(MapperWrapper.java:34)
	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:58)
	at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:55)
	at com.thoughtworks.xstream.core.TreeMarshaller.convert(TreeMarshaller.java:86)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:78)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:157)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:148)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:118)
	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:129)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:100)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:58)
	at com.thoughtworks.xstream.core.TreeMarshaller.convert(TreeMarshaller.java:86)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:78)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:63)
	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
	at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:55)
	at com.thoughtworks.xstream.core.TreeMarshaller.convert(TreeMarshaller.java:86)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:78)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:157)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:148)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.visit(AbstractReflectionConverter.java:118)
	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:129)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:100)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:58)
	at com.thoughtworks.xstream.core.TreeMarshaller.convert(TreeMarshaller.java:86)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:78)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:63)
	at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:98)
	at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:38)
	at com.thoughtworks.xstream.XStream.marshal(XStream.java:837)
	at com.thoughtworks.xstream.XStream.marshal(XStream.java:826)
	at com.thoughtworks.xstream.XStream.toXML(XStream.java:801)
	at br.com.caelum.vraptor.serialization.xstream.XStreamSerializer.serialize(XStreamSerializer.java:142)
	at br.com.xray.controller.ChamadosController.loadGrid(ChamadosController.java:130)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:61)
	... 39 more
22:29:33,571  WARN [CommonAnnotationBeanPostProcessor] Invocation of destroy method failed on bean with name 'entityManagerCreator': java.lang.IllegalStateException: EntityManager is closed

Estou achando que o problema não está no grid porque até com tabela está trazendo as linhas vazias.

Estava vendo alguns tópicos sobre LazyInitializationException, mas não encontrei como configurar no vraptor, será que não é isso? porque no final ele fala q minha configuração está fechada.

valeu Lucas pela ajuda.

com o recursive vc precisa tirar o include(“rows”)

qto ao lazy init, não eh uma configuração no vraptor, eh no hibernate…

se vc está usando o componente do vraptor pra gerar o EntityManager, ele fica aberto durante a requisicao inteira. e se vc tah fazendo isso vc não deveria fechar o entityManager na mão, o proprio vraptor faz isso.