0

I need to generate a report using iReport 5.0 for my EJB application.

When I'm calling report from my front end it works fine but when I'm trying to call same report in my EJB module it gives me a no class def found error.

This is how I call my report:

Map parameters = new HashMap();

parameters.put("Emp_ID", empNo);
parameters.put("From", startDate);
parameters.put("To", endDate);

Connection conn = DB_Conn.getDataBasConnection();
JasperDesign jDesign = JRXmlLoader.load("C:\\SalesRep_Sales_Sub01.jrxml");

JasperReport jasperReport = JasperCompileManager.compileReport(jDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters,conn);
JasperViewer.viewReport(jasperPrint,false);

And these are the libraries I use:

  • jasperreports-4.5.0
  • commons-beanutils-1.8.2
  • commons-collections-3.2.1
  • commons-digester-1.7
  • commons-javaflow-20060411
  • commons-logging-1.1
  • groovy-all-1.7.5
  • jcommon-1.0.15
  • jfreechart-1.0.12

Can someone please tell me what is the method to call my report from EJB and is there any additional libraries i should use.

Error report generate in output:

Exception in thread "AWT-EventQueue-0" javax.ejb.EJBException
    at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5215)
    at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5113)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4901)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994)
    at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:213)
    at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:79)
    at $Proxy175.getEmployeeSales(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:144)
    at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:174)
    at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:528)
    at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:199)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1624)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1486)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:990)
    at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:214)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:742)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:539)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2324)
    at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
    at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
    at BeansPerf.EmployeePerformance.getEmployeeSales(EmployeePerformance.java:75)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348)
    at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:206)
    ... 19 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.digester.Digester
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at com.sun.enterprise.v3.server.AppLibClassLoaderServiceImpl$URLClassFinder.findClass(AppLibClassLoaderServiceImpl.java:158)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 42 more

Simply I cannot call any method from imported jasperReport libraries.

Luke Woodward
  • 63,336
  • 16
  • 89
  • 104
SajithRu
  • 225
  • 1
  • 8
  • 24
  • Please add to your question the exception message of the NoClassDefFoundError, and perhaps also the first few lines of the stacktrace. (If the stacktrace is very deep, as it can be in JEE apps, don't feel you need to post the whole thing.) It's very difficult for us to help you if we don't know what class is missing (or what other class-loading problem there might be). – Luke Woodward Mar 31 '13 at 11:55
  • I added my exception message. as it says when I execute any method from imported iReport libraries it gives an exception saying NoClassDefFound. – SajithRu Apr 01 '13 at 02:03
  • You don't say what JEE container you are using (looks like GlassFish from the stacktrace - could you confirm this?). The class `org.apache.commons.digester.Digester` is part of the commons-digester-1.7 JAR, so it seems that your 'EJB Module', however it is deployed, is missing at least the commons-digester JAR. To be honest, I've not worked with GlassFish much, so I'm not sure how you would do this. – Luke Woodward Apr 01 '13 at 10:01
  • Yes its the GlassFish server I use. I have already all the above mentioned jar files to my EJB module. only thing is they not get called from GlassFish as I think. I hope there is a way to do that. – SajithRu Apr 02 '13 at 17:58
  • ever figure this out? – Johnny Z Sep 19 '13 at 17:48
  • nope. for this porject later deside to go without EJBs. but if you can give me a help it would be great :) – SajithRu Sep 19 '13 at 18:16

0 Answers0