Variable that doesn't exist in cfc

			<cfinvoke component="Character" method="GetCharacterEncumbrance" returnvariable="EncumbranceLevel">
				<cfinvokeargument name="CharacterID" value="#LocationID#">
				<cfinvokeargument name="AdditionalWeight" value="#Check.Weight#">
			</cfinvoke>

I confirmed LocationID and Check.Weight is set correctly. But when I run it in this CFC…

<cffunction name="GetCharacterEncumbrance" hint="Returns Encumbrance of the Character" returntype="String">
	<cfargument name="CharacterID" Required=True>
	<cfargument name="AdditionalWeight" Required=False default="0">
	<cfset Encumbrance = 0>
	<cfset LEVEL = 0>


	<cfquery name="CharacterInfo">
		Select	Characters.ST + IFNULL((Select Sum(ST) as total from Character_Drugs where CharacterID = #CharacterID# and Active = 1),0) as ST
				, HP
				, PlanetID
		From 	Characters
		Where 	CharacterID = <cfqueryparam cfsqltype="cf_sql_integer" value="#CharacterID#">
	</cfquery>

	<cfquery name="CharacterWeight">
		Select 	IFNULL(Sum(Weight),0) as TotalWeight
		from 	Items_Active
		Where 	LocationID = #CharacterID#
		and		LocationType = 'Character'
	</cfquery>

	<cfset Weight = CharacterWeight.TotalWeight + AdditionalWeight>

It stops at the end with the error
Error: variable [LEVEL] doesn’t exist
Line: 647 (the last line shown).

I even put in a cfset at the top, but I still get it (I got it when it wasn’t there as well). I tried removing additionalweight and then it did the same thing on the same line.

I can’t even dump out the variables because it tells me level doesn’t exist.

Even when I did a , right above setting encumbrance, it STILL gives me the level error on that line.

Anyone see what is wrong here? I’m at wits end.

Are you sure that the error is for that file? There is no reference to LEVEL in the snippet that you posted other than the assignment at the top.

Yes. It gave the file and line number. I am positive.

When I run it without sending in the additionalweight variable, it works
fine. But once I put that in, I get that error.

As for no reference to level. I know. That’s the issue. In that cffunction,
there is no reference to level at all.

Can you post the whole function? And the full error message with the stack trace?

Be sure to remove any confidential information if there is any (e.g. usernames, passwords, etc.)



Select Characters.ST + IFNULL((Select Sum(ST) as total from Character_Drugs where CharacterID = #CharacterID# and Active = 1),0) as ST , HP , PlanetID From Characters Where CharacterID = Select IFNULL(Sum(Weight),0) as TotalWeight from Items_Active Where LocationID = #CharacterID# and LocationType = 'Character'

<cfset Weight = CharacterWeight.TotalWeight + AdditionalWeight>



<cfset FinalWeight = Weight * Gravity>

<cfif CharacterInfo.HP LT 1>

The stack trace gives the info shows before. Before this, it’s just a cfinvoke.

yeah we really need the stacktrace, the exception for sure not happen on the last line of the code posted, there is no “level” on that line …
What i see in your code that you have not properly scoped the variables defined inside the function (including the query objects) what easly could cause problems like this. There are 2 ways to solve this.

  1. do everywhere local. in front of the variable name
  2. set localmode=“true” attribute with cffunction

I will see about getting a copy of the error (it only happens in
production), but it is reporting that line.

When you say to use localmode, true isn’t an option (
<cffunction> :: Lucee Documentation). Did you mean modern?

Catch
Entries: 13
additional
Struct (ordered)
cause
Struct
additional
Struct (ordered)
Detail
string
ErrNumber
number 0
ErrorCode
string 0
Extended_Info
string
ExtendedInfo
string
Message
string variable [LEVEL] doesn’t exist
StackTrace
string lucee.runtime.exp.ExpressionException: variable [LEVEL] doesn’t
exist at
lucee.runtime.type.scope.UndefinedImpl.getCollection(UndefinedImpl.java:422)
at
__138.data.projectelpis.cfc.character_cfc$cf.udfCall1(…/Data/ProjectElpis/cfc/Character.cfc:648)
at
__138.data.projectelpis.cfc.character_cfc$cf.udfCall(…/Data/ProjectElpis/cfc/Character.cfc)
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at
lucee.runtime.type.UDFImpl._call(UDFImpl.java:338) at
lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:211) at
lucee.runtime.ComponentImpl._call(ComponentImpl.java:663) at
lucee.runtime.ComponentImpl._call(ComponentImpl.java:580) at
lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1931) at
lucee.runtime.tag.Invoke.doComponent(Invoke.java:221) at
lucee.runtime.tag.Invoke.doEndTag(Invoke.java:194) at
__138.data.projectelpis.cfc.inventory_cfc$cf.udfCall(…/Data/ProjectElpis/cfc/Inventory.cfc:436)
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at
lucee.runtime.type.UDFImpl._call(UDFImpl.java:338) at
lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:211) at
lucee.runtime.ComponentImpl._call(ComponentImpl.java:663) at
lucee.runtime.ComponentImpl._call(ComponentImpl.java:580) at
lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1931) at
lucee.runtime.tag.Invoke.doComponent(Invoke.java:221) at
lucee.runtime.tag.Invoke.doEndTag(Invoke.java:194) at
__138.data.projectelpis.circuits.business.chat.__138.__138.generaluse.act_take_cfm$cf.call(…/Data/ProjectElpis/Circuits/Business/Chat/…/…/GeneralUse/act_Take.cfm:7)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:893) at
lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:838) at
lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:822) at
__138.data.projectelpis.parsed.chat_take_cfm230$cf.call(…/Data/ProjectElpis/parsed/chat.take.cfm:68)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:893) at
lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:838) at
lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:822) at
__138.data.projectelpis.application_cfc$cf.udfCall1(…/Data/ProjectElpis/Application.cfc:228)
at
__138.data.projectelpis.application_cfc$cf.udfCall(…/Data/ProjectElpis/Application.cfc)
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at
lucee.runtime.type.UDFImpl._call(UDFImpl.java:338) at
lucee.runtime.type.UDFImpl.call(UDFImpl.java:225) at
lucee.runtime.ComponentImpl._call(ComponentImpl.java:662) at
lucee.runtime.ComponentImpl._call(ComponentImpl.java:580) at
lucee.runtime.ComponentImpl.call(ComponentImpl.java:1918) at
lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:755)
at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1697) at
__138.data.projectelpis.fusebox5_cfm$cf.call(…/Data/ProjectElpis/fusebox5.cfm:57)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:893) at
lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:838) at
lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:822) at
index_cfm$cf.call(/index.cfm:48) at
lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:893) at
lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:838) at
lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:822) at
application_cfc$cf.udfCall(/Application.cfc:131) at
lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at
lucee.runtime.type.UDFImpl._call(UDFImpl.java:338) at
lucee.runtime.type.UDFImpl.call(UDFImpl.java:225) at
lucee.runtime.ComponentImpl._call(ComponentImpl.java:662) at
lucee.runtime.ComponentImpl._call(ComponentImpl.java:580) at
lucee.runtime.ComponentImpl.call(ComponentImpl.java:1918) at
lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:422)
at
lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:224)
at
lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:43)
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2394) at
lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2385) at
lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2353) at
lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:917) at
lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:102)
at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:62) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
at
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
at
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
TagContext
Array
1
Struct
codePrintHTML
string 646: </cfquery>
647:
648: <cfset Weight =
CharacterWeight.TotalWeight + AdditionalWeight>

649:
650:
<cfinvoke component="Planets"
method="GetPlanetGravity"
returnvariable="Gravity">

codePrintPlain
string 646: 647: 648: <cfset Weight =
CharacterWeight.TotalWeight + AdditionalWeight> 649: 650:
column
number 0
id
string ??
line
number 648
Raw_Trace
string
__138.data.projectelpis.cfc.character_cfc$cf.udfCall1(…/Data/ProjectElpis/cfc/Character.cfc:648)
template
string
/opt/lucee/tomcat/webapps/ROOT/Ubersite/Data/ProjectElpis/cfc/Character.cfc
type
string cfml
2
Struct
codePrintHTML
string 434: <cfinvokeargument name="CharacterID"
value="#LocationID#">
435: <cfinvokeargument
name="AdditionalWeight" value="#Check.Weight#">

436: </cfinvoke>
437:
438: <cfif
ListGetAt(EncumbranceLevel, 3, ‘,’, ‘true’) EQ -1>

codePrintPlain
string 434: 435:
436:
437: 438: <cfif ListGetAt(EncumbranceLevel, 3, ‘,’, ‘true’) EQ
-1>
column
number 0
id
string ??
line
number 436
Raw_Trace
string
__138.data.projectelpis.cfc.inventory_cfc$cf.udfCall(…/Data/ProjectElpis/cfc/Inventory.cfc:436)
template
string
/opt/lucee/tomcat/webapps/ROOT/Ubersite/Data/ProjectElpis/cfc/Inventory.cfc
type
string cfml
3
Struct
codePrintHTML
string 5: <cfinvokeargument name="LocationID"
value="#Character.CharacterID#">
6: <cfinvokeargument
name="LocationType" value="Character">
7:
</cfinvoke>

8:
9: <cfoutput>

codePrintPlain
string 5: 6: 7: 8: 9:
column
number 0
id
string ??
line
number 7
Raw_Trace
string
__138.data.projectelpis.circuits.business.chat.__138.__138.generaluse.act_take_cfm$cf.call(…/Data/ProjectElpis/Circuits/Business/Chat/…/…/GeneralUse/act_Take.cfm:7)
template
string
/opt/lucee/tomcat/webapps/ROOT/Ubersite/Data/ProjectElpis/Circuits/GeneralUse/act_Take.cfm
type
string cfml
4
Struct
codePrintHTML
string 66:
<cfelse><cfrethrow></cfif></cfcatch></cftry>

