[Coldbox 5.0.0] Lucee 4.5 - Application.cfc cannot load icu4j java component

Just started migration from CF2016 to Lucee 4.5 engine. Although I have enabled the cbi18n module, my application relies heavily on the the IBM icu4j Java i18n component. I have placed the latest icu4j-61.1.jar file with all dependencies in the /lib directory and loaded the needed components in the Application.cfc within the onApplicationStart() method. The Application.cfc file looks as follows:

// application start
public boolean function onApplicationStart(){

application.cbBootstrap = new coldbox.system.Bootstrap( COLDBOX_CONFIG_FILE, COLDBOX_APP_ROOT_PATH, COLDBOX_APP_KEY, COLDBOX_APP_MAPPING );
application.cbBootstrap.loadColdbox();

// Identify the absolute path to the resource bundles

var Application.rb_path = GetDirectoryFromPath(expandpath("/samovar/includes/i18n/rbundles/"));
var Application.rbFile1 = GetDirectoryFromPath(expandpath("/samovar/includes/i18n/rbundles/MenuRB.properties"));
var Application.rbFile2 = GetDirectoryFromPath(expandpath("/samovar/includes/i18n/rbundles/ScreenRB.properties"));
var Application.rbFile3 = GetDirectoryFromPath(expandpath("/samovar/includes/i18n/rbundles/ParamRB.properties"));

// Instantiate IBM icu4j-61.1 i18n libraries (http://apps.icu-project.org/apiref/icu4j/)

//var Application.Ulocale = createObject(“java”, “com.ibm.icu.util.ULocale” );
//var Application.icu4jTZ = createObject(“java”, “com.ibm.icu.util.TimeZone”);
//var Application.Ucalendar = createObject(“java”, “com.ibm.icu.util.Calendar”);
//var Application.icu4jDateFormat = createObject(“java”, “com.ibm.icu.text.DateFormat”);
//var Application.icu4jDateFormatSymbols = createObject(“java”, “com.ibm.icu.text.DateFormatSymbols”);
//var Application.msgFormat = createObject(“java”, “com.ibm.icu.text.MessageFormat”);
//var Application.icu4jCollator = createObject(“java”, “com.ibm.icu.text.Collator”);

var Application.rB = createObject(“java”, “java.util.PropertyResourceBundle”);
var Application.fis = createObject(“java”, “java.io.FileInputStream”);
var Application.StringUtils = createObject(“java”, “org.apache.commons.lang.StringEscapeUtils”);
var Application.javaRB = createObject(“component”,“samovar.includes.i18n.rbundles.javaRB”);

return true;
}

When started, the Lucee engine fires an error (see attached) for all the com.ibm.icu classes despite the fact they all are properly accessible from the /lib/icu4j-61.1.jar file. This issue never occurred in my previous environment running Coldbox4.3 on the CF2016 engine. Any suggestions?

started migration from CF2016 to Lucee 4.5 engine.

Why are you moving to Lucee 4? It’s basically end of lifed already. Lucee 5 has been out for a long time now.

I have placed the … jar file with all dependencies in the /lib directory

What lib directory exactly? How are these jars getting picked up? this.javaSettings??

Thanks!

Hi Brad, the default engine installed by CommandBox with ColdBox 5.0.0 was Lucee 4.5.5. I do not mind installing the Lucee 5 engine. What is the stable version of Lucee today?
As for the /lib directory, it comes by default with the Coldbox installation. The docs recommend to put all the Java jar files there. Application.cfc picks up the files with this I believe:

// Java Integration
this.javaSettings = {
loadPaths = [ “.\lib” ],
loadColdFusionClassPath = true,
reloadOnChange= false
};

Here is what I have in that /lib directory:

commons-lang-2.4.jar
mysql-connector-java-5.1.40-bin.jar
icu4j-61.1.jar

Application.cfc loads “org.apache.commons.lang.StringEscapeUtils” properly but not anything related to icu4j-6.1.1.jar…
I also have MySQL properly configured, which means Application.cfc properly loads the MySQL connector.

Brad, problem solved. The issue was simply with the javaSettings below. By default loadPaths = [ “.\lib” ]. I am a Mac guy, just reversed the slash to loadPaths = [ “./lib” ] and it now works.
Thanks for pointing to the Java integration settings.

Now for Lucee, what is the current stable version working with Coldbox 5.0.0 I should migrate to? Lucee 5.2.7+62?

Thanks

the default engine installed by CommandBox with ColdBox 5.0.0 was Lucee 4.5.5.

You are on an old version of CommandBox 4.0 now comes with Lucee 5.2.

What is the stable version of Lucee today?

5.2.7.63

Application.cfc picks up the files with this I believe:

Thank you for clarifying. You didn’t show that code in your original post and I wasn’t clear if you had it in place or not.

Application.cfc loads “org.apache.commons.lang.StringEscapeUtils” properly

I’m 90% sure the Lucee installation already includes the apache commons lang jar so that doesn’t really prove anything in regards to whether your javasettings are working.

I also have MySQL properly configured, which means Application.cfc properly loads the MySQL connector.

Lucee also bundles the jar for MySQL plus JDBC drivers must be loaded by the system class loader anyway so I’m also fairly sure this also doesn’t prove anything.

As a test, can you try two things please?

  1. Load these jars via the libdirs setting in your CommandBox server and see if it makes any difference
  2. Try creating the Java classes in onRequestStart to see if the jars haven’t been loaded yet when onApplicationStart runs.

By default loadPaths = [ “.\lib” ]. I am a Mac guy, just reversed the slash to loadPaths = [ “./lib” ] and it now works.

Interesting. Can you send a pull request for this. Luis, can you confirm if this works out of the box for you? I think Luis set that code up and he’s on a Mac so I’d be surprised if it didn’t work out of the box unless he never tested it.

Hi Brad,

I am now on Coldbox 5.0.0 with Lucee 5.2.7.63 on Mac Sierra. Everything looks now fine after changing to loadPaths = ["./lib] in the java settings in Application.cfc. What is to be noted though is that on Coldbox 4.3 with engine CF2016(2016.0.06+308055), the java settings were unchanged from the default (meaning .\lib) and the IBM java i18n libraries loaded without problems in Application.cfc.

This may be a bug in Lucee. Or at least an incompat. I would recommend:

  1. Sending a pull request to our app template repo so the code works out of the box on all engines
    https://github.com/coldbox-templates/advanced-script

  2. Entering a compatibility ticket for Lucee for them to match Adobe.
    https://luceeserver.atlassian.net/

What is the base branch I should use to create the pull request? I can also share with you my bitbucket repository at https://bitbucket.org/aquariuslogics/samovar/src/master/
if it makes sense.

What is the base branch I should use to create the pull request?

That repo I linked to only has one branch (master) so I guess take your pick?? :slight_smile: