掲示板
Trying to call Jasper iReport through portlet & getting error
16年前 に saurabh joshi によって更新されました。
Trying to call Jasper iReport through portlet & getting error
Junior Member 投稿: 47 参加年月日: 07/08/06 最新の投稿
Hi,
I have written the following code which is linked to a button in my portlet.
When I try to run this code I get the following error:
I have the following necessary files in my class path:
Please suggest me where I am going wrong.
Thanks & Regards
Saurabh.
I have written the following code which is linked to a button in my portlet.
package com.ext.portlet.drpdwn.action;
import com.liferay.portal.struts.PortletAction;
import com.liferay.portal.util.Constants;
import javax.portlet.WindowState;
import javax.servlet.jsp.PageContext;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import java.sql.*;
import javax.portlet.PortletException;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.engine.export.*;
public class QualityReportAction extends PortletAction
{
public void processAction(ActionMapping mapping, ActionForm form,PortletConfig config,ActionRequest req, ActionResponse res)
throws Exception
{
String typeofreport_val = req.getParameter("types_of_reports").trim();
System.out.println("Report Name is:" +typeofreport_val);
JasperReport jasperReport;
JasperPrint jasperPrint;
JasperDesign jasperDesign;
Connection connection = null;
if ( null == typeofreport_val || "".equals("typeofreport_val"))
{
setForward(req,"portlet.ext.drpdwn.error");
}
else
{
try
{
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://10.10.33.39:5432/globus_db?user=postgres&password=marines@123";
connection = DriverManager.getConnection(url);
// load JasperDesign from XML and compile it into JasperReport
jasperDesign = JRXmlLoader.load("C:/testRep/CCQR.jrxml");
jasperReport = JasperCompileManager.compileReport(jasperDesign);
// fill JasperPrint using fillReport() method
jasperPrint = JasperFillManager.fillReport(jasperReport,null,connection);
JasperExportManager.exportReportToPdfFile(jasperPrint,"C:/testRep/ccqr.pdf");
}
catch (SQLException ex)
{
setForward(req,"portlet.ext.drpdwn.error");
System.out.println("-------------------------------------------");
while (ex != null)
{
ex.printStackTrace();
ex = ex.getNextException();
}
System.out.println("-------------------------------------------");
}
catch(Exception e)
{
System.out.println("-------------------------------------------");
System.out.println("Exception is --> "+e);
System.out.println("-------------------------------------------");
}
setForward(req,"portlet.ext.drpdwn.success");
}
}
public ActionForward render(ActionMapping mapping,ActionForm form,PortletConfig config, RenderRequest req,RenderResponse res) throws Exception
{
if (getForward(req) != null && !getForward(req).equals(""))
{
return mapping.findForward(getForward(req));
}
else
{
return
mapping.findForward("portlet.ext.drpdwn.view");
}
}
}
When I try to run this code I get the following error:
exception javax.servlet.ServletException: Servlet execution threw an exception
com.liferay.filters.secure.SecureFilter.doFilter(SecureFilter.java:144)
com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.doFilter(VirtualHostFilter.java:136)
com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:126)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.liferay.filters.strip.StripFilter.doFilter(StripFilter.java:95)
com.liferay.filters.secure.SecureFilter.doFilter(SecureFilter.java:144)
com.liferay.filters.compression.CompressionFilter.doFilter(CompressionFilter.java:116)
com.liferay.filters.doubleclick.DoubleClickFilter.doFilter(DoubleClickFilter.java:138)
com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter.doFilter(LayoutCacheFilter.java:170)
com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.doFilter(AutoLoginFilter.java:106)
com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.doFilter(VirtualHostFilter.java:136)
root cause java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/xml/JRXmlLoader com.ext.portlet.drpdwn.action.QualityReportAction.processAction(QualityReportAction.java:59)
I have the following necessary files in my class path:
itext-1.3.1.jar
iReport.jar
commons-logging-1.0.2.jar
commons-javaflow-20060411.jar
commons-digester-1.7.jar
commons-collections-2.1.jar
commons-beanutils-1.7.jar
jasperreports-2.0.2.jar
jdt-compiler-3.1.1.jar
log4j-1.2.15.jar
xercesImpl.jar
Please suggest me where I am going wrong.
Thanks & Regards
Saurabh.
16年前 に Roman Hoyenko によって更新されました。
RE: Trying to call Jasper iReport through portlet & getting error
Liferay Master 投稿: 878 参加年月日: 07/10/08 最新の投稿
It doesn't find
java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/xml/JRXmlLoader
What do you mean "in my classpath" - where exactly are those classes and are they available to your app?
java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/xml/JRXmlLoader
What do you mean "in my classpath" - where exactly are those classes and are they available to your app?
16年前 に saurabh joshi によって更新されました。
RE: Trying to call Jasper iReport through portlet & getting error
Junior Member 投稿: 47 参加年月日: 07/08/06 最新の投稿
Hi Roman,
I apologize for replying so late.
Actually you almost gussed it right, although I mentioned the .jar files in the CLASSPATH but one of the .jar file was missing in my ..WEB-INF/lib dir.
So the issue is solved now.
Thanks for your time.
Saurabh.
I apologize for replying so late.
Actually you almost gussed it right, although I mentioned the .jar files in the CLASSPATH but one of the .jar file was missing in my ..WEB-INF/lib dir.
So the issue is solved now.
Thanks for your time.
Saurabh.