Ajas, it seems your use of the init is fine. It's just that if you want to call the constructor, you have to use init (and you can't have a real method of that name within the java class). You pass whatever arguments you want to call the appropriate constructor, and it should just work (whether you use CFOBJECT or createobject to create the instance). It's just that if you do NOT use init, then CF will otherwise call the default constructor when the first method is executed (which may seem odd, if one thinks that it's CFOBJECT or createobject that "actually creates the instance".)
As for your challenge, I wonder if there's more info available from the error than you're showing (or being given). Is this error message coming from error handling (cftry, cferror, onerror, etc)? If so, are you outputting all the available details? There are all kinds of things that could cause an "Object Instantiation Exception". For instance, if you named a class that didn't exist, you would get this: "An exception occurred when instantiating a Java object. The class must not be an interface or an abstract class." I'll add that if you gave an invalid argument type for the constructor, that would get a different error, as would passing in arguments that don't match any constructor. If anyone ever wants to learn more about calling Java within CFML (which was in fact the first talk I ever gave to the ACFUG, back in Oct 2001), you can find more in the CF docs (I nthe Developer's Guide), such as the section starting here in the CF8 docs: http://livedocs.adobe.com/coldfusion/8/htmldocs/Java_7.html Ajas, let us know if any of the above helps. /charlie From: ad...@acfug.org [mailto:ad...@acfug.org] On Behalf Of Ajas Mohammed Sent: Monday, April 13, 2009 2:46 PM To: discussion@acfug.org Subject: [ACFUG Discuss] CF 7 java Object Instantiation Exception. Perhaps init issue here? Hi there, I am getting an error(code in red) Object Instantiation Exception. I believe it has to do with init call because i remember CF's init is different from Java's style of callling constructors. Can anybody recommend an alternative ? FYI, if i remove code in red till the end and I do print values of other variables like docElement and SignatureSpecNS, then I can see there values. If you need any further information, let me know. <cfscript> xmlResponse= tokenXML; // this is full xml stored in variable here docElement= XmlParse(variables.xmlResponse).getDocumentElement(); SignatureConstants=CreateObject("Java", "org.apache.xml.security.utils.Constants"); SignatureSpecNS=SignatureConstants.SignatureSpecNS; xmlSignatureClass = CreateObject("Java","org.apache.xml.security.signature.XMLSignature"); xmlSignature = xmlSignatureClass.init(docElement.getElementsByTagNameNS(SignatureSpecNS,"Si gnature").item(0),""); // this lines gives error. see details below //Exceptions 13:00:53.053 - Object Exception - in **** line 85 Object Instantiation Exception. keyInfo=xmlSignature.getKeyInfo(); X509CertificateResolverCN = CreateObject("Java","org.apache.xml.security.keys.keyresolver.implementation s.X509CertificateResolverClass"); keyResolver=CreateObject("Java",X509CertificateResolverCN).init(); keyInfo.registerInternalKeyResolver(keyResolver); x509cert = keyInfo.getX509Certificate(); </cfscript> Thanks <Ajas Mohammed /> http://ajashadi.blogspot.com We cannot become what we need to be, remaining what we are. No matter what, find a way. Because thats what winners do. You can't improve what you don't measure. Quality is never an accident; it is always the result of high intention, sincere effort, intelligent direction and skillful execution; it represents the wise choice of many alternatives. ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/ List hosted by http://www.fusionlink.com -------------------------------------------------------------