Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Connect
Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Connect [message #558879] Tue, 14 September 2010 17:29 Go to next message
Lionel is currently offline LionelFriend
Messages: 31
Registered: July 2009
Member
Hi,

I have an issue when using a jndi datasource.

I start the Platform and report engine when the application starts (using a
ContextListener)
I destroy the engine and the Platform when the application stopts (using the
same ContextListener)

When I start tomcat, everything works fine, the jndi datasource is used and
my report is well displayed.
If I stop/start the application (either using tomcat manager or by saving a
java file), the jndi datasource is not used anymore and BIRT tries to open a
connection, which crashes:
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Missing properties in
Connection.open(Properties)

Stopping and restarting tomcat solves the problem. But I can't restart the
server for each deployment, this consumes too much time.

What did I do wrong ?

Hiere is my listener:
public void contextDestroyed(ServletContextEvent event) {

BirtEngine.destroyBirtEngine();

}



public void contextInitialized(ServletContextEvent event) {

BirtEngine.getBirtEngine();

}





BirtEngine.java:





public static synchronized IReportEngine getBirtEngine() {

if (birtEngine == null) {

EngineConfig config = new EngineConfig();

config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSL OADER_KEY,
BirtEngine.class.getClassLoader());







try{Platform.startup( config );}

catch ( BirtException e ){e.printStackTrace( );}


IReportEngineFactory factory = (IReportEngineFactory)

Platform.createFactoryObject(
IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );

birtEngine = factory.createReportEngine( config );


}

return birtEngine;

}



public static synchronized void destroyBirtEngine() {

if (birtEngine == null) {return; }

birtEngine.destroy();

Platform.shutdown();

birtEngine = null;

}





Thanks for your help.
Re: Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Con [message #558915 is a reply to message #558879] Tue, 14 September 2010 20:18 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Are you doing a task.close after running the report?

Jason

On 9/14/2010 1:29 PM, Lionel wrote:
> Hi,
>
> I have an issue when using a jndi datasource.
>
> I start the Platform and report engine when the application starts (using a
> ContextListener)
> I destroy the engine and the Platform when the application stopts (using the
> same ContextListener)
>
> When I start tomcat, everything works fine, the jndi datasource is used and
> my report is well displayed.
> If I stop/start the application (either using tomcat manager or by saving a
> java file), the jndi datasource is not used anymore and BIRT tries to open a
> connection, which crashes:
> org.eclipse.birt.report.data.oda.jdbc.JDBCException: Missing properties in
> Connection.open(Properties)
>
> Stopping and restarting tomcat solves the problem. But I can't restart the
> server for each deployment, this consumes too much time.
>
> What did I do wrong ?
>
> Hiere is my listener:
> public void contextDestroyed(ServletContextEvent event) {
>
> BirtEngine.destroyBirtEngine();
>
> }
>
>
>
> public void contextInitialized(ServletContextEvent event) {
>
> BirtEngine.getBirtEngine();
>
> }
>
>
>
>
>
> BirtEngine.java:
>
>
>
>
>
> public static synchronized IReportEngine getBirtEngine() {
>
> if (birtEngine == null) {
>
> EngineConfig config = new EngineConfig();
>
> config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSL OADER_KEY,
> BirtEngine.class.getClassLoader());
>
>
>
>
>
>
>
> try{Platform.startup( config );}
>
> catch ( BirtException e ){e.printStackTrace( );}
>
>
> IReportEngineFactory factory = (IReportEngineFactory)
>
> Platform.createFactoryObject(
> IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
>
> birtEngine = factory.createReportEngine( config );
>
>
> }
>
> return birtEngine;
>
> }
>
>
>
> public static synchronized void destroyBirtEngine() {
>
> if (birtEngine == null) {return; }
>
> birtEngine.destroy();
>
> Platform.shutdown();
>
> birtEngine = null;
>
> }
>
>
>
>
>
> Thanks for your help.
>
>
Re: Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Con [message #558974 is a reply to message #558915] Wed, 15 September 2010 08:11 Go to previous messageGo to next message
Lionel is currently offline LionelFriend
Messages: 31
Registered: July 2009
Member
Jason Weathersby wrote:
> Are you doing a task.close after running the report?
>
> Jason

Yes.
task.run(); is immediatly followed by

task.close();
Re: Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Con [message #558986 is a reply to message #558974] Wed, 15 September 2010 08:45 Go to previous messageGo to next message
Lionel is currently offline LionelFriend
Messages: 31
Registered: July 2009
Member
Lionel wrote:
> Jason Weathersby wrote:
>> Are you doing a task.close after running the report?
>>
>> Jason
>
> Yes.
> task.run(); is immediatly followed by
>
> task.close();

The following scenario works:
- Start tomcat
- use application
- reload application
- launch report --> ok


The following scenario doesn't work:
- Start tomcat
- use application
- launch report --> ok
- reload application
- launch report --> crash


Here is how I create and run the task:
ServletContext sc = getContext().getServletContext();

IReportEngine birtReportEngine = BirtEngine.getBirtEngine();

IReportRunnable design = birtReportEngine.openReportDesign(getReportUrl());

birtReportEngine.getConfig().setResourcePath(sc.getRealPath( "/") +
"WEB-INF/classes/");

task = birtReportEngine.createRunAndRenderTask(design);

task.setParameterValue("param", "value");

task.validateParameters();

reportOutput = new ByteArrayOutputStream();

HTMLRenderOption options = new HTMLRenderOption();

options.setOutputFormat(IHTMLRenderOption.OUTPUT_FORMAT_HTML );

options.setOutputStream(reportOutput);

options.setEmbeddable(true);


task.setRenderOption(options);

task.run();

task.close();
Re: Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Con [message #559090 is a reply to message #558986] Wed, 15 September 2010 15:10 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Lionel,

Do you only get this error on JNDI datasources? Have you tried the
default viewer to see if you get the same issue?

Jason

On 9/15/2010 4:45 AM, Lionel wrote:
> Lionel wrote:
>> Jason Weathersby wrote:
>>> Are you doing a task.close after running the report?
>>>
>>> Jason
>>
>> Yes.
>> task.run(); is immediatly followed by
>>
>> task.close();
>
> The following scenario works:
> - Start tomcat
> - use application
> - reload application
> - launch report --> ok
>
>
> The following scenario doesn't work:
> - Start tomcat
> - use application
> - launch report --> ok
> - reload application
> - launch report --> crash
>
>
> Here is how I create and run the task:
> ServletContext sc = getContext().getServletContext();
>
> IReportEngine birtReportEngine = BirtEngine.getBirtEngine();
>
> IReportRunnable design = birtReportEngine.openReportDesign(getReportUrl());
>
> birtReportEngine.getConfig().setResourcePath(sc.getRealPath( "/") +
> "WEB-INF/classes/");
>
> task = birtReportEngine.createRunAndRenderTask(design);
>
> task.setParameterValue("param", "value");
>
> task.validateParameters();
>
> reportOutput = new ByteArrayOutputStream();
>
> HTMLRenderOption options = new HTMLRenderOption();
>
> options.setOutputFormat(IHTMLRenderOption.OUTPUT_FORMAT_HTML );
>
> options.setOutputStream(reportOutput);
>
> options.setEmbeddable(true);
>
>
> task.setRenderOption(options);
>
> task.run();
>
> task.close();
>
>
Re: Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Con [message #559126 is a reply to message #559090] Wed, 15 September 2010 16:51 Go to previous messageGo to next message
Lionel is currently offline LionelFriend
Messages: 31
Registered: July 2009
Member
Jason Weathersby wrote:
> Lionel,
>
> Do you only get this error on JNDI datasources? Have you tried the
> default viewer to see if you get the same issue?
>
> Jason

Scripted datasource work fine even after application reload.
I don't use any other datasource.
I configure both JDBC properties (used to preview the report within eclipse,
this has always worked fine) and JNDI url (used when report engine is
embedded in my application and deployed on tomcat6).

I tried to remove the JNDI url from my datasource, the same thing happens:
at first application load, everything works fine, when application reloads,
it crashes (same error).


FIN: Finished preparing query.
15 sept. 2010 18:46:26
org.eclipse.birt.data.engine.odaconsumer.ConnectionManager
addProfileProviderService( Map )
FIN: Added default property service:
org.eclipse.datatools.connectivity.oda.profile.connectionPro pertyService
15 sept. 2010 18:46:26 org.eclipse.birt.report.data.oda.jdbc.OdaJdbcDriver
getConnection
FIN: JDBCConnectionFactory.getConnection( )
connectionClassName=org.eclipse.birt.report.data.oda.jdbc
15 sept. 2010 18:46:26 org.eclipse.birt.report.data.oda.jdbc.Connection open
FIN: Connection.open(Properties). connProperties =
OdaPropertyConfigId=org.eclipse.birt.report.data.oda.jdbc_My Application;contentBidiFormatStr=ILYNN;metadataBidiFormatStr =ILYNN;
15 sept. 2010 18:46:26 org.eclipse.birt.report.data.oda.jdbc.Connection
close
FIN: Connection closed.
15 sept. 2010 18:46:26 org.eclipse.birt.report.data.oda.jdbc.JDBCException
JDBCException
FIN: odajdbc.driver.DriverMissingProperties
15 sept. 2010 18:46:26
org.eclipse.birt.data.engine.odaconsumer.ConnectionManager openConnection
GRAVE: Unable to open connection.
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Missing properties in
Connection.open(Properties).
at
org.eclipse.birt.report.data.oda.jdbc.Connection.open(Connec tion.java:157)
at
org.eclipse.datatools.connectivity.oda.consumer.helper.OdaCo nnection.open(OdaConnection.java:239)
at
org.eclipse.birt.data.engine.odaconsumer.ConnectionManager.o penConnection(ConnectionManager.java:165)
Re: Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Con [message #559129 is a reply to message #559126] Wed, 15 September 2010 16:56 Go to previous messageGo to next message
Lionel is currently offline LionelFriend
Messages: 31
Registered: July 2009
Member
BIRRT Logs, without JNDI URL, at first start when everything works fine (no
change compared to previous log, only an application reload):

FIN: Finished preparing query.
15 sept. 2010 18:52:53
org.eclipse.birt.data.engine.odaconsumer.ConnectionManager
addProfileProviderService( Map )
FIN: Added default property service:
org.eclipse.datatools.connectivity.oda.profile.connectionPro pertyService
15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.OdaJdbcDriver
getConnection
FIN: JDBCConnectionFactory.getConnection( )
connectionClassName=org.eclipse.birt.report.data.oda.jdbc
15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.Connection open
FIN: Connection.open(Properties). connProperties =
OdaPropertyConfigId=org.eclipse.birt.report.data.oda.jdbc_My Application;odaURL=jdbc:postgresql://serveur2003:5432/MyApplication ;odaDriverClass=org.postgresql.Driver;odaPassword=***;odaUse r=MyApplication;contentBidiFormatStr=ILYNN;metadataBidiForma tStr=ILYNN;
15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.Connection
close
FIN: Connection closed.
15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.OdaJdbcDriver
JDBCDriverManager
FIN: JDBCDriverManager starts up
15 sept. 2010 18:52:53
org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager getConnection
FIN: Request JDBC Connection: driverClass=org.postgresql.Driver;
url=jdbc:postgresql://serveur2003:5432/MyApplication; jndi name url=null
15 sept. 2010 18:52:53
org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadDriverExtensions
INFO: Found JDBC driverinfo extension:
driverClass=org.apache.derby.jdbc.EmbeddedDriver, connectionFactory=null
15 sept. 2010 18:52:53
org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadDriverExtensions
INFO: Found JDBC driverinfo extension:
driverClass=org.eclipse.birt.report.data.oda.sampledb.Driver ,
connectionFactory=org.eclipse.birt.report.data.oda.sampledb. SampleDBJDBCConnectionFactory
15 sept. 2010 18:52:53
org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager
loadAndRegisterDriver
INFO: Loading JDBC driver class: org.postgresql.Driver
15 sept. 2010 18:52:53
org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager findDriver
INFO: Driver class not in class path: org.postgresql.Driver. Trying to
locate driver in drivers directory
15 sept. 2010 18:52:53
org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager$Driv erClassLoader
addNewURL
INFO: JDBCDriverManager: found JAR file
drivers/postgresql-8.2-507.jdbc4.jar.
URL= bundleentry://40.fwk13586438/drivers/postgresql-8.2-507.jdbc 4.jar
15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.Connection
createStatement
FIN:
Connection.createStatement(org.eclipse.birt.report.data.oda. jdbc.JdbcSelectDataSet)
Re: Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Con [message #559167 is a reply to message #559129] Wed, 15 September 2010 19:48 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Were you able to try the viewer in the runtime download?

On 9/15/2010 12:56 PM, Lionel wrote:
> BIRRT Logs, without JNDI URL, at first start when everything works fine (no
> change compared to previous log, only an application reload):
>
> FIN: Finished preparing query.
> 15 sept. 2010 18:52:53
> org.eclipse.birt.data.engine.odaconsumer.ConnectionManager
> addProfileProviderService( Map )
> FIN: Added default property service:
> org.eclipse.datatools.connectivity.oda.profile.connectionPro pertyService
> 15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.OdaJdbcDriver
> getConnection
> FIN: JDBCConnectionFactory.getConnection( )
> connectionClassName=org.eclipse.birt.report.data.oda.jdbc
> 15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.Connection open
> FIN: Connection.open(Properties). connProperties =
> OdaPropertyConfigId=org.eclipse.birt.report.data.oda.jdbc_My Application;odaURL=jdbc:postgresql://serveur2003:5432/MyApplication ;odaDriverClass=org.postgresql.Driver;odaPassword=***;odaUse r=MyApplication;contentBidiFormatStr=ILYNN;metadataBidiForma tStr=ILYNN;
> 15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.Connection
> close
> FIN: Connection closed.
> 15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.OdaJdbcDriver
> JDBCDriverManager
> FIN: JDBCDriverManager starts up
> 15 sept. 2010 18:52:53
> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager getConnection
> FIN: Request JDBC Connection: driverClass=org.postgresql.Driver;
> url=jdbc:postgresql://serveur2003:5432/MyApplication; jndi name url=null
> 15 sept. 2010 18:52:53
> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadDriverExtensions
> INFO: Found JDBC driverinfo extension:
> driverClass=org.apache.derby.jdbc.EmbeddedDriver, connectionFactory=null
> 15 sept. 2010 18:52:53
> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadDriverExtensions
> INFO: Found JDBC driverinfo extension:
> driverClass=org.eclipse.birt.report.data.oda.sampledb.Driver ,
> connectionFactory=org.eclipse.birt.report.data.oda.sampledb. SampleDBJDBCConnectionFactory
> 15 sept. 2010 18:52:53
> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager
> loadAndRegisterDriver
> INFO: Loading JDBC driver class: org.postgresql.Driver
> 15 sept. 2010 18:52:53
> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager findDriver
> INFO: Driver class not in class path: org.postgresql.Driver. Trying to
> locate driver in drivers directory
> 15 sept. 2010 18:52:53
> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager$Driv erClassLoader
> addNewURL
> INFO: JDBCDriverManager: found JAR file
> drivers/postgresql-8.2-507.jdbc4.jar.
> URL= bundleentry://40.fwk13586438/drivers/postgresql-8.2-507.jdbc 4.jar
> 15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.Connection
> createStatement
> FIN:
> Connection.createStatement(org.eclipse.birt.report.data.oda. jdbc.JdbcSelectDataSet)
>
>
Re: Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Con [message #559189 is a reply to message #559167] Wed, 15 September 2010 21:32 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I tried this with the viewer and tomcat/mysql connection pooling and did
a reload and did not see the issue. I assume you setup connection
pooling like:

http://wiki.eclipse.org/BIRT/FAQ/Deployment#Q:_How_do_I_setu p_BIRT_to_use_Tomcat_Connection_Pooling

Jason

On 9/15/2010 3:48 PM, Jason Weathersby wrote:
> Were you able to try the viewer in the runtime download?
>
> On 9/15/2010 12:56 PM, Lionel wrote:
>> BIRRT Logs, without JNDI URL, at first start when everything works
>> fine (no
>> change compared to previous log, only an application reload):
>>
>> FIN: Finished preparing query.
>> 15 sept. 2010 18:52:53
>> org.eclipse.birt.data.engine.odaconsumer.ConnectionManager
>> addProfileProviderService( Map )
>> FIN: Added default property service:
>> org.eclipse.datatools.connectivity.oda.profile.connectionPro pertyService
>> 15 sept. 2010 18:52:53
>> org.eclipse.birt.report.data.oda.jdbc.OdaJdbcDriver
>> getConnection
>> FIN: JDBCConnectionFactory.getConnection( )
>> connectionClassName=org.eclipse.birt.report.data.oda.jdbc
>> 15 sept. 2010 18:52:53
>> org.eclipse.birt.report.data.oda.jdbc.Connection open
>> FIN: Connection.open(Properties). connProperties =
>> OdaPropertyConfigId=org.eclipse.birt.report.data.oda.jdbc_My Application;odaURL=jdbc:postgresql://serveur2003:5432/MyApplication ;odaDriverClass=org.postgresql.Driver;odaPassword=***;odaUse r=MyApplication;contentBidiFormatStr=ILYNN;metadataBidiForma tStr=ILYNN;
>>
>> 15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.Connection
>> close
>> FIN: Connection closed.
>> 15 sept. 2010 18:52:53
>> org.eclipse.birt.report.data.oda.jdbc.OdaJdbcDriver
>> JDBCDriverManager
>> FIN: JDBCDriverManager starts up
>> 15 sept. 2010 18:52:53
>> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager getConnection
>> FIN: Request JDBC Connection: driverClass=org.postgresql.Driver;
>> url=jdbc:postgresql://serveur2003:5432/MyApplication; jndi name url=null
>> 15 sept. 2010 18:52:53
>> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager
>> loadDriverExtensions
>> INFO: Found JDBC driverinfo extension:
>> driverClass=org.apache.derby.jdbc.EmbeddedDriver, connectionFactory=null
>> 15 sept. 2010 18:52:53
>> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager
>> loadDriverExtensions
>> INFO: Found JDBC driverinfo extension:
>> driverClass=org.eclipse.birt.report.data.oda.sampledb.Driver ,
>> connectionFactory=org.eclipse.birt.report.data.oda.sampledb. SampleDBJDBCConnectionFactory
>>
>> 15 sept. 2010 18:52:53
>> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager
>> loadAndRegisterDriver
>> INFO: Loading JDBC driver class: org.postgresql.Driver
>> 15 sept. 2010 18:52:53
>> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager findDriver
>> INFO: Driver class not in class path: org.postgresql.Driver. Trying to
>> locate driver in drivers directory
>> 15 sept. 2010 18:52:53
>> org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager$Driv erClassLoader
>> addNewURL
>> INFO: JDBCDriverManager: found JAR file
>> drivers/postgresql-8.2-507.jdbc4.jar.
>> URL= bundleentry://40.fwk13586438/drivers/postgresql-8.2-507.jdbc 4.jar
>> 15 sept. 2010 18:52:53 org.eclipse.birt.report.data.oda.jdbc.Connection
>> createStatement
>> FIN:
>> Connection.createStatement(org.eclipse.birt.report.data.oda. jdbc.JdbcSelectDataSet)
>>
>>
>>
>
Re: Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Con [message #559474 is a reply to message #559189] Thu, 16 September 2010 17:53 Go to previous messageGo to next message
Lionel is currently offline LionelFriend
Messages: 31
Registered: July 2009
Member
Jason Weathersby wrote:
> I tried this with the viewer and tomcat/mysql connection pooling and
> did a reload and did not see the issue. I assume you setup connection
> pooling like:
>
> http://wiki.eclipse.org/BIRT/FAQ/Deployment#Q:_How_do_I_setu p_BIRT_to_use_Tomcat_Connection_Pooling

Yes.
My JNDI datasource has been configured long time before including BIRT in my
JPA project
I've never had any issue. Even when BIRT crashes, my application can still
access my datasource without any trouble.
It really looks like I did something wrong when I open/run/close my report
that make BIRT "think" that there is no JNDI datasource.

The logs clearly show that after a reload the connections properties are
lost:

-- Start tomcat:

16 sept. 2010 19:40:48 org.eclipse.birt.report.data.oda.jdbc.Connection open
FIN: Connection.open(Properties). connProperties =
odaJndiName=java:comp/env/jdbc/MyApplication;OdaPropertyConf igId=org.eclipse.birt.report.data.oda.jdbc_MyApplication;oda URL=jdbc:postgresql://serveur2003:5432/MyApplication ;odaDriverClass=org.postgresql.Driver;odaPassword=***;odaUse r=MyApplication;contentBidiFormatStr=ILYNN;metadataBidiForma tStr=ILYNN;

--reload application and refresh page:

16 sept. 2010 19:44:02 org.eclipse.birt.report.data.oda.jdbc.Connection open
FIN: Connection.open(Properties). connProperties =
OdaPropertyConfigId=org.eclipse.birt.report.data.oda.jdbc_My Application;contentBidiFormatStr=ILYNN;metadataBidiFormatStr =ILYNN;

What could I have done that would have done that ?
Re: Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Con [message #559486 is a reply to message #559474] Thu, 16 September 2010 18:38 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you open a bug for this? I can not reproduce the issue. I have
tried with both the viewer and my own servlet. I am posting my code in
this thread. I shutdown the engine on destruction of the servlet.

2 Classes BirtEngine and WebReport

//BirtEngine



import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;

import javax.servlet.ServletContext;

import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.framework.IPlatformContext;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.core.framework.PlatformServletContext;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;

public class BirtEngine {

private static IReportEngine birtEngine = null;

private static Properties configProps = new Properties();

private final static String configFile = "BirtConfig.properties";

public static synchronized void initBirtConfig() {
loadEngineProps();
}

public static synchronized IReportEngine getBirtEngine(ServletContext sc) {
if (birtEngine == null)
{
EngineConfig config = new EngineConfig();
if( configProps != null){
String logLevel = configProps.getProperty("logLevel");
Level level = Level.OFF;
if ("SEVERE".equalsIgnoreCase(logLevel))
{
level = Level.SEVERE;
} else if ("WARNING".equalsIgnoreCase(logLevel))
{
level = Level.WARNING;
} else if ("INFO".equalsIgnoreCase(logLevel))
{
level = Level.INFO;
} else if ("CONFIG".equalsIgnoreCase(logLevel))
{
level = Level.CONFIG;
} else if ("FINE".equalsIgnoreCase(logLevel))
{
level = Level.FINE;
} else if ("FINER".equalsIgnoreCase(logLevel))
{
level = Level.FINER;
} else if ("FINEST".equalsIgnoreCase(logLevel))
{
level = Level.FINEST;
} else if ("OFF".equalsIgnoreCase(logLevel))
{
level = Level.OFF;
}

config.setLogConfig(configProps.getProperty("logDirectory"), level);
}

config.setEngineHome("");

IPlatformContext context = new PlatformServletContext( sc );
config.setPlatformContext( context );


//Create the report engine
//birtEngine = new ReportEngine( config );
//ReportEngine engine = new ReportEngine( null );


try
{
Platform.startup( config );
}
catch ( BirtException e )
{
e.printStackTrace( );
}

IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(
IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
birtEngine = factory.createReportEngine( config );


}
return birtEngine;
}

public static synchronized void destroyBirtEngine() {
if (birtEngine == null) {
return;
}
birtEngine.destroy();
Platform.shutdown();
birtEngine = null;
}

public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}

private static void loadEngineProps() {
try {
//Config File must be in classpath
ClassLoader cl = Thread.currentThread ().getContextClassLoader();
InputStream in = null;
in = cl.getResourceAsStream (configFile);
configProps.load(in);
in.close();


} catch (IOException e) {
e.printStackTrace();
}

}

}

//WebReport

import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Logger;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;

public class WebReport extends HttpServlet {

/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Constructor of the object.
*/
private IReportEngine birtReportEngine = null;
protected static Logger logger = Logger.getLogger( "org.eclipse.birt" );

public WebReport() {
super();
}

/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy();
BirtEngine.destroyBirtEngine();
}


/**
* The doGet method of the servlet. <br>
*
*/
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

//get report name and launch the engine
resp.setContentType("text/html");
//resp.setContentType( "application/pdf" );
//resp.setHeader ("Content-Disposition","inline; filename=test.pdf");
String reportName = req.getParameter("ReportName");
ServletContext sc = req.getSession().getServletContext();
this.birtReportEngine = BirtEngine.getBirtEngine(sc);



IReportRunnable design;
try
{
//Open report design
design = birtReportEngine.openReportDesign(
sc.getRealPath("/Reports")+"/"+reportName );
//create task to run and render report
IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask(
design );
task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOA DER_KEY,
WebReport.class.getClassLoader());
task.getAppContext().put("BIRT_VIEWER_HTTPSERVLET_REQUEST", req );

//set output options
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML) ;
options.setOutputStream(resp.getOutputStream());
options.setImageHandler(new HTMLServerImageHandler());
options.setBaseImageURL(req.getContextPath()+"/images");
options.setImageDirectory(sc.getRealPath("/images"));

/*
PDFRenderOption options = new PDFRenderOption();
options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_PDF);
resp.setHeader( "Content-Disposition", "inline;
filename=\"test.pdf\"" );
options.setOutputStream(resp.getOutputStream());
*/
task.setRenderOption(options);


//run report
task.run();
task.close();
}catch (Exception e){

e.printStackTrace();
throw new ServletException( e );
}
}

/**
* The doPost method of the servlet. <br>
*
*/
public void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.println(" Post Not Supported");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}

/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init(ServletConfig sc) throws ServletException {
BirtEngine.initBirtConfig();
this.birtReportEngine = BirtEngine.getBirtEngine(sc.getServletContext());

}

}

BirtConfig.properties
logDirectory=c:/temp
logLevel=FINEST


Jason


On 9/16/2010 1:53 PM, Lionel wrote:
> Jason Weathersby wrote:
>> I tried this with the viewer and tomcat/mysql connection pooling and
>> did a reload and did not see the issue. I assume you setup connection
>> pooling like:
>>
>> http://wiki.eclipse.org/BIRT/FAQ/Deployment#Q:_How_do_I_setu p_BIRT_to_use_Tomcat_Connection_Pooling
>
> Yes.
> My JNDI datasource has been configured long time before including BIRT in my
> JPA project
> I've never had any issue. Even when BIRT crashes, my application can still
> access my datasource without any trouble.
> It really looks like I did something wrong when I open/run/close my report
> that make BIRT "think" that there is no JNDI datasource.
>
> The logs clearly show that after a reload the connections properties are
> lost:
>
> -- Start tomcat:
>
> 16 sept. 2010 19:40:48 org.eclipse.birt.report.data.oda.jdbc.Connection open
> FIN: Connection.open(Properties). connProperties =
> odaJndiName=java:comp/env/jdbc/MyApplication;OdaPropertyConf igId=org.eclipse.birt.report.data.oda.jdbc_MyApplication;oda URL=jdbc:postgresql://serveur2003:5432/MyApplication ;odaDriverClass=org.postgresql.Driver;odaPassword=***;odaUse r=MyApplication;contentBidiFormatStr=ILYNN;metadataBidiForma tStr=ILYNN;
>
> --reload application and refresh page:
>
> 16 sept. 2010 19:44:02 org.eclipse.birt.report.data.oda.jdbc.Connection open
> FIN: Connection.open(Properties). connProperties =
> OdaPropertyConfigId=org.eclipse.birt.report.data.oda.jdbc_My Application;contentBidiFormatStr=ILYNN;metadataBidiFormatStr =ILYNN;
>
> What could I have done that would have done that ?
>
>
>
Re: Birt 2.5.2 - JNDI not used after application reload under tomcat--> Missing properties in Con [message #640665 is a reply to message #559486] Mon, 22 November 2010 17:57 Go to previous message
Lionel is currently offline LionelFriend
Messages: 31
Registered: July 2009
Member
Jason Weathersby wrote :
> Can you open a bug for this? I can not reproduce the issue. I have tried
> with both the viewer and my own servlet. I am posting my code in this
> thread. I shutdown the engine on destruction of the servlet.

The issue seems to be solved by upgrading to BIRT 2.6.1.
Previous Topic:drill-through hyperlinks contain unwanted ../../..
Next Topic:How to Use report engine
Goto Forum:
  


Current Time: Thu Apr 18 04:26:43 GMT 2024

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

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

Back to the top