Lucee admin throws exception determining Java version

Hi, I’m trying to run Lucee in a windows container (openjdk:16-windowsservercore-1809 to be exact).

When I try to view the Lucee server admin, I get an exception:

Array index [2] out of range, array size is [1]
The Error Occurred in
/admin/overview.cfm: line 777
called from /admin/overview.cfm: line 296
called from /admin/web.cfm: line 492
called from /admin/server.cfm: line 2

Looking at line 777 of overview.cfm I can see it’s trying to determine the Java version:

<cfscript>
	function getJavaVersion() {
		var verArr=listToArray(server.java.version,'.');
		if(verArr[1]>2) return verArr[1];
		return verArr[2];
	}
</cfscript>

I’m running the latest Lucee (5.3.7.43) on Tomcat 9. This is the output of Java --version

openjdk version “16-ea” 2021-03-16
OpenJDK Runtime Environment (build 16-ea+21-1209)
OpenJDK 64-Bit Server VM (build 16-ea+21-1209, mixed mode, sharing)

Any suggestions other than switch to a different JVM that doesn’t trip up the code in overview.cfm?

what is this value?

16-ea

My base image is from here: https://hub.docker.com/_/openjdk

(openjdk:16-windowsservercore-1809 to be exact)

Maybe since it is an early access it doesn’t have an official version number yet? Try 15 or below.

OK. Minor bug. Each new major release of OpenJDK return only the major with java.version.
Example 14+36 only returns “14” and 14.0.2_12 return “14.0.2”.

Bug created and fix submitted.

EDIT:
Actually that didn’t fix it.
The problem is JDK 16 returns “16-ea” for the server.java.version which causes the error. This is because of the pre-release info “ea” appended to the version.
var verArr=listToArray(server.java.version,’.-’); would fix the problem but I don’t know if it would be worth it.

I added some code in a comment in your PR. This should fix it.

function getJavaVersion() {
	var verArr=listToArray(server.java.version,'.');
	if(verArr[1]>2) {
		return verArr[1];
	} elseif (verArr.len() GT 1) {
		return verArr[2];
	} else {
	    return val(server.java.version);
	}
}

image

I created a new pull request for this, I referenced your ticket.

1 Like