[Resolvido] Hibernate - iReport

7 respostas
TheKill

Pessoal, to fazendo uns testes com Hibernate
onde estou encontrando uma certa dificuldade para enviar os dados para o relatório…

Tenho a seguinte situação, um List do meu objeto Pais, onde contem a consulta do Banco…
Onde envio para o relatorio através de um JRBeanCollection. Só que da erro, e nao consegui identificar porque.

Sendo que já conferi o List e tem informação nele, ele da erro no JasperFillManager:

Collection<Pais> paisCollection = new ArrayList<Pais>();
        paisCollection.add((Pais) pais.get(0));
       
        try {
        JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(paisCollection);
		JasperPrint jp = JasperFillManager.fillReport(caminhoJasper, hm, ds);

7 Respostas

R

Stack trace?

fnandos

Não sei se vai te ajudar mais

JasperReport relatorio = (JasperReport) JRLoader.loadObject("/home/user/relatorios/teste.jasper");
JasperPrint impressao = new JasperPrint();			
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(resul);			
impressao = JasperFillManager.fillReport(relatorio, hs, ds);
TheKill

galera, já pesquisei um monte e ainda nao descobri porque:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Hibernate: 
    select
        this_.codigo as codigo1_0_,
        this_.nome as nome1_0_ 
    from
        Pais this_
Exception occurred during event dispatching:
java.lang.NoClassDefFoundError: Lorg/apache/commons/logging/Log;
	at java.lang.Class.getDeclaredFields0(Native Method)
	at java.lang.Class.privateGetDeclaredFields(Unknown Source)
	at java.lang.Class.getDeclaredField(Unknown Source)
	at java.io.ObjectStreamClass.getDeclaredSUID(Unknown Source)
	at java.io.ObjectStreamClass.access$700(Unknown Source)
	at java.io.ObjectStreamClass$2.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.io.ObjectStreamClass.<init>(Unknown Source)
	at java.io.ObjectStreamClass.lookup(Unknown Source)
	at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
	at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
	at java.io.ObjectInputStream.readClassDesc(Unknown Source)
	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
	at java.io.ObjectInputStream.readObject0(Unknown Source)
	at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
	at java.io.ObjectInputStream.readSerialData(Unknown Source)
	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
	at java.io.ObjectInputStream.readObject0(Unknown Source)
	at java.io.ObjectInputStream.readArray(Unknown Source)
	at java.io.ObjectInputStream.readObject0(Unknown Source)
	at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
	at java.io.ObjectInputStream.readSerialData(Unknown Source)
	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
	at java.io.ObjectInputStream.readObject0(Unknown Source)
	at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
	at java.io.ObjectInputStream.defaultReadObject(Unknown Source)
	at net.sf.jasperreports.engine.base.JRBaseReport.readObject(JRBaseReport.java:732)
	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 java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
	at java.io.ObjectInputStream.readSerialData(Unknown Source)
	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
	at java.io.ObjectInputStream.readObject0(Unknown Source)
	at java.io.ObjectInputStream.readObject(Unknown Source)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:90)
	at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:536)
	at br.com.caelum.hibernate.negocio.Relatorios.ListaPaisService.montaSql(ListaPaisService.java:47)
	at br.com.caelum.hibernate.apresentacao.util.impriPais.okButtonActionPerformed(impriPais.java:76)
	at br.com.caelum.hibernate.apresentacao.util.impriPais.access$3(impriPais.java:73)
	at br.com.caelum.hibernate.apresentacao.util.impriPais$4.actionPerformed(impriPais.java:167)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.Dialog$1.run(Unknown Source)
	at java.awt.Dialog$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.Dialog.show(Unknown Source)
	at java.awt.Component.show(Unknown Source)
	at java.awt.Component.setVisible(Unknown Source)
	at java.awt.Window.setVisible(Unknown Source)
	at java.awt.Dialog.setVisible(Unknown Source)
	at br.com.caelum.hibernate.apresentacao.cadastros.IFrmCadastroPais.imprimirCadastro(IFrmCadastroPais.java:282)
	at br.com.octal.util.ToolBarCadastro$6.actionPerformed(ToolBarCadastro.java:271)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 100 more
TheKill

linha 47

JasperPrint jp =JasperFillManager.fillReport("D:/projetos/java/octalHibernate/src/br/com/caelum/hibernate/iReport/relatorioPais.jasper", hm, jr);
fnandos
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log

Parece faltar um jar

TheKill

pior que eu também ja pensei isso…

Mas todos os jars estão corretos… inclusive esse que ta citando log4j

TheKill

Resolvido, era problema no meu relatorio…

Estava criando os objetos de maneira errada, ai a collection que eu passava nao encontrava nada no relatorio =x

aaff…

att. Jonas

Criado 23 de março de 2010
Ultima resposta 23 de mar. de 2010
Respostas 7
Participantes 3