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

CF 2021 - Creating a new object throws

Explorer ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

Environment: Windows 

CF Version: 2021 Patch 4, single instance.

IIS Site

 

The following code (which is everywhere in our codebase), worked in CF2016.

 

variables.newObj = new svc.myobject( config = struct );

 

WHERE:

svc - is a map to our services directory

config - is a configuration structure containing various env configuration 

 

In CF2021, they're throwing the following error:

 

DetailError information java.lang.NoSuchMethodException: coldfusion.runtime.CFComponent.arrayPushVaradic([Ljava.lang.Object;)
MessageUnable to complete CFML to Java translation.
StackTracecoldfusion.compiler.CompilerInternalException: Unable to complete CFML to Java translation. at coldfusion.compiler.ASTruntimeCall.getVaradicMethod(ASTruntimeCall.java:618) at coldfusion.compiler.ASTruntimeCall.setMethod(ASTruntimeCall.java:305) at coldfusion.compiler.ExprVisitor.call(ExprVisitor.java:792) at coldfusion.compiler.ExprVisitor.transform(ExprVisitor.java:82) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:166) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:118) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:29) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:29) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:118) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:29) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:29) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:29) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:29) at coldfusion.compiler.Treewalker.postorder(Treewalker.java:29) at coldfusion.compiler.NeoTranslator.parseAndTransform(NeoTranslator.java:476) at coldfusion.compiler.NeoTranslator.translateJava(NeoTranslator.java:407) at coldfusion.compiler.NeoTranslator.translateJava(NeoTranslator.java:160) at coldfusion.runtime.TemplateClassLoader$TemplateCache$1.fetch(TemplateClassLoader.java:527) at coldfusion.util.LruCache.get(LruCache.java:180) at coldfusion.runtime.TemplateClassLoader$TemplateCache.fetchSerial(TemplateClassLoader.java:453) at coldfusion.util.AbstractCache.fetch(AbstractCache.java:58) at coldfusion.util.SoftCache.get_statsOff(SoftCache.java:153) at coldfusion.util.SoftCache.get(SoftCache.java:92) at coldfusion.runtime.TemplateClassLoader.findClass(TemplateClassLoader.java:721) at coldfusion.runtime.RuntimeServiceImpl.getFile(RuntimeServiceImpl.java:1229) at coldfusion.runtime.RuntimeServiceImpl.resolveTemplatePath(RuntimeServiceImpl.java:1181) at coldfusion.runtime.TemplateProxyFactory.getResolvedFile(TemplateProxyFactory.java:1464) at coldfusion.runtime.TemplateProxyFactory.getTemplateFileHelper(TemplateProxyFactory.java:1812) at coldfusion.cfc.ComponentProxyFactory.getProxy(ComponentProxyFactory.java:77) at coldfusion.cfc.ComponentProxyFactory.getProxy(ComponentProxyFactory.java:56) at coldfusion.runtime.CFPage.___createObjectInternal(CFPage.java:16891) at coldfusion.runtime.CFPage._createObject(CFPage.java:16866) at cfcalendarService2ecfc181088373$funcINIT.runFunction(C:\signupgenius\wwwroot\model\service\calendarService.cfc:54) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:623) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:553) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:516) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:463) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:438) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:681) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:980) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:762) at coldfusion.runtime.CFPage.___createObjectInternal(CFPage.java:16907) at coldfusion.runtime.CFPage._createObject(CFPage.java:16880) at cfappResetService2ecfc2016787770$funcRESETCALENDARSERVICE.runFunction(C:\signupgenius\wwwroot\model\service\appResetService.cfc:256) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:623) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:553) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:516) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:463) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:438) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:310) at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:5011) at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:4991) at cfappResetService2ecfc2016787770$funcRELOADAPP.runFunction(C:\signupgenius\wwwroot\model\service\appResetService.cfc:81) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:623) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:553) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:516) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:463) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:438) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:681) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:980) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:762) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:4165) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:4129) at cfApplication2ecfc1747619718$funcSETUPAPPLICATION.runFunction(C:\signupgenius\wwwroot\Application.cfc:408) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:623) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:516) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:463) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:438) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:310) at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:5011) at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:4991) at cfApplication2ecfc1747619718$funcONAPPLICATIONSTART.runFunction(C:\signupgenius\wwwroot\Application.cfc:29) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:623) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:516) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:463) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:438) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:310) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:975) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:696) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:503) at coldfusion.runtime.AppEventInvoker.invoke(AppEventInvoker.java:115) at coldfusion.runtime.AppEventInvoker.onApplicationStart(AppEventInvoker.java:238) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:436) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:43) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:162) at coldfusion.filter.IpFilter.invoke(IpFilter.java:45) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:97) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:60) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.CfmServlet.service(CfmServlet.java:231) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:311) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:46) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:47) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at coldfusion.inspect.weinre.MobileDeviceDomInspectionFilter.doFilter(MobileDeviceDomInspectionFilter.java:57) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:47) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:377) at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:463) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:834)
 
 

