[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

CF 9.0 upgrade issue

Posted on 2011-09-23
11
Medium Priority
?
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

656 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