Page 1 of 1

Can not load "stimulsoft.properties" from web application

Posted: Tue Sep 18, 2012 1:55 am
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

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

Posted: Tue Sep 18, 2012 1:26 pm
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.

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

Posted: Wed Sep 19, 2012 2:47 am
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.

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

Posted: Thu Sep 20, 2012 8:56 am
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 502 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.

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

Posted: Thu Sep 20, 2012 10:29 pm
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.

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

Posted: Mon Sep 24, 2012 11:12 am
by Vladimir
Hello,

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