Skip to main content
Inspiring
June 1, 2022
Answered

CF 2021 - Creating a new object throws

  • June 1, 2022
  • 3 replies
  • 560 views

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)
 
 
    This topic has been closed for replies.
    Correct answer --jojo--

    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 ); 

     

     

    3 replies

    --jojo--AuthorCorrect answer
    Inspiring
    June 6, 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 ); 

     

     

    BKBK
    Community Expert
    Community Expert
    June 6, 2022

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

    Charlie Arehart
    Community Expert
    Community Expert
    June 3, 2022

    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)
    BKBK
    Community Expert
    Community Expert
    June 3, 2022

    @--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

    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.

    --jojo--Author
    Inspiring
    June 3, 2022

    @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.

    BKBK
    Community Expert
    Community Expert
    June 4, 2022

    @--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
      }