• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

java.io.FileInputStream init problem on Linux

New Here ,
Nov 28, 2009 Nov 28, 2009

Copy link to clipboard

Copied

Hi,

I'm using the code below since a while on a ColdFusion hosting on Windows platform. Now I try to install on a Linux server and I get this error (on working code):

Object Instantiation Exception.An exception occurred when instantiating a Java object. The class must not be an interface or an abstract class. Error: ''.

Here is the code extract. The error occurs on the marked line.

Anybody knows how to solve this?

  <cfscript>
   prefix = ucase(left(name,find(".properties",name)-1));
   languages = listAppend(languages,prefix);
  
   // these objects enable getResourceBundle method to load the properties files:
   rb  = createObject("java", "java.util.PropertyResourceBundle");
   fis = createObject("java", "java.io.FileInputStream");

   if( not isDefined("application.rb_#prefix#")) {
    fis.init(application.translationpath&prefix&'.properties');
    rb.init(variables.fis);
    "application.rb_#prefix#" = rb;
   }

   fis.close();
  </cfscript>

TOPICS
Advanced techniques

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 28, 2009 Nov 28, 2009

Copy link to clipboard

Copied

I think the problem isn't the line fis = createObject("java", "java.io.FileInputStream");, but the line after that. It should be an assignment of the form a=b. Something like this should work:

<cfscript>
   prefix = ucase(left(name,find(".properties",name)-1));
   languages = listAppend(languages,prefix);
 
   // fis and rb enable getResourceBundle method to load the properties files:
   if( not isDefined("application.rb_#prefix#")) {
    variables.fis = createObject("java", "java.io.FileInputStream").init(application.translationpath&prefix&'.properties');
    variables.rb = createObject("java", "java.util.PropertyResourceBundle").init(variables.fis);
    "application.rb_#prefix#" = variables.rb;

    variables.fis.close();
   }  
</cfscript>

In fact, this is even more efficient, as you will only need to create the objects when isDefined() returns true.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 28, 2009 Nov 28, 2009

Copy link to clipboard

Copied

I trief with your suggestion, but still the error.

Object Instantiation Exception.

An exception occurred when instantiating a Java object. The class must not be an interface or an abstract class. Error: ''.
The error occurred in /var/opt/coldfusion8/wwwroot/hosts/www.backup.habimat.be/Application.cfm: line 46
44 :      // fis and rb enable getResourceBundle method to load the properties files:
45 :      if (not isDefined("application.rb_#prefix#")) {
46 :         variables.fis = createObject("java", "java.io.FileInputStream").init(application.translationpath&prefix&'.properties ');
47 :         variables.rb = createObject("java", "java.util.PropertyResourceBundle").init(variables.fis);
48 :         "application.rb_#prefix#" = variables.rb;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 28, 2009 Nov 28, 2009

Copy link to clipboard

Copied

application.translationpath&prefix&'.properties '

Make sure this line -- neater without the extra space at the end -- represents a string that represents the full path to a properties file. What happens when you replace it with

"#application.translationpath&prefix&'.properties'#"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 28, 2009 Nov 28, 2009

Copy link to clipboard

Copied

Still the same 😞 I tried just removing the trailing space and adding the # signs.

Object Instantiation Exception.

An exception occurred when instantiating a Java object. The class must not be an interface or an abstract class. Error: ''.
The error occurred in /var/opt/coldfusion8/wwwroot/hosts/www.backup.habimat.be/Application.cfm: line 46
44 :      // fis and rb enable getResourceBundle method to load the properties files:
45 :      if (not isDefined("application.rb_#prefix#")) {
46 :         variables.fis = createObject("java", "java.io.FileInputStream").init(#application.translationpath#&#prefix#&'.properties');
47 :         variables.rb = createObject("java", "java.util.PropertyResourceBundle").init(variables.fis);
48 :         "application.rb_#prefix#" = variables.rb;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 28, 2009 Nov 28, 2009

Copy link to clipboard

Copied

LATEST

OK it works...the most stupid Windows <> Linux mistake...

tried to load NL.properties while it should be nl.properties.

Thanks for the help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation