Highlighted

Calling a CFC from JAVA

New Here ,
Aug 02, 2018

Copy link to clipboard

Copied

Hi

I'm trying to implement CFCProxy as per the following tutorial ColdFusion Help | Enhanced Java integration in ColdFusion.

It works if you call the JAVA from ColdFusion then call the CFC from JAVA but I would like to call the CFC straight from Java instead, is this possible?

When I try and it I get the following error:

runtime error. coldfusion.server.ServiceFactory$ServiceNotAvailableException: The Runtime service is not available. at coldfusion.server.ServiceFactory.getRuntimeService(ServiceFactory.java:117) at coldfusion.cfc.CFCProxy.<init>(CFCProxy.java:119) at coldfusion.cfc.CFCProxy.<init>(CFCProxy.java:73)

Thanks for your help!

Views

250

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Calling a CFC from JAVA

New Here ,
Aug 02, 2018

Copy link to clipboard

Copied

Hi

I'm trying to implement CFCProxy as per the following tutorial ColdFusion Help | Enhanced Java integration in ColdFusion.

It works if you call the JAVA from ColdFusion then call the CFC from JAVA but I would like to call the CFC straight from Java instead, is this possible?

When I try and it I get the following error:

runtime error. coldfusion.server.ServiceFactory$ServiceNotAvailableException: The Runtime service is not available. at coldfusion.server.ServiceFactory.getRuntimeService(ServiceFactory.java:117) at coldfusion.cfc.CFCProxy.<init>(CFCProxy.java:119) at coldfusion.cfc.CFCProxy.<init>(CFCProxy.java:73)

Thanks for your help!

Views

251

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 02, 2018 0
Adobe Community Professional ,
Aug 03, 2018

Copy link to clipboard

Copied

Hi, Ben. That CFCProxy is indeed designed only to be used when calling a CFC from within the CF address space itself, thus the need (typically) to be running the Java code via a call from within CF. As it says, “To call CFC, ColdFusion class loader must be the current class loader.” And as it notes you need to import coldfusion.cfc.CFCProxy, which requires compiling the java code with reference to the cfusion.jar which has the needed classes in the coldfusion.cfc package (more on that in a moment).

But it sounds like you are saying you want to access the CFC “from outside of CF”, right? Well, you could call it then via either REST or web services. Each does require you to modify the CFC to be able to expose itself to “remote” users, but it’s eminently doable. And there is then provision for that CFC to return generic objects that any outside caller could access (whether json or simple or complex objects).

Might that be the better solution for you? There is ample documentation (from Adobe and in blog posts and articles elsewhere) about calling CFCs via REST or web services.

As for the CFCProxy, besides that rather brief doc on the topic, I’ll note that I did the chapter in the CF 10 “Web Application Construction Kit” which focused on the new things about Java integration in CF10, including the new directinvoke method for it. But I also introduced both the broader concept of using CFCProxy—and lots of pros and cons, and I showed actually creating and compiling Java code to use it. I Realize you may not need that info, but I offer it for future readers. I also discuss other new aspects CF10 had added like the related createdynamicproxy, also discussed on that doc page, and the new application-specific classloader, and more.

If you may decide you DO want to use those more direct forms of integration, you can find that 5-year old book for still for sale online. I’m not aware that the whole book was ever posted online, but I am finding that you can see the chapter in google books, with the cfcproxy discussion starting at https://books.google.com/books?id=zZKlM7rYYz8C&pg=PT274.

Let us know how things work out for you.

/charlie

/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2018 0
New Here ,
Aug 06, 2018

Copy link to clipboard

Copied

Hi Charlie

Thanks for the lengthy response!

CFCProxy makes sense, it works fine when invoking from CF but like you say it doesn't work in isolation when calling it directly from JAVA.

Our ideal solution would be: our JAVA code could call our CF code when it's run on the same JVM but the code isn't always instantiated or called from CF in the first place.

I had the REST web service route down as the last option as it will mean creating that but, it seems that it's the way to go. I just wanted a sanity check to make sure what I was doing was 1. Correct and 2. Actually possible.

Thanks for your help!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 06, 2018 0