Link to home
Start Free TrialLog in
Avatar of Tpaul_10
Tpaul_10Flag for United States of America

asked on

CF 9.0 upgrade issue

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

Avatar of _agx_
_agx_
Flag of United States of America image


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




Avatar of Tpaul_10

ASKER

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

Might just be a server version. Can you dump that variable in CF7? See what it says.
#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
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.
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Keep in mind you'll have to do a one-time add of the keys on each machine first.


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






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.


AGX Help was great and directed me what exactly I needed to do to resolve the issue.
Sorry for the delayed response. I got tied up with work.  Anyway, Glad to hear it's resolved. Now you can enjoy your weekend :)