This <cfobject action="create" type="java" class="IceKey" name="myObj" /> <cfset ret=myObj.init() /> <cfdump var="#myObj#" />
Gives this Error Occurred While Processing Request Unable to find a constructor for class IceKey that accepts parameters of type ( ). The error occurred in D:\Tools\Web\test.cfm: line 2 1 : <cfobject action="create" type="java" class="IceKey" name="myObj" /> 2 : <cfset ret=myObj.init() /> 3 : <cfdump var="#me#" /> Regards Dale Fraser > -----Original Message----- > From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of Mark Mandel > Sent: Tuesday, 21 March 2006 13:42 PM > To: cfaussie@googlegroups.com > Subject: [cfaussie] Re: Call Java Class (Java Code Attached) > > To copy paste out of the coldfusion documentation: > > http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common > /html/wwhelp.htm?context=ColdFusion_Documentation&file=part_dev.htm > > > > Invoking objects > > The cfobject tag makes Java objects available in ColdFusion MX. It > can access any Java class that is available on the JVM classpath or in > either of the following locations: > > * In a Java archive (.jar) file in web_root/WEB-INF/lib > * In a class (.class) file in web_root/WEB-INF/classes > > For example: > > <cfobject type="Java" class="MyClass" name="myObj"> > > Although the cfobject > <http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000302.htm#2820239 > > tag loads the class, it does not create an instance object. Only static > methods and fields are accessible immediately after the call to cfobject. > > If you call a public non-static method on the object without first > calling the init method, there ColdFusion makes an implicit call to the > default constructor. > > To call an object constructor explicitly, use the special ColdFusion > init method with the appropriate arguments after you use the cfobject tag; > for example: > > <cfobject type="Java" class="MyClass" name="myObj"> > <cfset ret=myObj.init(arg1, arg2)> > > Note: The init method is not a method of the object, but a > ColdFusion identifier that calls the new function on the class constructor. > So, if a Java object has an init method, a name conflict exists and you > cannot call the object's init method. > > To have persistent access to an object, you must use the init > function, because it returns a reference to an instance of the object, and > cfobject does not. > > An object created using cfobject or returned by other objects is > implicitly released at the end of the ColdFusion page execution. > > > Btw - you may want to brush up on your OO vocabulary. I think you meant > to say you could 'not find a init method in this class' or something to > that effect. > > Mark > > > > On 3/21/06, Dale Fraser <[EMAIL PROTECTED]> wrote: > > > Hey, > > I'm no Java guru, but I don't see a constructor class or init method > in this > function. > > Regards > Dale Fraser > > > > -----Original Message----- > > From: cfaussie@googlegroups.com <mailto:cfaussie@googlegroups.com> > [mailto:[EMAIL PROTECTED] On > > Behalf Of Mark Mandel > > Sent: Tuesday, 21 March 2006 13:02 PM > > To: cfaussie@googlegroups.com <mailto:cfaussie@googlegroups.com> > > Subject: [cfaussie] Re: Call Java Class (Java Code Attached) > > > > Actually - what just popped into my head - > > > > Try this - > > > > <cfscript> > > myObj = createObject("java", "IceKey").init(); > > </cfscript> > > > > I have found on occasion you actually need to explicitly call the > default > > constructor on the Java object, otherwise you get weirdness. > > > > I'm not really sure why it is, I have a feeling it may have > something to > > do with static attributes - therefore I tend to call init() on all > > constructors by default. > > > > Try that, and see if that works. > > > > Mark > > > > > > > > > > -- > E: [EMAIL PROTECTED] > W: www.compoundtheory.com > ICQ: 3094740 > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie -~----------~----~----~----~------~----~------~--~---