Skip to main content
Known Participant
October 24, 2024
Answered

update 17 and split

  • October 24, 2024
  • 3 replies
  • 2890 views

applied update 17 to some of our dev servers and was told that certain code no longer works - 

specifically when invoking the split command - 

the below code is something being actively worked on - my concern is that there might be other things it could affect -   is this unusual?

 

<cfif len(trim(manager)) gt 0>
<cfset mgr = manager.split(",")[1]/>
<cfset mgr = mgr.substring(3,len(mgr))/>
<cfset mgr_fname = mgr.split(' ')[1]/>
<cfset mgr_lname = mgr.split(' ')[2]/>
<cfelse>
<cfset mgr = ''/>
<cfset mgr_fname = ''/>
<cfset mgr_lname = ''/>
</cfif>

 

error from log:

Error","ajp-nio-127.0.0.1-8020-exec-9","10/24/24","11:00:00","HumanscaleHostSite","The split method was not found.Either there are no methods with the specified method name and argument types or the split method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity. The specific sequence of files included or processed is: E:\internal\betahost.h\schedtasks\ad.cfm, line: 17"

    This topic has been closed for replies.
    Correct answer BKBK
    quote

    Thanks for the suggestion. Unfortunately, we tried it, and still got the split method was not found error.

     

    <cfloop query=#Q_ADResults#>
     
    By @patrick_8394

     

    As I said, change that line to

     

    <cfloop query="Q_ADResults">

     

    and apply Pete's suggestion, too.


    I now suspect the error arises because ColdFusion is confusing the manager in variables scope with the manager in query scope. So, separate the concerns. For example, by introducing a new variable, currentManager, in variables scope.

     

    To be clear, here's the suggestion in full

     

    <cfloop query="Q_ADResults">
    <cftry>
      <cfset currentManager = trim(toString(Q_ADResults.manager[currentrow]))>
      <cfif len(currentManager) gt 0>
                     <cfset mgr = currentManager.split(",")[1]/>
                     <cfset mgr = mgr.substring(3,len(mgr))/>
                     <cfset mgr_fname = mgr.split(' ')[1]/>
                     <cfset mgr_lname = mgr.split(' ')[2]/>
      <cfelse>
                     <cfset mgr = ''/>
                     <cfset mgr_fname = ''/>
                     <cfset mgr_lname = ''/>
      </cfif>
      
       <cfoutput>             
           mgr_fname: #mgr_fname#  <br>
           mgr_lname: #mgr_lname#  <br>
       </cfoutput>
     
    <cfcatch>
       CurrentManager: <cfoutput>#currentManager#</cfoutput><br>  
    </cfcatch>
    </cftry>
    </cfloop>

     

     

     

     

     

    3 replies

    Charlie Arehart
    Community Expert
    Community Expert
    November 3, 2024

    I realize this is a few days after your original question, but assuming the problem remains (and beyond the ideas shared so far by Yorik, Patrick, bkbk and Pete), I have a different question, especially since you say the problem happens only on SOME of your AD query results. 

     

    I think a simple change will help better diagnose what's amiss. First, it's not clear whether your error is happening on line 2, 4, or 5 of your code. There error refers to line 17. Assuming that's line 2 above, what do you see if you change that line:

     

    <cfset mgr = manager.split(",")[1]/>

     

    to:

     

    <cftry>
       <cfset mgr = manager.split(",")[1]/>
       <cfcatch>
          <cfdump var="#manager#" >
          <cfabort>
       </cfcatch>
    </cftry>

     

     

    The point here is to see just what is in that manager scope. Or if you want to, you could put all the code in the cftry and dump both the manager and mgr variables, since again we can't know from the error which is the one that has your issue.

     

    Finally, you've not said what cf update you were on BEFORE applying cf2021 update 17. Was it before update 13? If so, there may be a connection to its change of default behavior regarding implicit scope searching. See the technote for that update for more on that change, as well as options for reverting the behavior change at the app or jvm level.  If somehow the dump doesn't help, and you were on update 12 or earlier, let us know if changing that default behavior might help. 

    /Charlie (troubleshooter, carehart. org)
    BKBK
    Community Expert
    Community Expert
    November 3, 2024

    Charlie, my last post contains your suggestion. It is clear from my last post that the issue is caused by the variable manager calling the split method.

     

    In fact, you can reproduce it yourself, using:

     

    <cfset Q_ADResults = queryNew("manager","varchar", {manager="CN=Maria Guadalupe López,OU=Human Resources,OU=Nogales,OU=Mexico,OU=North America,OU=Domain Users,OU=Offices,DC=humanscale,DC=com"})>
    
    <cfloop query="Q_ADResults">
    	<cftry>
    		<cfset mgr = manager.split(",")[1]/>
    	<cfcatch>
    		manager variable is of type:<cfoutput> #manager.getClass().getName()#</cfoutput> <br><br>
    	   <cfdump var="#cfcatch#" label="cfcatch dump">
    	   
    	</cfcatch>
    	</cftry>
    </cfloop>
    

     

    The result is

    The cause of the issue is that the method split() is being called by manager, which is not of String type. It is of type coldfusion.sql.QueryColumn.

    Charlie Arehart
    Community Expert
    Community Expert
    November 3, 2024

    Bkbk, while your dump is looking at the variable in your sample code, my focus was focused on Pete's original code...to help him given that his reply to you earlier said his AD query was returning different info.

     

    Are you trying to assert in your code that you've found the exact cause and solution? Or was yours just some more code to help Pete try to figure things out? That's how I read it, so mine was indeed added as SEPERATE from what you wrote--which is in fact why I created it as a new thread (though I acknowledged what you and Pete F had written). As you often like to point out, we're all here trying to help. I didn't feel my suggestion was stepping on or dismissing yours.

     

    And either way, my question to him about his update level still stands. 

    /Charlie (troubleshooter, carehart. org)
    BKBK
    Community Expert
    Community Expert
    October 27, 2024

    Like @aliaspooryorik , I too did a test on CFFiddle using Update 17 of ColdFusion 2021. There was no error.

    <cfset manager ="John James Smith,Mary Jane Robinson">
    
    <cfif len(trim(manager)) gt 0>
    	<cfset mgr = manager.split(",")[2]/>
    	<cfset mgr = mgr.substring(5,len(mgr))/>
    	<cfset mgr_middle_name = mgr.split(' ')[1]/>
    	<cfset mgr_last_name = mgr.split(' ')[2]/>
    <cfelse>
    	<cfset mgr = ''/>
    	<cfset mgr_fname = ''/>
    	<cfset mgr_lname = ''/>
    </cfif>
    <cfoutput>
    	mgr_middle_name: #mgr_middle_name# <br>
    	mgr_last_name: #mgr_last_name# 
    </cfoutput>

    https://cffiddle.org/app/file?filepath=5149d2c1-49d1-4aca-879c-4e6ef33ff4c3/e3ecff66-71ce-4e00-bd2e-cdd58947ee0a/7afa49cd-80a9-463c-82f8-606910ffa8cd.cfm 

     

     

    Participating Frequently
    October 28, 2024

    Hi Support,

     

    We do understand you run the code using hardcoded value for the manager string returning no error, and we ran the same, also no errors. However, the manager field / string values are returned from AD (Active Directory) using cfldap. Let me show you more in the code as below (removed the server name and creds for demonstration purpose).

     

    The manager attribute from AD contains the value like this

     

    CN=Maria Guadalupe López,OU=Human Resources,OU=Nogales,OU=Mexico,OU=North America,OU=Domain Users,OU=Offices,DC=humanscale,DC=com

     

    In some cases, people’s name would have special characters in Spanish or French name, not sure if that would affect anything for the split function. We have changed to use mid function instead. But we were wondering the same code using the java split function worked with no errors before the update 17. Please let us know if you have any ideas. Thanks for your time.

     

    <cfldap action="query"

       server=""

       name="Q_ADResults"

       start=""

       username=""

       password=""

       attributes ="createTimestamp,whenChanged,department, givenname,sn,cn,displayname,samaccountname,userprincipalname,lockoutTime,lockoutDuration,IsAccountLocked,title,mail,physicalDeliveryOfficeName,streetaddress,l,st,postalcode,co,c,hometelephone,telephoneNumber,mobile,fax,manager,ExtensionAttribute1"

       scope="subtree">

                  

    <cfloop query=#Q_ADResults#>

    <cftry>

                                  <cfif len(trim(Q_ADResults.manager)) gt 0>

                                                 <cfset mgr = manager.split(",")[1]/>

                                                 <cfset mgr = mgr.substring(3,len(mgr))/>

                                                 <cfset mgr_fname = mgr.split(' ')[1]/>

                                                 <cfset mgr_lname = mgr.split(' ')[2]/>

                                  <cfelse>

                                                 <cfset mgr = ''/>

                                                 <cfset mgr_fname = ''/>

                                                 <cfset mgr_lname = ''/>

                                  </cfif>

        <cfcatch>

                   <cfoutput>#Q_ADResults.manager#</cfoutput><br>

                   </cfcatch>

    </cftry>

    </cfloop>

    BKBK
    Community Expert
    Community Expert
    October 28, 2024

    Taking the hint from you, I ran the following code on CF2021 Update 17 on Cffiddle:

     

    <cfset manager ="CN=Maria Guadalupe López,OU=Human Resources,OU=Nogales,OU=Mexico,OU=North America,OU=Domain Users,OU=Offices,DC=humanscale,DC=com">
    
    <cfif len(trim(manager)) gt 0>
    	<cfset mgr = manager.split(",")[1]/>
    	<cfset mgr = mgr.substring(3,len(mgr))/>
    	<cfset mgr_fname = mgr.split(' ')[1]/>
    	<cfset mgr_mname = mgr.split(' ')[2]/>
    	<cfset mgr_lname = mgr.split(' ')[3]/>
    <cfelse>
    	<cfset mgr = ''/>
    	<cfset mgr_fname = ''/>
    	<cfset mgr_mname = ''/>
    	<cfset mgr_lname = ''/>
    </cfif>
    <cfoutput>
    	mgr_fname: #mgr_fname# <br>
    	mgr_mname: #mgr_mname# <br>
    	mgr_lname: #mgr_lname# <br>
    </cfoutput>

     

    https://cffiddle.org/app/file?filepath=9cf84e08-8565-43b6-b710-d8a0472bb9ac/73ad24d8-be36-4aa6-8586-0b1d4bf91b0d/54fda563-c261-47ed-8844-0b693770a227.cfm 

     

    As you can see, it works as expected.

     

    If you're still having an issue with this, then you will probably have to look elsewhere. For example, shouldn't the line

     

      <cfset mgr = manager.split(",")[1]/>

     

    be

     

      <cfset mgr = Q_ADResults.manager.split(",")[1]/>

     

    instead?

    Participating Frequently
    October 25, 2024

    None of those are CFML member functions, they are methods of `java.lang.String`. A pure CFML version of the above would be to use `listToArray()` and `mid`. 

     

    Having said that I wouldn't expect the behaviour to change. Judging my the error you mention of `The split method was not found.` I think the issue is that `manager` is not being set to a string at all.

     

    Here is your code running on ACF2021 update 17 with no errors when manager is a string.

     

    https://cffiddle.org/app/file?filepath=9f029a87-df43-4679-8ad1-e68e1aef64e4/af5419cf-9755-4f3a-998d-f01f0ccba9be/180d3834-2245-44c8-b48d-32567258f885.cfm