Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Problem when generating dynamic tables(OutOfMemory error)
Problem when generating dynamic tables [message #929664] Mon, 01 October 2012 16:48 Go to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Hello all
I have a web application developed in PHP and integrated with birt by PhpJavaBridge. My birt version is 2.6.2. I have an class in java wich i use like an factory to build report itens as php request them.
My JAVA_OPTS was set like in my catalina.bat:

set JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx1024m -XX:MaxPermSize=512m -Djava.awt.headless=true

The report itens are built fine, i can see them in the report design, test connection success, preview datasets ..... verything looks like ok. But when i run the report it gives me the error
in eclipse
java.lang.ClassCastException: java.lang.OutOfMemoryError cannot be cast to java.lang.Exception

in tomcat
Exception in thread "http-apr-9191-exec-5" java.lang.OutOfMemoryError: Java heap
 space
        at org.eclipse.birt.core.util.IOUtil.readUTF(IOUtil.java:1173)
        at org.eclipse.birt.core.util.IOUtil.readString(IOUtil.java:810)
        at org.eclipse.birt.data.engine.executor.cache.ResultObjectUtil.readData
(ResultObjectUtil.java:187)
        at org.eclipse.birt.data.engine.executor.dscache.CacheUtilFactory$DiskLo
adUtil.loadObject(CacheUtilFactory.java:552)
        at org.eclipse.birt.data.engine.executor.dscache.DataSetFromCache.loadOb
ject(DataSetFromCache.java:76)
        at org.eclipse.birt.data.engine.executor.dscache.DataSetFromCache.fetch(
DataSetFromCache.java:58)
        at org.eclipse.birt.data.engine.executor.cache.OdiAdapter.fetch(OdiAdapt
er.java:222)
        at org.eclipse.birt.data.engine.executor.cache.RowResultSet.next(RowResu
ltSet.java:105)
        at org.eclipse.birt.data.engine.executor.cache.ExpandableRowResultSet.ne
xt(ExpandableRowResultSet.java:63)
        at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.populate
Data(SmartCacheHelper.java:316)
        at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.initInst
ance(SmartCacheHelper.java:285)
        at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.getResul
tSetCache(SmartCacheHelper.java:246)
        at org.eclipse.birt.data.engine.executor.cache.SmartCache.<init>(SmartCa
che.java:73)
        at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.populat
eOdiResultSet(PassUtil.java:142)
        at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.pass(Pa
ssUtil.java:62)
        at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.doSi
nglePass(PassManager.java:211)
        at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.prep
areDataSetResultSet(PassManager.java:94)
        at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.pass
(PassManager.java:125)
        at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.popu
lateResultSet(PassManager.java:74)
        at org.eclipse.birt.data.engine.executor.transform.ResultSetPopulator.po
pulateResultSet(ResultSetPopulator.java:198)
        at org.eclipse.birt.data.engine.executor.transform.CachedResultSet.<init
>(CachedResultSet.java:154)
        at org.eclipse.birt.data.engine.executor.DataSourceQuery.execute(DataSou
rceQuery.java:1012)
        at org.eclipse.birt.data.engine.impl.PreparedOdaDSQuery$OdaDSQueryExecut
or.executeOdiQuery(PreparedOdaDSQuery.java:441)
        at org.eclipse.birt.data.engine.impl.QueryExecutor.execute(QueryExecutor
.java:1103)
        at org.eclipse.birt.data.engine.impl.ServiceForQueryResults.executeQuery
(ServiceForQueryResults.java:232)
        at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(Quer
yResults.java:173)
        at org.eclipse.birt.report.engine.data.dte.QueryResultSet.<init>(QueryRe
sultSet.java:98)
        at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(
DteDataEngine.java:168)
        at org.eclipse.birt.report.engine.data.dte.DataGenerationEngine.doExecut
eQuery(DataGenerationEngine.java:80)
        at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(Ab
stractDataEngine.java:265)
        at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery
(ExecutionContext.java:1890)
        at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuer
y(QueryItemExecutor.java:80)
Re: Problem when generating dynamic tables [message #929736 is a reply to message #929664] Mon, 01 October 2012 18:10 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you post your code? Verify that all tasks get closed and that the engine only gets started once for the life of the application,

Jason
Re: Problem when generating dynamic tables [message #929740 is a reply to message #929736] Mon, 01 October 2012 18:19 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Sure this is my builder/factory java class called from php
package builder;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.model.api.DataItemHandle;
import org.eclipse.birt.report.model.api.DataSetHandle;
import org.eclipse.birt.report.model.api.DataSourceHandle;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.DesignElementHandle;
import org.eclipse.birt.report.model.api.ElementFactory;
import org.eclipse.birt.report.model.api.IDesignEngine;
import org.eclipse.birt.report.model.api.IDesignEngineFactory;
import org.eclipse.birt.report.model.api.LabelHandle;
import org.eclipse.birt.report.model.api.OdaDataSetHandle;
import org.eclipse.birt.report.model.api.OdaDataSourceHandle;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.SessionHandle;
import org.eclipse.birt.report.model.api.SlotHandle;
import org.eclipse.birt.report.model.api.StructureFactory;
import org.eclipse.birt.report.model.api.StyleHandle;
import org.eclipse.birt.report.model.api.TableHandle;
import org.eclipse.birt.report.model.api.TextItemHandle;
import org.eclipse.birt.report.model.api.activity.SemanticException;
import org.eclipse.birt.report.model.api.command.ContentException;
import org.eclipse.birt.report.model.api.command.NameException;
import org.eclipse.birt.report.model.api.command.StyleException;
import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants;
import org.eclipse.birt.report.model.api.elements.structures.ComputedColumn;

import com.ibm.icu.util.ULocale;


public class ReportBuilder
{
	public static final String DefaultTableStyle = "defaultTableStyle";
	public static final String DefaultHeaderStyle = "defaultHeaderStyle";
	public static final String DefaultDetailStyle = "defaultDetailStyle";
	public static final String DefaultLabelStyle = "defaultLabelStyle";
	public static final String DefaultReportItemStyle = "defaultReportItemStyle";
	private static final String ON_PREPARE = "onPrepare";
	private static final String ON_CREATE = "onCreate";
	private static final String ON_RENDER = "onRender";
	private static final String ON_PAGE_BREAK = "onPageBreak";
	
	static Map<String, String> scriptMap = new HashMap<String, String>();
	static ReportDesignHandle designHandle = null;
	static ElementFactory designFactory = null;
	static StructureFactory structFactory = null;
	static SessionHandle session = null;
	static IDesignEngine designEngine = null;
	static DesignConfig designConfig = null;
	static IDesignEngineFactory factory = null;
	private String reportPath = null;
	
	public void prepareOnPrepare(String script){
		scriptMap.put(ON_PREPARE, script);
	}
	
	public void prepareOnCreate(String script){
		scriptMap.put(ON_CREATE, script);
	}
	
	public void prepareOnRender(String script){
		scriptMap.put(ON_RENDER, script);
	}
	
	public void prepareOnPageBreak(String script){
		scriptMap.put(ON_PAGE_BREAK, script);
	}

	/**
	 * Called externally
	 * @param title
	 */
	public void setReportTitle(String title){
		//Define titulo do relatório como o parametro
		try {
			designHandle.setTitle( title );
		} catch (SemanticException e) {
			System.out.println("ERROR: Report title cannot be null !");
			e.printStackTrace();
		}
	}
	
	/**
	 * Called externally 
	 * @param author
	 */
	public void setReportAuthor(String author){
		//Define titulo do relatório como o parametro
		designHandle.setAuthor( author );
	}
	
	/**
	 * Called externally
	 * @param templatePath
	 * @param birtHome
	 */
	public void initReport(String templatePath, String birtHome){
		try{
			System.out.print(".....Build Report initiated!");
			
			reportPath = templatePath;
			designConfig = new DesignConfig();
	        designConfig.setBIRTHome(birtHome);
	        // Startup plugins.
	        Platform.startup( designConfig );
	        // Open de report design file.
			openDesign();
			// Removes design elements
			dropReportObjects();
			// Create default element style.
			createStyles();
		}catch (Exception e) {
			System.out.println("..........ERROR!");
			e.printStackTrace();
		}
	}
	
	private void openDesign() throws Exception{
		try{
			System.out.print("\n.....Searching for template");
			
			factory = (IDesignEngineFactory) Platform.createFactoryObject( IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
			designEngine = factory.createDesignEngine( designConfig );
			session = designEngine.newSessionHandle( ULocale.ENGLISH ) ;
			File templateFile = new File(reportPath);
			if(templateFile.exists()) {
				System.out.println("..........done!");
				designHandle = session.openDesign( reportPath );
			} else {
				System.out.println("..........template not found!");
				System.out.print(".....Creating new design");
				designHandle = session.createDesign();
				System.out.println("..........done!");
			}
			
			designFactory = designHandle.getElementFactory( );
			
		}catch( Exception ex){
 			throw ex;
		}
	}
	
	/**
	 * Called externally
	 * @throws IOException
	 */
	public void closeReport()throws IOException{
		try{
			System.out.print(".....Saving report");
			designHandle.saveAs(reportPath);
			designHandle.close();
//			session.closeAll(true);
		}catch(IOException e){
			System.out.println("..........ERROR!");
			e.printStackTrace();
		} finally {
			System.out.println(".....Finished!");
			Platform.shutdown();
		}
	}
	
	/**
	 * Called externally
	 * @param name
	 * @param url
	 * @param user
	 * @param password
	 * @return OdaDataSourceHandle
	 */
	public OdaDataSourceHandle buildDataSource(String name, String url,String user, String password)
	{
		System.out.print(".....Creating dataSource: \""+name+"\"");
		try {
			OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource("dataSource_"+name, "org.eclipse.birt.report.data.oda.jdbc" );
			dsHandle.setProperty( "odaDriverClass", "oracle.jdbc.OracleDriver" );
			dsHandle.setProperty( "odaURL", url );
			dsHandle.setProperty( "odaUser", user );
			dsHandle.setProperty( "odaPassword", password );
			//dsHandle.setProperty( "odaJndiName", jndi );
			designHandle.getDataSources( ).add( dsHandle );
			
			System.out.println("..........done!");
			
			return dsHandle;
		} catch (Exception e) {
			System.out.println("..........ERROR!");
			e.printStackTrace();
			return null;
		}
	}

	/**
	 * Called externally
	 * @param name
	 * @param query
	 * @param dataSource
	 * @return
	 * @throws Exception
	 */
	public DataSetHandle buildDataSet(String name, String query ,DataSourceHandle dataSource)
	{
		System.out.print(".....Creating dataSet: \""+name+"\"");
		try {
			OdaDataSetHandle dsHandle = designFactory.newOdaDataSet( "dataSet_"+name, "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
			dsHandle.setDataSource( dataSource.getName() );
			dsHandle.setQueryText( query );
			designHandle.getDataSets( ).add( dsHandle );
			
			System.out.println("..........done!");
			
			return dsHandle;
		} catch (Exception e) {
			System.out.println("..........ERROR!");
			e.printStackTrace();
			return null;
		}
	}

	/**
	 * Called externally
	 * @param name
	 * @param text
	 */
	public void addToDesign(DesignElementHandle item)
	{
		System.out.print(".....Building item: \""+item.getName()+"\"");
		try {
			designHandle.getBody( ).add( item );
			System.out.println("..........done!");
		} catch (ContentException e) {
			System.out.print("Error adding item to design.\n"+e.getMessage());
			e.printStackTrace();
		} catch (NameException e) {
			System.out.print("Error adding item to design.\n"+e.getMessage());
			e.printStackTrace();
		}
	}

	/**
	 * Called externally
	 * @param name
	 * @param text
	 * @return
	 */
	public TextItemHandle createTextItem(String name, String text, String contentType, DataSetHandle dataSet, 
			ArrayList<String>columnBindings, HashMap<String, String> properties)
	{
		System.out.print(".....Creating text item: \""+name+"\"");
		
		TextItemHandle textItem = designFactory.newTextItem("textItem_"+name);
		try {
			if (contentType.equalsIgnoreCase("auto")) {
				textItem.setContentType( DesignChoiceConstants.TEXT_CONTENT_TYPE_AUTO );
			} else if (contentType.equalsIgnoreCase("html")) {
				textItem.setContentType( DesignChoiceConstants.TEXT_CONTENT_TYPE_HTML );
			} else if (contentType.equalsIgnoreCase("plain")) {
				textItem.setContentType( DesignChoiceConstants.TEXT_CONTENT_TYPE_PLAIN );
			} else if (contentType.equalsIgnoreCase("rtf")) {
				textItem.setContentType( DesignChoiceConstants.TEXT_CONTENT_TYPE_RTF );
			}
			
			
			if(dataSet != null) {
				textItem.setDataSet( dataSet );
			}
			if(columnBindings != null) {
				ComputedColumn dataBinding = null;
				for(String binding : columnBindings) {
					dataBinding = StructureFactory.createComputedColumn();
					dataBinding.setName(binding);
					dataBinding.setExpression("dataSetRow[\"" + binding + "\"]");
					textItem.addColumnBinding(dataBinding, false);
				}
			}
			textItem.setStyleName( DefaultReportItemStyle );
			textItem.setContent(text);
			
			textItem = (TextItemHandle)createElementProperties(textItem, properties);
			
			System.out.println("..........done!");
			return textItem;
		} catch (SemanticException e) {
			System.out.println("..........ERROR!");
			e.printStackTrace();
			return null;
		}
	}
	
	/**
	 * Called externally
	 * @param name
	 * @param colSize
	 * @param ds
	 * @return
	 */
	public BirtReportTableHandler createTable(String name, int colSize, DataSetHandle ds, HashMap<String, String> properties)
	{
		try {
			System.out.print(".....Creating table item: \""+name+"\"");
			
			BirtReportTableHandler table = new BirtReportTableHandler(designFactory.newTableItem("table_"+name, colSize), ds);
			
			table.setHandler((TableHandle)createElementProperties(table.getHandler(), properties));
			
			System.out.println("..........done!");
			return table;
		} catch (Exception e) {
			System.out.println("Error creating table: "+name+"\n"+e.getMessage());
			e.printStackTrace();
			return null;
		}
	}
	
	/**
	 * Called externally
	 * @param name
	 * @param text
	 * @return
	 * @throws Exception
	 */
	public LabelHandle createLabel(String name, String text, HashMap<String, String> properties){
		try {
			System.out.print(".....Creating label item: \""+name+"\"");
			
			LabelHandle label = designFactory.newLabel( "label_"+name );  
			label.setStyleName( DefaultLabelStyle );
			label.setText( text );
			
			label = (LabelHandle)createElementProperties(label, properties);
			
			System.out.println("..........done!");
			return label;
		} catch (ContentException e) {
			System.out.println("Error creating label: "+name+"\n"+e.getMessage());
			e.printStackTrace();
		} catch (NameException e) {
			System.out.println("Error creating label: "+name+"\n"+e.getMessage());
			e.printStackTrace();
		} catch (StyleException e) {
			System.out.println("Error creating label: "+name+"\n"+e.getMessage());
			e.printStackTrace();
		} catch (SemanticException e) {
			System.out.println("Error creating label: "+name+"\n"+e.getMessage());
			e.printStackTrace();
		}
		
		return null;
	}

	/**
	 * Called externally
	 * @param name
	 * @param expression
	 * @param dataSet
	 * @param resultSetCol
	 * @param columnBindings
	 * @return
	 * @throws Exception
	 */
	public DataItemHandle createDataItem(String name, String expression, DataSetHandle dataSet, String resultSetCol, 
			ArrayList<String>columnBindings, HashMap<String, String> properties) {
		System.out.print(".....Creating data item: \""+name+"\"");
		
		DataItemHandle data = designFactory.newDataItem( "data_"+name );
		try {
			data.setStyleName( DefaultDetailStyle );
			if(dataSet != null) {
				data.setDataSet( dataSet );
				data.setResultSetColumn( resultSetCol );
			}
			if(columnBindings != null) {
				ComputedColumn dataBinding = null;
				for(String binding : columnBindings) {
					dataBinding = StructureFactory.createComputedColumn();
					dataBinding.setName(binding);
					dataBinding.setExpression("dataSetRow[\"" + binding + "\"]");
					data.addColumnBinding(dataBinding, false);
				}
			}
			
			data = (DataItemHandle)createElementProperties(data, properties);
			
			System.out.println("..........done!");			
			return data;
		} catch (StyleException e) {
			System.out.println("Error creating data item: "+name+"\n"+e.getMessage());
			e.printStackTrace();
			return null;
		} catch (SemanticException e) {
			System.out.println("Error creating data item: "+name+"\n"+e.getMessage());
			e.printStackTrace();
			return null;
		}
	}
	
	@SuppressWarnings("unchecked")
	private void dropReportObjects()throws Exception{
		try{
			Iterator<Object> reportItens = designHandle.getBody().getContents().iterator();
			while(reportItens.hasNext()){
				DesignElementHandle designHandler = (DesignElementHandle)reportItens.next();
				designHandler.drop();
			}
			
			SlotHandle dataSets = designHandle.getDataSets( );
			Iterator<DataSetHandle> itDataset = dataSets.iterator();
			while(itDataset.hasNext()) {
				DataSetHandle dataSet = itDataset.next();
				dataSet.drop();
			}
			
			SlotHandle dataSources = designHandle.getDataSources( );
			
			Iterator<DataSourceHandle> itDatasource = dataSources.iterator();
			while(itDatasource.hasNext()) {
				DataSourceHandle dataSource = itDatasource.next();
				dataSource.drop();
			}

		} catch (Exception e){
			throw e;
		}
	}
	


	public static DesignElementHandle createElementProperties(DesignElementHandle element, HashMap<String, String> properties) throws SemanticException {
		
		if(properties != null) {
			try {
				if(properties.get("borderLeft") != null) {
					element.setProperty(StyleHandle.BORDER_LEFT_WIDTH_PROP, properties.get("borderLeft"));
					element.setProperty(StyleHandle.BORDER_LEFT_STYLE_PROP, DesignChoiceConstants.LINE_STYLE_SOLID );
					element.setProperty(StyleHandle.BORDER_LEFT_COLOR_PROP, "#000000");
				}
				if(properties.get("borderRight") != null) {
					element.setProperty(StyleHandle.BORDER_RIGHT_WIDTH_PROP, properties.get("borderRight"));
					element.setProperty(StyleHandle.BORDER_RIGHT_STYLE_PROP, DesignChoiceConstants.LINE_STYLE_SOLID );
					element.setProperty(StyleHandle.BORDER_RIGHT_COLOR_PROP, "#000000");
				}
				if(properties.get("borderTop") != null) {
					element.setProperty(StyleHandle.BORDER_TOP_WIDTH_PROP, properties.get("borderTop"));
					element.setProperty(StyleHandle.BORDER_TOP_STYLE_PROP, DesignChoiceConstants.LINE_STYLE_SOLID );
					element.setProperty(StyleHandle.BORDER_TOP_COLOR_PROP, "#000000");
				}
				if(properties.get("borderBottom") != null) {
					element.setProperty(StyleHandle.BORDER_BOTTOM_WIDTH_PROP, properties.get("borderBottom"));
					element.setProperty(StyleHandle.BORDER_BOTTOM_STYLE_PROP, DesignChoiceConstants.LINE_STYLE_SOLID );
					element.setProperty(StyleHandle.BORDER_BOTTOM_COLOR_PROP, "#000000");
				}
				if(properties.get("paddingLeft") != null) element.setProperty(StyleHandle.PADDING_LEFT_PROP, properties.get("paddingLeft"));
				if(properties.get("paddingRight") != null) element.setProperty(StyleHandle.PADDING_RIGHT_PROP, properties.get("paddingRight"));
				if(properties.get("paddingTop") != null) element.setProperty(StyleHandle.PADDING_TOP_PROP, properties.get("paddingTop"));
				if(properties.get("paddingBottom") != null) element.setProperty(StyleHandle.PADDING_BOTTOM_PROP, properties.get("paddingBottom"));
				if(properties.get("marginLeft") != null) element.setProperty(StyleHandle.MARGIN_LEFT_PROP, properties.get("marginLeft"));
				if(properties.get("marginRight") != null) element.setProperty(StyleHandle.MARGIN_RIGHT_PROP, properties.get("marginRight"));
				if(properties.get("marginTop") != null) element.setProperty(StyleHandle.MARGIN_TOP_PROP, properties.get("marginTop"));
				if(properties.get("marginBottom") != null) element.setProperty(StyleHandle.MARGIN_BOTTOM_PROP, properties.get("marginBottom"));
			} catch (SemanticException e) {
				throw e;
			}
		}
		
		return element;
	}
	
	private void createStyles( ) throws Exception{
		 try{
			 //Style da Table
			 StyleHandle tableStyle = designFactory.newStyle( DefaultTableStyle );
			 tableStyle.setProperty(StyleHandle.CAN_SHRINK_PROP, true);

			 designHandle.getStyles( ).add( tableStyle );
			 
			 //Cria o Style do label
			 StyleHandle labelStyle = designFactory.newStyle( DefaultLabelStyle );
			 labelStyle.setProperty( StyleHandle.FONT_WEIGHT_PROP,DesignChoiceConstants.FONT_WEIGHT_BOLD );
			 labelStyle.setProperty( StyleHandle.FONT_SIZE_PROP, DesignChoiceConstants.FONT_SIZE_X_SMALL);
			 labelStyle.setProperty( StyleHandle.FONT_FAMILY_PROP, "Arial" );
			 labelStyle.setProperty( StyleHandle.COLOR_PROP, "#000000" );
			 labelStyle.setProperty( StyleHandle.PADDING_LEFT_PROP, "2" );
			 labelStyle.setProperty( StyleHandle.PADDING_RIGHT_PROP, "2" );
			 labelStyle.setProperty( StyleHandle.PADDING_BOTTOM_PROP, "8" );
			 labelStyle.setProperty( StyleHandle.TEXT_ALIGN_PROP, "Left" );
			 
			 
			 designHandle.getStyles( ).add( labelStyle );
			 
			 //Cria o Style do detalhe
			 StyleHandle dataStyle = designFactory.newStyle( DefaultDetailStyle );
			 dataStyle.setProperty( StyleHandle.FONT_SIZE_PROP, DesignChoiceConstants.FONT_SIZE_X_SMALL);
			 dataStyle.setProperty( StyleHandle.FONT_FAMILY_PROP, "Arial"
			 );
			 dataStyle.setProperty( StyleHandle.COLOR_PROP, "#000000" );
			 dataStyle.setProperty( StyleHandle.PADDING_LEFT_PROP, "2" );
			 dataStyle.setProperty( StyleHandle.PADDING_RIGHT_PROP, "2" );
			 dataStyle.setProperty( StyleHandle.TEXT_ALIGN_PROP, "Left" );
			 
			 designHandle.getStyles( ).add( dataStyle );
			 
			 //Cria o Style da TableHeader Row
			 StyleHandle headerStyle = designFactory.newStyle( DefaultHeaderStyle );
			 //headerStyle.setProperty( StyleHandle.BORDER_TOP_STYLE_PROP, DesignChoiceConstants.LINE_STYLE_SOLID  );
			 //headerStyle.setProperty( StyleHandle.BORDER_TOP_COLOR_PROP, "#2275FF" );
			 //headerStyle.setProperty( StyleHandle.BORDER_TOP_WIDTH_PROP, "2px" );
			 headerStyle.setProperty( StyleHandle.BORDER_BOTTOM_STYLE_PROP, DesignChoiceConstants.LINE_STYLE_SOLID  );
			 headerStyle.setProperty( StyleHandle.BORDER_BOTTOM_WIDTH_PROP, "2px" );
			 headerStyle.setProperty( StyleHandle.BORDER_BOTTOM_COLOR_PROP, "#2275FF" );
			 
			 designHandle.getStyles( ).add( headerStyle );
			 
			 //Cria o Style do report item
			 StyleHandle itemStyle = designFactory.newStyle( DefaultReportItemStyle );
			 itemStyle.setProperty( StyleHandle.FONT_SIZE_PROP, DesignChoiceConstants.FONT_SIZE_X_SMALL);
			 itemStyle.setProperty( StyleHandle.FONT_FAMILY_PROP, "Arial" );
			 itemStyle.setProperty( StyleHandle.COLOR_PROP, "#000000" );
			 
			 designHandle.getStyles( ).add( itemStyle );
		 }catch(Exception e){
			 throw new Exception(e.getMessage());
		 }
	 }
	
 }


so from php i call each element i wanna build according to my request, after my builder returns the build up java class to my php i add it using the "addToDesign" method, to the design body . It can be a text item and after it 2 tables each one with different data and different report itens and after more 2 text itens elements (my testing example).
Re: Problem when generating dynamic tables [message #929902 is a reply to message #929740] Mon, 01 October 2012 21:47 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Are you only calling this:
Platform.startup( designConfig );
once?

Jason
Re: Problem when generating dynamic tables [message #930485 is a reply to message #929902] Tue, 02 October 2012 11:13 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Yes im calling it just once by the initReport method
Re: Problem when generating dynamic tables [message #930490 is a reply to message #930485] Tue, 02 October 2012 11:19 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
I have my initReport called in my php class construct method and the same class has a singleton() method to prevent more instances of it.
after i build my report i call the closeReport method wich contains the Platform.shutdown()

[Updated on: Tue, 02 October 2012 11:24]

Report message to a moderator

Re: Problem when generating dynamic tables [message #930716 is a reply to message #929664] Tue, 02 October 2012 15:12 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Jason i run up some tests here and i found that when i have more then 1 element bound to the same dataset the outOfMemory error occurs, but if i have each element bound to distinct datasets it renders without any errors.
Re: Problem when generating dynamic tables [message #930865 is a reply to message #930716] Tue, 02 October 2012 18:12 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you do a reportDesign.saveAs and post the report when you more than one element bound to a dataset?

Jason
Re: Problem when generating dynamic tables [message #931630 is a reply to message #930865] Wed, 03 October 2012 11:22 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Sure, here it is.
Re: Problem when generating dynamic tables [message #931847 is a reply to message #931630] Wed, 03 October 2012 15:25 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

So in the report you posted, the first and last text item are bound to the same dataset. If you remove one of these the issue goes away?
I no data set caching was improved in 3.7, but these should be caching. One thing to try is to add a grid that contains the first text item, the table and then the last text item. Remove the binding setting for the text items and set it once on the grid. One another note, why in the following code are you setting the dataset on data items instead of setting on the container element?

public DataItemHandle createDataItem(String name, String expression, DataSetHandle dataSet, String resultSetCol,
ArrayList<String>columnBindings, HashMap<String, String> properties) {
System.out.print(".....Creating data item: \""+name+"\"");

DataItemHandle data = designFactory.newDataItem( "data_"+name );
try {
data.setStyleName( DefaultDetailStyle );
if(dataSet != null) {
data.setDataSet( dataSet );
data.setResultSetColumn( resultSetCol );
}

Jason
Re: Problem when generating dynamic tables [message #931963 is a reply to message #931847] Wed, 03 October 2012 17:40 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Because i can have a data item with different dataset binding, i already changed these lines to
if(dataSet != null) {
data.setDataSet( dataSet );
if(resultSetCol != null) {
data.setResultSetColumn( resultSetCol );


so when i create a table i dont inform dataItem's data set, just the resultsetcol and bind the dataset to the table. Only if the dataset parameter is set that it will bind it to the data item instead of the container.

Anyway, just tested creating textItens inside a grid with just 1 cell and bound the datasets to the grids instead of the text items. The outOfMemory error still occurs.
Re: Problem when generating dynamic tables [message #931964 is a reply to message #931847] Wed, 03 October 2012 17:42 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Because i can have a data item with different dataset binding, i already changed these lines to
if(dataSet != null) {
data.setDataSet( dataSet );
if(resultSetCol != null) {
data.setResultSetColumn( resultSetCol );


so when i create a table i dont inform dataItem's data set, just the resultsetcol and bind the dataset to the table. Only if the dataset parameter is set then it will be bound to the data item instead of the container.
I cant do the grid thing because as this is a dynamic proccess there are cases in what ill have n elements bound to n datasets, i mean in this example i had 2 text item to same dataset and 1 table to another, but what if i had 2 text in dataset 1, 2 table in dataset 2, more 2 texts in dataset 3 and 3 tables in dataset 4, if i follow ur container idea i will have to create a grid for almost each design element.

[Updated on: Wed, 03 October 2012 20:10]

Report message to a moderator

Re: Problem when generating dynamic tables [message #931988 is a reply to message #931964] Wed, 03 October 2012 18:16 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
I just created another environment to test this with birt 3.7.2.
In tomcat cleared my javabridge platform folder, copied the lib from 3.7.2 runtime to javabridge lib and also updated the viewer.
First time i run the report is built fine but the outOfMemory error still happens, but second time it start giving me this error
org.eclipse.birt.core.exception.BirtException: error.CannotStartupOSGIPlatform
        at org.eclipse.birt.core.framework.Platform.startup(Platform.java:81)
        at builder.ReportBuilder.initReport(ReportBuilder.java:112)
        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 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1044)
        at php.java.bridge.Request.handleRequest(Request.java:417) 


i checked migration changes and all i did was add runtime lib to my project buildpath and removed the following line from source
designConfig.setBIRTHome(birtHome);
Re: Problem when generating dynamic tables [message #932085 is a reply to message #931988] Wed, 03 October 2012 20:28 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

That error looks like you are starting and stopping the platform many times. Are you sure that you are not?
Take a look at this bugzilla entry for restarting the platform:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351052

Jason
Re: Problem when generating dynamic tables [message #932792 is a reply to message #932085] Thu, 04 October 2012 12:35 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Strange...i debugged my php code and it pass over the initReport method (wich calls the platform.startup) just once

[Updated on: Thu, 04 October 2012 12:45]

Report message to a moderator

Re: Problem when generating dynamic tables [message #932839 is a reply to message #932792] Thu, 04 October 2012 13:35 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Jason i tested again adding the RegistryProviderFactory.releaseDefault(); after Platform.shutdown(). This managed the osgi startup error, but the outOfMemory error still persists.
Re: Problem when generating dynamic tables [message #932840 is a reply to message #932839] Thu, 04 October 2012 13:39 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
If you want to see the .rtpdesign in the 3.7.2 birt get the attached



Re: Problem when generating dynamic tables [message #932990 is a reply to message #932840] Thu, 04 October 2012 16:29 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Did you figure out if the platform is constantly re-started. If you fix this it may fix your out of memory error.

Jason
Re: Problem when generating dynamic tables [message #933850 is a reply to message #932990] Fri, 05 October 2012 11:59 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Jason, i limited the platform lifecycle to user's session in php, before was limited per build request. Now the platform is started during user session, the build became faster but unfortunatelly it still giving me the error
The test was made with platform started, i build up the report and test it without shutting down the platform(because if i do it ill need to restart it again in the next request so i would be back to the same place i was) and when the user ends his session the platform is then shutted down.

[Updated on: Fri, 05 October 2012 12:38]

Report message to a moderator

Re: Problem when generating dynamic tables [message #933887 is a reply to message #933850] Fri, 05 October 2012 12:34 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
There is another weird stuff in birt 3.7.2 generated report... when i render it in preview its ok but if i see it in any webviewer (from Eclipse birt 3.7.2 RCP viewer and tomcat viewer) the last text item is duplicated several times.
Re: Problem when generating dynamic tables [message #934176 is a reply to message #933887] Fri, 05 October 2012 18:27 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Have you logged a bugzilla entry for this? If you want I can do a skype session to have a look at it.

Jason
Re: Problem when generating dynamic tables [message #934194 is a reply to message #934176] Fri, 05 October 2012 18:48 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Do you want to log both problems or just the dataset cache ?
Can you send me the link to birt bugzilla entries ?
Thanks.
Re: Problem when generating dynamic tables [message #934199 is a reply to message #934194] Fri, 05 October 2012 18:53 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Ill try to reproduce this at my home (since im at work and here we have some policies that blocks me from using skype) and if i can do it, ill manage that skype session so you can look at it.
Re: Problem when generating dynamic tables [message #934208 is a reply to message #934199] Fri, 05 October 2012 18:59 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Sounds good. My email address is jasonweathersby at windstream dot net. Send me an email and we can setup a time.

Jason
Re: Problem when generating dynamic tables [message #934245 is a reply to message #934208] Fri, 05 October 2012 19:44 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Alright, this weekend im out of my home town but next week ill e-mail you so we can setup this.

Thank you very much for your atention once more Jason.

Gustavo.
Re: Problem when generating dynamic tables [message #934249 is a reply to message #934245] Fri, 05 October 2012 19:44 Go to previous messageGo to next message
Gustavo Missing name is currently offline Gustavo Missing nameFriend
Messages: 20
Registered: March 2011
Junior Member
Oh, forgot...the bugzilla (birt session) link, do you ahve it ?
Re: Problem when generating dynamic tables [message #937306 is a reply to message #934249] Mon, 08 October 2012 21:57 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Look at the bugzilla category here:
http://www.eclipse.org/birt/phoenix/community.php

Thanks

Jason
Previous Topic:Report Design Option Missing From Eclipse 3.7.1 Preferences
Next Topic:How to change Master Page size onFetch of data set.
Goto Forum:
  


Current Time: Fri Mar 29 04:39:38 GMT 2024

Powered by FUDForum. Page generated in 0.04507 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top