Avatar of Panos
Panos
Flag 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?
ColdFusion Language

Avatar of undefined
Last Comment
Panos

8/22/2022 - Mon
Coast Line

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

and see what u get then
Panos

ASKER
Here what i get
test.jpg
gdemaria

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
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Panos

ASKER
Hi gdemaria
The createobject is in the onApplicationStart function.
Can you please explain the ...Best practices ... with an example?
ASKER CERTIFIED SOLUTION
gdemaria

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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
gdemaria

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..
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
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
gdemaria

> 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.
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?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Panos

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

ASKER
Thank you for your help.
regards panos