Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Random error CFC - Element is undefined

New Here ,
Sep 09, 2008 Sep 09, 2008
Hi everyone, hope someone out there can help because this error is driving me nuts! At random intervals, I keep getting the same error. It says either :

Element MYFIELD is undefined in MYQUERY
or
Variable MYVARIABLE is undefined
or
Element MYFIELD is undefined in a Java object of type class [Ljava.lang.String;.

The thing is, that if I just refresh the page, the error goes away. The error seems to appear on every page of the site, not just in a specific section of code. All my CFCs are declared as Application variables in Application.cfc and, as far as I've noticed, I always use CFLOCK to access my CFC objects. I've read that this problem can occur when "Maintain database client connexions" is checked in the CF Admin, which it was, but not anymore (and I restarted the CF Application service).

Anyone have any idea what's causing this error? Thanks!!!
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2008 Sep 09, 2008
Forgot to give some additional info. Basically we're running CF8 on Windows 2000 server and using a SQL Server Express database. Hope this helps!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 09, 2008 Sep 09, 2008
Are all your function-local variables VARed?

It might help if you post the CFC code.

--
Adam
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2008 Sep 09, 2008
ok you'll find a tiny part of my code (I actually have maybe 20 cfc with over a thousand lines of code in each so I can't really put everything here). I also included different ways I'm accessing this CFC. See anything wrong? Thanks for your help!!!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 09, 2008 Sep 09, 2008
So woudl this line:

> #TrouverEtablissement.noEtablissement[1]#

Be an example of where you'ge the an error to the effect of;

Element noEtablissement is undefined in TrouverEtablissement?

Is noEtablissement a column in the Etablissements table? I don't see it
cited in your SELECT statement, so presume it is..?

You're not VARing your query object:

<CFQUERY NAME="TrouverDonnees" DATASOURCE="#ARGUMENTS.datasource#">

On the basis of what you've posted, I can't see that being the cause, but I
am also guessing you've not posted the entire CFC.

If you ever use another unVARed variable "TrouverDonnees" in that CFC
instance, you'll have problems. Basically you MUST always VAR your local
variables in your CFCs, if you're re-using the CFC instance at all. It'sd
a recipe for disaster not to.

Go VAR all your local variables in all your CFCs, retest, and report back.

As a side note, I find your DB naming convention to be quite clunky, having
the table name in all the column names (esp given the table names
themselves are quite long). I'd also recommend aliasing your tables in
your queries if you've got such long names. That source code is really
quite difficult to read as it is. Neither of these points have anything to
do with your issue though (other than making it more difficult to easily
spot wheat amongst the chaff).

--
Adam
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2008 Sep 09, 2008
Hi Adam, thanks for your response but how exactly can I var a Query? I do often use "TrouverDonnees" as a query name so if you think that can cause a problem, maybe you're on to something. If there's a way of VARing my queries, can you show me an example?

Thanks!!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2008 Sep 09, 2008
Forgot to mention, yes noEtablissement is a field that's in my Etablissements table. For my CFC, no I did not post it all (just that CFC has 1995 lines of code). I just posted the relevant information for this post (basically, the simplest function that I know already generated an error).
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 09, 2008 Sep 09, 2008
germ wrote:
> Hi Adam, thanks for your response but how exactly can I var a Query? I do often
> use "TrouverDonnees" as a query name so if you think that can cause a problem,
> maybe you're on to something. If there's a way of VARing my queries, can you
> show me an example?
>
> Thanks!!
>

You var the variable in an intilization line, then use it in the query.

<cffunction....>
...
<cfset var TrouverDonnees = "">
...
<cfquery name="TrouverDonnees"...>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2008 Sep 09, 2008
I'll try it right away! I honestly never thought I could VAR my queries. In all my years of developping CF Apps, I never did that. If that solves my problem I'll owe you guys!!!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2008 Sep 09, 2008
So far so good, haven't had an error message since...! Thank you so much guys!!! You're life savers!!!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 09, 2008 Sep 09, 2008
just a suggestion, which may make it easier for you to VAR your cfc
variables in the future:

in each and every cfc function declare <cfset var LOCAL = structnew()>
at the top of the function, after any <cfargument ...> declarations

then assign any variable you use or create in the cfc to this LOCAL
structure, inline, like:

<cfquery name="LOCAL.TrouverDonnees" ...>

that way you do not have to declare <cfset var myvar = whatever> in the
beginning of your function for each and every variable.
just remember to use LOCAL.myvar instead of myvar.

hth

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2008 Sep 11, 2008
Thanks for the tip! I've changed everything and now it works perfectly! Also, if ever someone else has this problem, I don't seem able to use LOCAL.queryName when doing Queries of Queries. So I had to declare them as var individually at the top. I also needed to do the same when using CFREPORT. Just in case someone else has this problem, hope this info can help!

Again, thanks everyone for your help! It's really appreciated!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 11, 2008 Sep 11, 2008
LATEST
did you try using associative array notation in QoQ/cfreport?

LOCAL['queryname'] is same as LOCAL.queryname

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources