Can not load "stimulsoft.properties" from web application

Stimulsoft Reports.JAVA discussion
Post Reply
User avatar
Chipo
Posts: 44
Joined: Thu Sep 13, 2012 4:09 am
Location: Sydney, Australia

Can not load "stimulsoft.properties" from web application

Post by Chipo »

Hi,

current version of the library: 2012.2.1332-trial (uploaded today 18/09/2012)

I am using java application as a data provider. Currently I met problem while loading the "stimulsoft.properties" from web resources.

"stimulsoft.properties" is available for application via the class loader as a resource. I decompiled class files and found the following:

class com.stimulsoft.library.ConfigureProperties

Code: Select all

private static File getConfigFile(String stimulsoftDir) throws IOException  {
  File confFile = new File(stimulsoftDir, StiConstants.FILE_NAME_CONFIGURE_PROPERTIES.value);
  if (!(confFile.exists())) {
      printWarnNoConfProperty();
      FileUtil.copyInputStreamToFile(new ResourceApp().getDefaultConfigure(), confFile);
  }
  return confFile;
}
Actually this does not work for web application. This method tries to find properties file on the default file folder of the server and does not try to load it from web application itself.

At the first run it recognizes file as missing and write with default one ("defconfigure.properties") from the stimulsoft library to the server public directory. My configuration stayed ignored.

How I can fix the situation?

Best regards
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: Can not load "stimulsoft.properties" from web applicatio

Post by Vladimir »

Hello,

Please specify where you have located the stimulsoft.properties file?
If your file is available from the application, to specify a configuration file, you can use the ApplicationInitializer class, which specifies:
StiConfig stiConfig = new StiConfig(<your file>);

Thank you.
User avatar
Chipo
Posts: 44
Joined: Thu Sep 13, 2012 4:09 am
Location: Sydney, Australia

Re: Can not load "stimulsoft.properties" from web applicatio

Post by Chipo »

Hi,

I keep "stimlsoft.properties" file in the "sti-reporting" directory inside war archive. It is accessible as a resource for application. Originally I do not have it on the file system of the server.

If I call StiConfig(File stiDir) it will do the following:

Code: Select all

public StiConfig(File stiDir) throws StiException {
  try {
    ConfigureProperties.init(stiDir.getAbsolutePath());
  } catch (Exception e) {
    throw new StiException(e);
  }
this stiDir.getAbsolutePath() will not work. Property file (even if I can calculate physical path) is not accessible as a file for java.io. This could work if my war file deployed as dearchived directory to the app server deployment area.

After that ConfigureProperties goes down to:

Code: Select all

private static File getConfigFile(String stimulsoftDir) throws IOException {
  File confFile = new File(stimulsoftDir, StiConstants.FILE_NAME_CONFIGURE_PROPERTIES.value);
  if (!(confFile.exists())) {
    printWarnNoConfProperty();
    FileUtil.copyInputStreamToFile(new ResourceApp().getDefaultConfigure(), confFile);
  }
  return confFile;
}
In there application finds out that cnfFile does not exist and write default content in there. Yesterday our deployed application stack because some read/write restrictions for newly created files (or something) on Unix.

Vot takie vot pirogi. Best regards.
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: Can not load "stimulsoft.properties" from web applicatio

Post by Vladimir »

Hello,

We added this feature, please download the attached file:
stimulsoft.reports.fx-core-2012.2.1400-trial.zip
(1.5 MiB) Downloaded 355 times
Here is a sample code:

Code: Select all

        Properties properties = new Properties();
        InputStream inStream = getClass().getResourceAsStream("RESOURCE_PATH");
        properties.load(inStream);
        StiConfig stiConfig = StiConfig(properties);
Thank you.
User avatar
Chipo
Posts: 44
Joined: Thu Sep 13, 2012 4:09 am
Location: Sydney, Australia

Re: Can not load "stimulsoft.properties" from web applicatio

Post by Chipo »

Hi,

thank you. This definitely works.

But there is one hiccup. I caught NullPointerException at
com.stimulsoft.actions.ReturnXmlOrSqlData line 107

Code: Select all

default:
    Object object = rs.getObject(i);
    rowData.add(columnLabel, object.toString());  // line 107
}
I overrode your class with line 107 overridden like

Code: Select all

rowData.add(columnLabel, (object == null) ? "" : object.toString()); 
Problem disappeared.

Best regards.
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: Can not load "stimulsoft.properties" from web applicatio

Post by Vladimir »

Hello,

In the attached archive is an updated version:
stimulsoft.reports.fx-core-2012.2.1400-trial.zip
(1.5 MiB) Downloaded 354 times
Thank you.
Post Reply