67: <cftry>
68: <cfoutput><cfinclude
template="…/Circuits/Business/Chat/…/…/GeneralUse/act_Take.cfm"></cfoutput>


69: <cfcatch type="missingInclude"><cfif
len(cfcatch.MissingFileName) gte 29 and right(cfcatch.MissingFileName,29)
is "…/…/GeneralUse/act_Take.cfm">
70: <cfthrow
type="fusebox.missingFuse" message="missing Fuse"
detail="You tried to include a fuse …/…/GeneralUse/act_Take.cfm in
circuit Chat which does not exist (from fuseaction Chat.Take).">

codePrintPlain
string 66: 67: 68:

69: <cfif len(cfcatch.MissingFileName) gte
29 and right(cfcatch.MissingFileName,29) is
“…/…/GeneralUse/act_Take.cfm”> 70:
column
number 0
id
string ??
line
number 68
Raw_Trace
string
__138.data.projectelpis.parsed.chat_take_cfm230$cf.call(…/Data/ProjectElpis/parsed/chat.take.cfm:68)
template
string
/opt/lucee/tomcat/webapps/ROOT/Ubersite/Data/ProjectElpis/parsed/chat.take.cfm
type
string cfml
5
Struct
codePrintHTML
string 226: —>
227: <cflock
name="#_parsedFileData.lockName#" type="readonly"
timeout="30">
228: <cfinclude
template="#_parsedFileData.parsedFile#" />

229:
</cflock>
230: <cfcatch type="missinginclude">

codePrintPlain
string 226: —> 227: 228: 229: 230:
column
number 0
id
string ??
line
number 228
Raw_Trace
string
__138.data.projectelpis.application_cfc$cf.udfCall1(…/Data/ProjectElpis/Application.cfc:228)
template
string
/opt/lucee/tomcat/webapps/ROOT/Ubersite/Data/ProjectElpis/Application.cfc
type
string cfml
6
Struct
codePrintHTML
string 55: </cftry><cfprocessingdirective
suppresswhitespace="true">
56: <cftry>
57:
<cfset __fuseboxAppCfc.onRequest(CGI.SCRIPT_NAME) />

58:
<cfset __fuseboxAppCfc.onRequestEnd(CGI.SCRIPT_NAME) />
59:
<cfcatch type="any">

codePrintPlain
string 55: 56:
57: <cfset __fuseboxAppCfc.onRequest(CGI.SCRIPT_NAME) /> 58: <cfset
__fuseboxAppCfc.onRequestEnd(CGI.SCRIPT_NAME) /> 59:
column
number 0
id
string ??
line
number 57
Raw_Trace
string
__138.data.projectelpis.fusebox5_cfm$cf.call(…/Data/ProjectElpis/fusebox5.cfm:57)
template
string
/opt/lucee/tomcat/webapps/ROOT/Ubersite/Data/ProjectElpis/fusebox5.cfm
type
string cfml
7
Struct
codePrintHTML
string 46: <cfif This.Name contains ‘projectelpis’>
47: <cfset
FUSEBOX_APPLICATION_PATH = "…/Data/ProjectElpis/">
48:
<cfinclude template="#FUSEBOX_APPLICATION_PATH#/fusebox5.cfm"
/>

49: </cfif>
50:

codePrintPlain
string 46: <cfif This.Name contains ‘projectelpis’> 47: 48: 49: 50:
column
number 0
id
string ??
line
number 48
Raw_Trace
string index_cfm$cf.call(/index.cfm:48)
template
string /opt/lucee/tomcat/webapps/ROOT/Ubersite/wwwroot/index.cfm
type
string cfml
8
Struct
codePrintHTML
string 129:
130: <!— Include the requested page. —>

131: <cfinclude template="#ARGUMENTS.TargetPage#"
/>

132:
133: <!— Return out. —>

codePrintPlain
string 129: 130: <!— Include the requested page. —> 131: 132: 133: <!— Return out. —>
column
number 0
id
string ??
line
number 131
Raw_Trace
string application_cfc$cf.udfCall(/Application.cfc:131)
template
string /opt/lucee/tomcat/webapps/ROOT/Ubersite/wwwroot/Application.cfc
type
string cfml
type
string expression
Detail
string
ErrNumber
number 0
ErrorCode
string 0
Extended_Info
string
ExtendedInfo
string
Message
string variable [LEVEL] doesn’t exist
name
string onRequest

The odd thing is that I have the save version of Lucee 5.1.18 on my windows
system and my production which is Ubuntu. It works fine on windows, but not
on Ubuntu. I think this may be some kind of bug with Lucee itself.

modern is an alias for true, so either of those would work.

I’m guessing (because that’s all I can do with the little information that we have), that an older version of the script is cached on the server, and it references a missing variable named LEVEL.

Because of that “caching”, the error message is not in sync with the source snippet that you posted.

I thought that as well. I cleared the cache first thing and same issue.