8 thoughts

  1. The docs say that the CF Classloader has to be the current classloader for any class making use of a CFCProxy. Does this mean that only java classes called by ColdFusion can use CFCProxy or that a non-ColdFusion app can use CFCProxy in some way?
    I’m sure that this is totally clear to a J2EE person, but the question of how to get a class to be part of the ColdFusion context without being inside ColdFusion is one that has to be asked.

  2. Ben,
    The application scope does not seem to be accessible from a CFC created via CFCProxy.
    My methods work fine when I create the CFC from ColdFusion but as soon as I create it from Java using CFCProxy I get errors because variables don’t exist in the application scope.
    Is this intended behaviour?
    George.

  3. CFCproxy in Coldfusion 9
    First I received this error:Caused by: java.lang.NoClassDefFoundError: coldfusion/cfc/CFCProxy, Caused by: java.lang.ClassNotFoundException: coldfusion.cfc.CFCProxy
    Now I received this error: instantiation exception.An exception occurred while instantiating a Java object. The class must not be an interface or an abstract class. Error: coldfusion/cfc/CFCProxy…
    ————————
    test.cfm:
    ————————
    <cfset invkJAVA = createObject("java","Coldfusion2").init()>
    <cfset LvarArgs = structNew()>
    <cfset LvarArgs.dato = "hello">
    <cfset x = invkJAVA.jCFCinvoker(‘TestColdfusion’,’ping’,LvarArgs)>
    ————————
    Coldfusion2.java:
    ————————
    import coldfusion.cfc.CFCProxy;
    import java.util.Map;
    public class Coldfusion2
    {
    public java.util.Map jCFCinvoker(String cfc, String fn, java.util.Map args)
    throws Throwable
    {
    Map map = null;
    try{
    CFCProxy myCFC;
    myCFC = new CFCProxy ("C:\ColdFusion9\wwwroot\TestColdfusion.cfc");
    Object[] myArgs = {cfc, fn, args};
    map = (java.util.Map) myCFC.invoke("rmiCFCinvoker", myArgs);
    }catch (Throwable e){
    System.out.println("exception: " + e.getMessage());
    e.printStackTrace();
    }
    return map;
    }
    }
    ————————
    TestColdfusion.cfc
    ————————
    <cffunction name="ping" returntype="string" output="no">
    <cfargument name="dato" required="yes" type="string">
    <cfreturn dato>
    </cffunction>
    <cffunction name="rmiCFCinvoker" returntype="any" output="no">
    <cfargument name="cfc" required="yes">
    <cfargument name="fn" required="yes">
    <cfargument name="args" required="yes" type="struct">
    <cfset LvarResult = structNew()>
    <cfset LvarResult.Error = "">
    <cftry>
    <cfinvoke component ="#Arguments.cfc#"
    method ="#Arguments.fn#"
    returnvariable="LvarRes"
    >
    <cfloop collection="#Arguments.args#" item="arg">
    <cfinvokeargument name="#arg#" value="#Arguments.args[arg]#">
    </cfloop>
    </cfinvoke>
    <cfif isdefined("LvarRes")>
    <cfset LvarResult.Result = LvarRes>
    </cfif>
    <cfcatch type="any">
    <cfset LvarResult.Error = cfcatch.Message & " " & cfcatch.Detail>
    </cfcatch>
    </cftry>
    <cfreturn LvarResult>
    </cffunction>
    ——————————————-

  4. Ozkar, did you ever resolve your problem? I can report that both errors have the same underlying cause: if you comment out the lines:
    myCFC = new CFCProxy ("C:\ColdFusion9\wwwroot\TestColdfusion.cfc");
    and
    map = (java.util.Map) myCFC.invoke("rmiCFCinvoker", myArgs);
    (and recompile Coldfusion2 and restart CF), you won’t get the errors when invoking the class from within CF, but of course the question it begs is why the CFCProxy is considered notfound. I’m experiencing the same thing in CF8 (so it’s not a CF9 thing). I can confirm (for those who would wonder) that I am on the Enterprise edition, not Standard. the CFCProxy is inside the cfusion.jar, which is already in the classpath for CF. Very curious.

Leave a Reply