3 Replies Latest reply on Oct 18, 2007 10:45 AM by Dinghus

    Instantiating CFC as application variable

    Dinghus Level 1
      I have a CFC (obviously) that works fine if I instantiate it during onRequest. But since everyone uses it a lot, I thought it would be better to have it as an APPLICATION.CFC instead.

      However now I get the error
      Element USER is undefined in a Java object of type class [Ljava.lang.String; referenced as

      This happens with this code :
        • 1. Re: Instantiating CFC as application variable
          Stressed_Simon Level 1
          If you have added the object instantiation to OnApplicationStart() to an already running application then it will not exist in the application scope until the application is restarted. You can call OnApplicationStart() programatically from within your Application.cfc or you can just restart coldfusion.
          • 2. Re: Instantiating CFC as application variable
            Level 7
            > However now I get the error
            > Element USER is undefined in a Java object of type class [Ljava.lang.String;
            > referenced as

            > application.user.authenticate(email='#form.email#',password='#form.password#');

            Can you post the code that creates application.user?

            --
            Adam
            • 3. Re: Instantiating CFC as application variable
              Dinghus Level 1
              Thanx Stressed. You hit me with a "DOH!" moment. lol
              I have a "reinit" in my application.cfc file which does exactly what you said about calling the onApplicationStart(). BUT I decided to check it again and make sure it was okay and what to my amazement should I find? Some evil code demon had put it INSIDE the onApplicationStart function.

              So, moving it outside of the function where it should be, it now works fine.

              *banging head against wall*