Skip to main content
Known Participant
September 9, 2008
Question

Random error CFC - Element is undefined

  • September 9, 2008
  • 8 replies
  • 1189 views
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!!!
    This topic has been closed for replies.

    8 replies

    Inspiring
    September 10, 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/
    germAuthor
    Known Participant
    September 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!
    germAuthor
    Known Participant
    September 9, 2008
    So far so good, haven't had an error message since...! Thank you so much guys!!! You're life savers!!!
    germAuthor
    Known Participant
    September 9, 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!!!
    Inspiring
    September 9, 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"...>
    germAuthor
    Known Participant
    September 9, 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).
    germAuthor
    Known Participant
    September 9, 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!!
    Inspiring
    September 9, 2008
    Are all your function-local variables VARed?

    It might help if you post the CFC code.

    --
    Adam
    germAuthor
    Known Participant
    September 9, 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!!!
    germAuthor
    Known Participant
    September 9, 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!