Link to home
Start Free TrialLog in
Avatar of Panos
PanosFlag for Germany

asked on

Error - Element OBJCATEGORIES is undefined in a Java object of type class [Ljava.lang.String;.

Hello experts.
I get sometimes the following error:
Element OBJCATEGORIES is undefined in a Java object of type class [Ljava.lang.String;.
After reloading the page the error disappears.
I have in my application.cfc :
<cfset application.objcategories = CreateObject("component", "com.getcategories").init("intech")>

In my cfm page:
<cfset qryMainCategories = application.objcategories.fqrycategories(uselanguage = request.myLanguage,subcategoryof = 0)>

More information:
In the debug - info i get also:
Called from ..........Application.cfc: line 203
Line 203 is:
<cffunction name="onRequest" returnType="void">
      <cfargument name="targetPage" type="String" required=true/>
     <!---203---> <cfinclude template="#Arguments.targetPage#">
   </cffunction>
Any help?
Avatar of Coast Line
Coast Line
Flag of Canada image

when u initially load your page
 
create a dump for the application vars

and see what u get then
Avatar of Panos

ASKER

Here what i get
test.jpg
I have in my application.cfc :
<cfset application.objcategories = CreateObject("component", "com.getcategories").init("intech")>


where in your application.cfc is this line?  Which method?

Best practices:

 You want to put it in it's own function called LoadMethods()

Then call load methods from onApplicationStart()
But for debugging, call the method also from onRequestStart() until it goes into production
Avatar of Panos

ASKER

Hi gdemaria
The createobject is in the onApplicationStart function.
Can you please explain the ...Best practices ... with an example?
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Panos

ASKER

Ok.
I created this in Application.cfc:
<cffunction name="loadComponents" output="false">
     <cfset application.objcategories = CreateObject("component", "com.getcategories").init("intech")>
   </cffunction>
and put
<cfset loadComponents()>
onApplicationStart() method AND your onRequestStart method
perfect !

When you go into production you can remove it from onRequestStart, or as some people do, create a flag so you can automatically reload the components whenever you need to... like this...

<cfif isDefined("url.appreload"0 and url.appreload is 1>
   <cfset loadComponents()>
</cfif>

that way, if you add &appreload=1  to any URL on your site and load the page (one time) it will reload the components for you..
Avatar of Panos

ASKER

gdemaria
1. This way i 'm calling twice the same createobject. One onApplicationStart and one calling the  LoadMethods()  function from the onapplicationstart .
Is this OK?

2. I will check  if the error remains when i remove the createobject from the onrequeststart function
> This way i 'm calling twice the same createobject. One onApplicationStart and one calling the  LoadMethods()  function from the onapplicationstart .  Is this OK?

Well, you're only calling it twice in one instance (for one user's request) every 4 hours (assuming your app timeout is 4 hours)

And it is Ok, even if more often because you're simply writing over the variable with the same thing again, no big deal.

>  I will check  if the error remains when i remove the createobject from the onrequeststart function

Provided of course that you have restarted your application or your application has timed out already.   I suggest instead of removing it that you wrap it in the <cfif> statement as showed so you can reload it on demand.
Avatar of Panos

ASKER

I have in my onRequestStart allready this:
<cfif structKeyExists(url, "reinit")>
         <cfset onApplicationStart()>
        </cfif>
It is like your code but i'm calling the onApplicationStart() .
If i will use
<cfif isDefined("url.appreload"0 and url.appreload is 1>
   <cfset loadComponents()>
</cfif>

i must remove - copy (?) all the createobjects from the onapplicationstart to the loadComponents function.

Your opinion?
Avatar of Panos

ASKER

Hi gdemaria
Can you please post your opinion about my last post ?
Avatar of Panos

ASKER

Thank you for your help.
regards panos