Error "Element FAPI is undefined in a Java object of type class [Ljava.lang.String;."when starting the site/webtop application

Hi!

After verifying that my site works fine on the development system (macOS Sierra with Apache2 and ColdFusion 11/2016), I uploaded it to my hosting company (Windows with IIS 8.5). Whenever I try to start it (no matter if the site itself or the webtop), I keep getting the following error:

Element FAPI is undefined in a Java object of type class [Ljava.lang.String;.

The error occurred in D:/Inetpub/dermerker/farcry/core/packages/lib/error.cfc: line 580
578 : 		<cfelseif cgi.remote_addr eq "127.0.0.1">
579 : 			<cfset showError = true />
580 : 		<cfelseif application.fapi.getContentType(typename="configEnvironment").getEnvironment() eq "development">
581 : 			<cfset showError = true />
582 : 		</cfif>

coldfusion.runtime.UndefinedElementException: Element FAPI is undefined in a Java object of type class [Ljava.lang.String;.
	at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1773)
	...
	at cferror2ecfc1931938815$funcSHOWERRORPAGE.runFunction(D:\Inetpub\dermerker\farcry\core\packages\lib\error.cfc:580)
...
at cfApplication2ecfc1801957798$funcONERROR.runFunction(D:\Inetpub\dermerker\farcry\core\Application.cfc:550)

I looked up this forum, found the entry 5.2.7 to 7.1.1 Upgrade, double-checked my files with modius’s and Justin’s recommendations, and uploaded again. Alas, no change.

(The only thing I didn’t do is to restart the CF server, since I’m not running on a dedicated server but in a shared hosting environment.)

I understand from the previous conversation that the FarCry application did not start up. But how to force it to do (or to restart)? And why does everything work fine in development? Has this something to do with the IIS?

Any ideas/suggestions are welcome.

Thanks,
Thomas

This is a bug with rendering the error page due to the application having not started up correctly, and it should be fixed in the latest p710 and/or p720 branch, so I’d recommend updating to one of those so that you can see what the real error message is.

Alternatively, as a quick fix you can change line 580 in core/packages/lib/error.cfc to just have <cfelse> and it’ll always show the error. You should undo this change once you’ve debugged the underlying issue.

Thanks. I will give it a try tomorrow morning.

BTW, I run FarCry core 7.2.9 (sorry, I forgot to mention this in my original post).

Ok, I unmasked the error message and tried again. Now the OnApplicationStart method fails with the following error stack trace:

D:\Inetpub\dermerker\farcry\core\packages\farcry\javaloader\JavaLoader.cfc (line: 428)
D:\Inetpub\dermerker\farcry\core\packages\farcry\javaloader\JavaLoader.cfc (line: 48)
D:\Inetpub\dermerker\farcry\core\packages\farcry\utils.cfc (line: 27)
D:\Inetpub\dermerker\farcry\core\Application.cfc (line: 997)
D:\Inetpub\dermerker\farcry\core\Application.cfc (line: 257)

This traces back to the initialization of the java loading classes in method ensureNetworkClassLoaderOnServerScope, line urlClassLoader = createObject()...

<cffunction name="ensureNetworkClassLoaderOnServerScope"
			hint="makes sure there is a URL class loader on the server scope that can load me up some networkClassLoader goodness"
			access="private" returntype="void" output="false">
	<cfscript>
		var Class = createObject("java", "java.lang.Class");
		var Array = createObject("java", "java.lang.reflect.Array");
		var jars = queryJars();
		var iterator = jars.iterator();
		var file = 0;
		var urls = Array.newInstance(Class.forName("java.net.URL"), ArrayLen(jars));
		var counter = 0;
		var urlClassLoader = 0;
		var key = instance.static.uuid & "." & getVersion();
	</cfscript>

	<cfif NOT StructKeyExists(server, key)>
    	<cflock name="javaloader.networkclassloader" throwontimeout="true" timeout="60">
    	<cfscript>
    		if(NOT StructKeyExists(server, key))
    		{
				while(iterator.hasNext())
				{
					Array.set(urls, counter, createObject("java", "java.io.File").init(iterator.next()).toURL());
					counter = counter + 1;
				}

				urlClassLoader = createObject("java", "java.net.URLClassLoader").init(urls);

				//put it on the server scope
				server[key] = urlClassLoader;
			}
    	</cfscript>
    	</cflock>
    </cfif>
</cffunction>

My guess is that loading java classes into the server scope is just not allowed in a shared hosting environment due to security restrictions.

Any ideas how to work aorund his? And (since I am no Java expert): What are those classes required anyway? FarCry 4.X (I know, that was a long time ago) did well without them.

Creating Java objects is required for Core’s combine/minify and perhaps a
couple of other things, so if your shared host is blocking that then it may
be a problem.

FarCry 4.x also loaded java object, e.g. for the i18n. So, what is the difference now? And what shall/do I need to ask the host for?

Can you provide the error message/detail? I can’t quite tell what the particular error is just from the stack trace and code alone, it might not be the permission to create Java objects that is the problem as I first thought, because some of the lines above are already creating Java objects and it wasn’t throwing errors on those…

It may or may not be related, but what version of CF are you running in production and what version of java are you running as well?

Hi all,

the hosting company told me that the error was caused because the Java runtime permissions were disabled in the CF server (V11; don’t know the Java runtime version).

What I found interesting though, is, that creating Java objects for classes like java.io… have been processed.

Currently, there seems to be another issue with the site set-up, so: no breakthrough yet.

If there are any news, I will report. Hopefully, my experiences will help others in the future who want (or habe to) to doe shared hosting with a CF hosting company.

Thank you for your continued interest in this matter.