title: ColdFusion Class definition error
body: <p>I have the following Applicaton.cfc</p>
  
  <pre><code>&lt;cffunction name="onApplicationStart" access="public" returntype="Object"&gt;
   &lt;cfset application.dsn = "myDB" /&gt;
   &lt;cfset application.userGateway = createObject("component","cfc.UserGateway").init(dsn = application.dsn) /&gt;
   &lt;cfreturn this /&gt;
  &lt;/cffunction&gt;
  </code></pre>
  
  <p>This is my component UserGateway.cfc</p>
  
  <pre><code>&lt;cfcomponent name="UserGateway" hint="Data Access Object" output="false"&gt;
   &lt;cffunction name="init" access="public" hint="constructor" output="false" returntype="UserGateway"&gt;
    &lt;cfargument name="dsn" type="string" required="true" hint="datasource" /&gt;
     &lt;cfset variables.dsn = arguments.dsn /&gt;
   &lt;cfreturn this /&gt;
   &lt;/cffunction&gt;
  
   &lt;cffunction name="getUsers" access="public" output="false" returntype="query"&gt;
    &lt;cfargument name="id" type="String" default="" /&gt;
    &lt;cfargument name="name" type="String" default="" /&gt;
    &lt;cfargument name="district" type="String" default="" /&gt;
    &lt;cfset var qQuery = "" /&gt;
    &lt;cfquery name="qQuery" datasource="#variables.dsn#"&gt;
      SELECT *
      FROM A INNER JOIN B
      ON A.X = B.Y
      WHERE 0=0
      &lt;cfif "#arguments.id#" neq ""&gt;
       AND B.X LIKE '%#arguments.id#%'
      &lt;/cfif&gt;
      &lt;cfif "#arguments.name#" neq ""&gt;
       AND (A.I LIKE '#arguments.name#%'
        OR A.J LIKE '#arguments.name#%')
      &lt;/cfif&gt;
      &lt;cfif "#arguments.district#" neq ""&gt;
       AND A.O LIKE '%#arguments.district#%'
      &lt;/cfif&gt;
    &lt;/cfquery&gt;
    &lt;cfreturn qQuery /&gt;
   &lt;/cffunction&gt;
  &lt;/cfcomponent&gt;
  </code></pre>
  
  <p>And this is my same.cfm</p>
  
  <pre><code>&lt;cfform action="same.cfm" method="post" preservedata="true"&gt;
   &lt;p&gt;ID: &lt;cfinput type="text" name="id" size="20" maxlength="4" /&gt;&lt;/p&gt;
   &lt;p&gt;Name: &lt;cfinput type="text" name="name" size="20" maxlength="64" /&gt;&lt;/p&gt;
   &lt;p&gt;District: &lt;cfinput type="text" name="district" size="20" maxlength="3" /&gt;&lt;/p&gt;
   &lt;p&gt;&lt;cfinput class="button" type="submit" name="submit" value="OK" /&gt;&lt;/p&gt;
  &lt;/cfform&gt;
  
  &lt;cfif IsDefined("form.submit")&gt;
   &lt;table&gt;
    &lt;cfset qQuery = application.userGateway.getUsers(id = form.id, name = form.name, district = form.district) /&gt;
    &lt;cfoutput query="qQuery"&gt;
     &lt;tr&gt;
      &lt;td&gt;#qQuery.currentRow#.&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;#qQuery.I#&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;#qQuery.M#, #qQuery.N#&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;#qQuery.D#&lt;/a&gt;&lt;/td&gt;
     &lt;/tr&gt;
    &lt;/cfoutput&gt;
   &lt;/table&gt;
  &lt;/cfif&gt;
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Element USERGATEWAY is undefined in a Java object of type class [Ljava.lang.String;.
  The error occurred in same.cfm: line 10
  </code></pre>
  
  <p>What am i missing?</p>
  
  <pre><code>-------------------------------------------
  -------------------------------------------
  </code></pre>
  
  <p>When i do it this way it works. it must be something trivial that i as a beginner do not get.</p>
  
  <p>Application.cfc</p>
  
  <pre><code>&lt;cffunction name="onRequestStart" access="public" returntype="String"&gt;
   &lt;cfset request.dsn="myDB" /&gt;
  &lt;/cffunction&gt;
  </code></pre>
  
  <p>same.cfm</p>
  
  <pre><code>    &lt;cfset userGateway = createObject("component","cfc.UserGateway").init(dsn = request.dsn) /&gt;
      &lt;cfset qGetUser = userGateway.getUsers(id = form.personid, name = form.name, district = form.district) /&gt;
    &lt;cfoutput query="qQuery"&gt;
     &lt;tr&gt;
      &lt;td&gt;#qQuery.currentRow#.&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;#qQuery.I#&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;#qQuery.M#, #qQuery.N#&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;#qQuery.D#&lt;/a&gt;&lt;/td&gt;
     &lt;/tr&gt;
    &lt;/cfoutput&gt;
  </code></pre>