Views

218

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

correct answers 1 Correct answer

Explorer , Jun 06, 2022 Jun 06, 2022

Ok, I found out what's causing it: 

 

Somewhere in the component we are using arrayPush() like so:

message = [];
try {
    // do something
}
catch( any err ){
   arrayPush(message, err.message); 
}

 

This was tolerated by 2016 - in CF2021, I had to define arrayPush( array=message, value=err.message ); 

 

 

Votes

Translate

Translate
Community Expert ,
Jun 03, 2022 Jun 03, 2022

Copy link to clipboard

Copied

@--jojo-- , the fact that the code worked in CF2016 is no guarantee. ColdFusion is constantly improving. So ColdFusion 2021 might produce an error for code which worked in ColdFusion 2016.

 

The error message suggests that ColdFusion thinks 'myobject' is a method. Is it?

 

There are other questions besides:

  • What is the full path of the CFC that you wish to instantiate?
  • Does the CFC have a property named 'config' and an init method?

 

In any case, I have created the following example, which you can compare with your set-up. I am on CF2021 Update 4.

 

Step 1: I registered the mapping svc in the Administrator

BKBK_0-1654267105614.png

Step 2: Create the CFC C:\ColdFusion2021\cfusion\wwwroot\services\MyObject.cfc. Its code is:

<cfcomponent accessors="yes">
                <cfproperty name="config">
                <cffunction name="init" returntype="any">
                               <cfargument name="config" type="struct">
                               <cfset variables.config=arguments.config>

                               <cfreturn this>
                </cffunction>

                <cffunction name="myFunc" returntype="string">
                               <cfreturn "Test: OK">
                </cffunction>
</cfcomponent>

 

Step 3: Create testPage.cfm containing the following code, and launch it in the browser:

<cfscript>
struct=cgi;
variables.newObj =new svc.myobject( config=struct );
writedump(variables.newObj.getConfig());
</cfscript>

 

The result is a dump of the CGI struct. Hence, no errors.

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
Explorer ,
Jun 03, 2022 Jun 03, 2022

Copy link to clipboard

Copied

@BKBK - exactly my point (did something changed in CF2021) that is causing the stack trace I've posted. (?) 

 

Minus step1 (which the "svc" path is defined in the application.cfc), the sample code you posted is exactly what I have. There is an init() that handles the struct argument.

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 ,
Jun 04, 2022 Jun 04, 2022

Copy link to clipboard

Copied

@--jojo-- , I did the following:

  1.  Delete the svc mapping from the ColdFusion Administrator;
  2.  Restart ColdFusion;
  3.  Place this line of code in the pseudo-constructor area of Application.cfc:
    this.mappings["/svc"] = expandPath('/services');
    // Alternative
    // this.mappings["/svc"] = "C:\ColdFusion2021\cfusion\wwwroot\services";​
  4.  Launch testPage.cfm in the browser.
    It worked as expected! 🙂

    So, verify the details of your environment, especially because you have made a change in ColdFusion version from 2016 to 2021.
    Are the CFC paths still valid? For example, you spoke of the 'services' directory, whereas the error message shows a 'service' directory. In addition, you've said that the CFC you wish to instantiate, presumably myObject.cfc, has an init method. Yet the init method in the error message belongs to calendarService.cfc instead.
    Did you mistakenly define a function inside another function anywhere? 
    Is the correct Application.cfc in effect?
    Is this.mappings["/svc"] defined in Application.cfc's pseudoconstructor area and not somewhere else? Example:
    component {
        // Define this.mappings["/svc"] here, not in one of the event-handlers 
        onApplicationStart() {}
        onSessionStart() {}
        onRequestStart() {}
        // ... etc
    }

 

 

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 ,
Jun 03, 2022 Jun 03, 2022

