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

Panos
Panos used Ask the Experts™
on
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?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
when u initially load your page
 
create a dump for the application vars

and see what u get then

Author

Commented:
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
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Author

Commented:
Hi gdemaria
The createobject is in the onApplicationStart function.
Can you please explain the ...Best practices ... with an example?
If you have it in your onApplicationStart function then it will only get updated when the application restarted... that would happen at the time your application timeout period is up.   A typically application timeout may be 1/2 day or a full day..

That means if you make a change to the cfc, it will not take effect in your code for some hours (depending on the timeout).

To get around this, you create a function and put the createObject line in that function.  Simply call the function in your onApplicationStart() method AND your onRequestStart method.


  <cfset loadComponents()>

Author

Commented:
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..

Author

Commented:
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.

Author

Commented:
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?

Author

Commented:
Hi gdemaria
Can you please post your opinion about my last post ?

Author

Commented:
Thank you for your help.
regards panos

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial