Solved

CF 9.0 upgrade issue

Posted on 2011-09-23
11
276 Views
Last Modified: 2012-05-12
Experts,

I am upgrading from CF 7.0 to CF 9.0 and I have the following code in my application and it is failing at <cfset siteType = "#server.servervars.Environment#"> and the error is
"Element SERVERVARS.ENVIRONMENT is undefined in SERVER."

I understand that HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\Web_Server doesn't make sense for CF 9.0 and any help to resolve this is much appreciated and not sure how it worked for CF 7.0

Thanks in advance for your help.
<cfif not isdefined("server.servervars")>
	<cfset server.servervars = structNew()>
	<cfregistry action = "get"
 branch = "HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\Web_Server" 
 entry = "Environment" type = "String" variable = "server.servervars.environment">
 	<cfregistry action = "get"
 branch = "HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\Web_Server" 
 entry = "SSLPort" type = "String" variable = "server.servervars.SSLPort">
</cfif>
<cfoutput>

<cfset siteType = "#server.servervars.Environment#">

Open in new window

0
Comment
Question by:Tpaul_10
  • 6
  • 5
11 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 36588780

I don't use cfregistry much, but the docs on action="get" say:
        "If the value does not exist, the cfregistry tag does not create an entry"

Seeing as how it's outdated, perhaps you just need to add some code that generates a default if action="get" fails.  Not sure what that default should be.  Depends on what the variables are used for .. ?

<cfif not structKeyExists(server.servervars, "environment")>
    <cfset server.servervars.environment = "set some default here">
</cfif>
<cfif not structKeyExists(server.servervars, "SSLPort  ")>
    <cfset sserver.servervars.SSLPort  = "set some default here">
</cfif>

Open in new window




0
 

Author Comment

by:Tpaul_10
ID: 36588929
Thanks for the quick reply and I am also trying to see what is that environment varibale is and what for.
I have attached the complete file to give you an idea.

Thanks
<!--- Set IP address, site type, and actual server name --->

<cfsilent>
<cfset theKey = 0000>

<cfset ipaddress="">
<cfset siteType="">
<cfset phyRoot="">
<cfset curPhyRoot="">
<cfset curWwwRoot="">
<cfset refPage="">
<cfset curPage="">
<cfset refPageName="">
<cfset curPageName="">
<cfset gb_dsn=""> 
<cfset my_dsn=""> 
<cfset forcedport=""> <!--- either 80 or 443 --->

<!--- Get server name 													--->
<!--- start of redirect. --->
<cfswitch expression="#cgi.server_name#">
	<cfcase value="www.mycompany.com,mycompany.com">
		<cflocation url="http://www.ourcompany.com#cgi.path_info#">		
	</cfcase>
</cfswitch>
<!--- End of redirect. --->

<!--- We're now pulling the environment type and the SSL port directly from	--->
<!--- the registry instead of using the case statement to sniff for the		--->
<!--- cgi.server_name value.												--->
<!--- moved into server scope to avoid repeated registry hits --->
<cfif not isdefined("server.servervars")>
	<cfset server.servervars = structNew()>
	<cfregistry action = "get"
 branch = "HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\Web_Server" 
 entry = "Environment" type = "String" variable = "server.servervars.environment">
 	<cfregistry action = "get"
 branch = "HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\Web_Server" 
 entry = "SSLPort" type = "String" variable = "server.servervars.SSLPort">
</cfif>
<cfoutput>

	<cfset siteType = "#server.servervars.Environment#">
	<cfset caller.ForcedPort = "#server.servervars.SSLPort#">
	<cfset caller.my_dsn="mydsn">
	<cfset caller.thekey=#thekey#>
	<cfset caller.ipAddress = "#ipaddress#">
	<cfset caller.siteType = "#siteType#">	
		
	<!---  Set physical root using variable from previous set--->
	<cfset phyRoot="d:\FolderName\wwwroot\">
	
	<cfset caller.phyRoot = "#phyRoot#">
	<cfset caller.dev = "1"><!--- Toggles debugging in product index.cfm: 0 (off), 1 (on) --->
	
	<!--- Set current page name w/o extension--->
	<!--- where to start in string --->
	<cfset varPlace = 1>
	<!--- as long as there are slashes --->
	<cfloop condition = "varPlace NEQ 0">
		<cfset varPlaceEnd = varPlace>
	<!--- look in current page string to find slashes --->
		<cfset varPlace = find("/", cgi.script_name, varPlace)>
	<!--- As long as one is found keep looking --->
		<cfif varPlace NEQ 0>
			<cfset varPlace = varPlace + 1>
		</cfif>
	</cfloop>
	
	<cfset curPage = #right(cgi.script_name, len(cgi.script_name) - varPlaceEnd + 1)#>
	<cfset curWwwDir = #left(cgi.script_name, len(cgi.script_name) - len(curPage))#>
	<cfset extPlace = find(".", curPage)>
	<cfif extPlace NEQ 0>
		<cfset curPageName = #left(curPage,extPlace - 1)#>
	</cfif>
	
	<cfset caller.curPage = "#curPage#">
	<cfset caller.curPagename = "#curPageName#">
	<cfset caller.curWwwDir = "#curWwwDir#">
	<cfset curPhyDir = replacenocase(curWwwDir, "/", "")>
	<cfset caller.curPhyDir = replacenocase(curPhyDir, "/", "\", "ALL")>
	
	
	<!---  Set referrer page name w/o pagename--->
	<!--- Where to start in string --->
	<cfset varPlace = 1>
	<!--- String to work with --->
	<cfset tempString = cgi.http_referer>
	<!--- Find if parameters were passed in URL --->
	<cfset varPlace = find("?", tempString, varPlace)>
	<!--- Remove paramaters if present --->
	<cfif varPlace NEQ 0>
	<!--- extra charcters is to remove ? in URL --->
		<cfset tempString = mid(tempString,1,varPlace - 1)>
	</cfif>
	
	<!--- Reset where to start in string now that string is only url without parameters --->
	<cfset varPlace = 1>
	<!--- Continue through this loop until no more / are found --->
	<cfloop condition = "varPlace NEQ 0">
	<!--- Move to characters after last / found --->
		<cfset varPlace = varPlace + 1>
	<!--- Set End location to last succesful find  --->
		<cfset varPlaceEnd = varPlace>
	<!--- Find slash in string --->
		<cfset varPlace = find("/", tempString, varPlace)>
	</cfloop>
	<!--- return string from after last slash up to end of string--->
	<cfif len(tempString) - varPlaceEnd + 1 GT 0>
		<cfset refPage = #right(tempString, len(tempString) - varPlaceEnd + 1)#>
	<cfelse>
		<cfset refPage = "">
	</cfif>
	<cfset extPlace = find(".", refPage)>
	<cfif extPlace NEQ 0>
		<cfset refPageName = #left(refPage,extPlace - 1)#>
	</cfif>
	
	<cfset caller.refPage = "#refPage#">
	<cfset caller.refPageName = "#refPageName#">

</cfoutput>
</cfsilent>

Open in new window

0
 
LVL 52

Expert Comment

by:_agx_
ID: 36588949
Might just be a server version. Can you dump that variable in CF7? See what it says.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Tpaul_10
ID: 36589285
#server.servervars.Environment# says Dev, QA and Production. I am trying to find out where these are set and I think it is going to be a problem if I set this variable to a default value (or I need to have a three different versions of my file). So, what are your thoughs?

Thanks
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36589397
Oh... weird. So they were storing the machine version (Dev, QA, prodcution) in the registry? Then you could just replace the old "Allaire" path with a valid registry path for CF9.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 36589414
I'm not near a CF9 install, but the client variable docs suggest the path was changed from "Allaire" to "Macromedia". So I think you can just add the environment and SSL port keys here:

      HKEY_LOCAL_MACHINE\Software\Macromedia\ColdFusion\Web_Server

Then change your cfregistry code to use that path instead.


0
 
LVL 52

Expert Comment

by:_agx_
ID: 36589421
Keep in mind you'll have to do a one-time add of the keys on each machine first.

0
 

Author Comment

by:Tpaul_10
ID: 36589884

>>>>>> "So I think you can just add the environment and SSL port keys here"  HKEY_LOCAL_MACHINE\Software\Macromedia\ColdFusion\Web_Server

How to add this? and I have tried to run this path and says windows can't find it.
Please let me know if there is document or steps to follow.

Thanks






0
 

Author Comment

by:Tpaul_10
ID: 36590516
I have got this working and sincere THANKS for directing me in the right way to fix the problem.
It was very very great help and appreciate your patience and the way you responded. You rock.

Here is what I did. I have created the same path "HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\Web_Server " on the registry and added the variables I wanted with their values.

THANKS again and have a good weekend.


0
 

Author Closing Comment

by:Tpaul_10
ID: 36590519
AGX Help was great and directed me what exactly I needed to do to resolve the issue.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36590684
Sorry for the delayed response. I got tied up with work.  Anyway, Glad to hear it's resolved. Now you can enjoy your weekend :)
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question