Copy link to clipboard

Copied

Jojo, while it's understandable that you think something changed in cf2021 to cause your problem, there are many other possible explanations...and too many to list them all here.

 

Let's start with something simpler: can you easily rename or copy the files involved: the one doing the calling and the cfc being called, and the call to it? Does it work then? It may seem silly, but if things then work, that tells us this is about the compiled cfml created for the original files. And we could talk about how to deal with that, and what happened to cause the problem.

 

If it fails the same way, that would point us in other directions. Let's take 'em one step at a time.

 

And if somehow this is important to solve asap, I'll suggest that we might solve it (and assess/discuss/try other options to get there) quickly in a screenshare consulting session. If that interests you, see more on my rates, approach, satisfaction guarantee, and online calendar at carehart.org/consulting.

 

Otherwise we can all proceed here. 


/Charlie (troubleshooter, carehart.org)

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
Explorer ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

Ok, I found out what's causing it: 

 

Somewhere in the component we are using arrayPush() like so:

message = [];
try {
    // do something
}
catch( any err ){
   arrayPush(message, err.message); 
}

 

This was tolerated by 2016 - in CF2021, I had to define arrayPush( array=message, value=err.message ); 

 

 

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 ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

Nice to hear you're up and running with CF2021. Thanks for sharing your finding.

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 ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

Hmm, no, Jojo. There are two things that seem incorrect about your conclusion (though it "worked" for you).

 

First, let's note that Arraypush (as a built-in CF function) was in fact only ADDED in cf2021. That's indicated in that doc page you point to, where its "History" section says, "New in ColdFusion (2021 release)". 

 

If it was working for you previously, then you must have instead been using some user-defined function of that name, which your code (or code you included) made available. Now, normally, if you have code defining such a function and it conflicts with a built-in function, that should itself generate an error. (Someone could have hidden that error with a try/catch.)

 

Second, even that base code you offered (without the arg names in the function) works just fine on CF2021, with or without adding the named args. Again, I get it that you say it doesn't work in your environment, but anyone reading along can see this for themselves using Adob'es cffiddle.org site (or trycf.com).  I ran it at cffiddle both ways, no problem (though you had a typo in your first line creating the message aray). Here are links to see and run each of the versions without the named args, and with the named args.

 

So as you can see, there's something not right about your conclusion (and it being "the correct answer", as is). It really feels like something else must explain why that change was needed for you.

 

And more than anything, again, arraypush was not available as a built-in function until CF2021, but you are saying you have code that ran it as CF2016. Again, something is amiss there. (Note that if you change the drop-down at the cffiddle examples to use CF2018 or 2016, you get an error saying, "Variable ARRAYPUSH is undefined", because CF is not recognizing it as a valid built-in function.)

 

Not picking a fight here, just trying to get all concerned to the "right answer". And I realize you may choose to leave it at "well, this change fixed things for me". In that case, I leave all this here for any others who may find the thread, or be interested in the issue. And of course I'm open to correction if somehow I'm making a mistake here.


/Charlie (troubleshooter, carehart.org)

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 ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

LATEST

Ah, wait. Let's turn things around: in your example above (the one today and the one last week), I suspect now it's that you have this code in a CFC where you DO have a method defined called arraypush. So THAT could at least explain why you're hitting that original conflict.

 

First, I never noticed the reference to arraypush buried in your first error message on June 1, "Error information java.lang.NoSuchMethodException: coldfusion.runtime.CFComponent.arrayPushVaradic([Ljava.lang.Object;)". then second, given that the standalone code you offered today just "worked" for me, this kept me from realizing you must have been referring to your OWN arraypush method.

 

So that is interesting (and perhaps a bug): it seems however you were defining YOUR arraypush, the problem indeed is that in CF2021 you are hitting a conflict with the new built-in Arraypush, but CF is reporting it with that odd error rather than a more straight-forward one.

 

This would seem worth your filing as a bug report (tracker.adobe.com), if you're motivated to do that. Or perhaps bkbk will. I suspect this problem would happen with other functions (not arraypush uniquely), but perhaps it's different when it's a CFC method vs a user-defined function in a CFM page (which is what I was thinking of in my last reply, when I said CF should have thrown an error). 

 

I don't have time right now to code up exampels to demonstrate that. If either of you may (or know you will not), chime in and we can figure how best to proceed. As always, I just want to help.


/Charlie (troubleshooter, carehart.org)

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