Jump to content
JasperReports Library 7.0 is now available ×

OutofMemory Error - Exception


Recommended Posts

By: srav01 - srav01

OutofMemory Error - Exception

2006-05-11 18:55

I am getting a Out of Memory Error while accessing the PDF report (using JasperReports). The Jasper verion used is .0.6.6 on Websphere application server 5.1.3.with code compiled in JDK 1.4.2

 

can anybody help ASAP as this is happening in production environment.

 

we are using custom datasource using interface JRDataSource

 

public class ProducerDataSource implements JRDataSource {

 

private List mList = null;

private int mCounter = 0;

private int mSize;

/** reference to the Logging Framework */

private static final Logger LOGGER = Logger.getLogger(ProducerDataSource.class.getName());

 

/**

* Constructor for ProducerDataSource

* @param argList

*/

public ProducerDataSource(List argList){

//LOGGER.debug(Constants.ENTER_METHOD);

 

if (argList == null)

{

throw new IllegalArgumentException("argList must not be null");

}

mList = argList;

mSize = mList.size();

LOGGER.debug(Constants.EXIT_METHOD);

}

/**

* @return boolean

*/

public boolean next(){

// LOGGER.debug(Constants.ENTER_METHOD);

 

if (mCounter < mSize){

mCounter = mCounter +1;

LOGGER.debug(Constants.EXIT_METHOD);

return true;

}

else {

LOGGER.debug(Constants.EXIT_METHOD);

return false;

}

 

}

 

/**

* @param argJrField

* @return Object

*/

public Object getFieldValue(JRField argJrField){

 

String fieldName = argJrField.getName();

 

Object obj1 = null;

String methodName = "get" + fieldName;

 

 

Class clazz = argJrField.getValueClass();

 

 

obj1 = (Object)mList.get(mCounter-1);

 

Class classObj = obj1.getClass();

 

Method method = null;

 

Method[] methods = classObj.getMethods();

 

int size=methods.length;

 

for (int i =0;i< size; i++){

method = methods;

int index = method.getName().indexOf(methodName);

if (index != -1){

break;

}

}

Object obj = null;

Object xx = null;

try{

obj = method.invoke(obj1,null);

 

}

catch(Exception e){

//LOGGER.debug("exception :"+e.getMessage());

}

 

if (obj != null) {

 

if (clazz.equals(java.lang.Integer.class))

{

String y = obj.toString();

obj = new Integer((String)y);

 

}

else if (clazz.equals(java.lang.Float.class))

{

String y = obj.toString();

obj = new Float((String)y);

}

else if(clazz.equals(java.util.Date.class))

{

String y = obj.toString();

obj = new Date((String)y);

}

else if(clazz.equals(java.lang.String.class))

{

 

 

String y = obj.toString();

obj = y;

 

}

else if(clazz.equals(java.math.BigDecimal.class))

{

 

 

String y = obj.toString();

obj = new BigDecimal((String)y);

 

}

else if(clazz.equals(java.lang.Double.class))

{

 

 

String y = obj.toString();

obj = new Double((String)y);

 

}

return obj;

}

 

else return null;

 

}

}

 

/**

* Exports Jasperprint object PDF

* @param report of type JasperPrint

* @return byte array

* @throws JRException

*/

public static byte[] exportPdfReport(JasperPrint argReport)

throws JRException {

 

LOGGER.debug(Constants.ENTER_METHOD);

 

byte[] pdfByteArray = JasperExportManager.exportReportToPdf(argReport);

 

LOGGER.debug(Constants.ENTER_METHOD);

 

return pdfByteArray;

}

 

/**

* This Method Outputs the byte array PDF with

* content type set to PDF format

* @param response

* @return byte array

* @throws IOException

*/

 

public static void sendPdfResponse(

HttpServletResponse response,

byte[] pdfByteArray)

throws IOException {

 

LOGGER.debug(Constants.ENTER_METHOD);

 

response.setHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_PDF);

response.setContentLength(pdfByteArray.length);

 

OutputStream out = response.getOutputStream();

out.write(pdfByteArray, 0, pdfByteArray.length);

out.flush();

out.close();

 

LOGGER.debug(Constants.EXIT_METHOD);

}

 

Thanks

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...