Skip to main content
Participant
January 25, 2023
Question

Coldfusion 2021 and separate java server

  • January 25, 2023
  • 1 reply
  • 451 views

Hello all,

 

We recently upgraded from Coldfusion 9 to 2021.  Coldfusion 9 was using jrun as the java server, while 2021 uses Tomcat.

 

On 9, we had a separate server running some servlets we had written, and works just fine.  I can't figure out how to duplicate this feature in 2021.  

 

I created a separate instance, and placed the class files (after recompiling) into the classes directory, but it cannot find them.  I get a 404 error, with the message "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.".  I did create a simple .cfm page that works fine, but cannot call the class.  Is there a document or something that could point me in the right direction?  

 

In jrun, the main thing I had to do was add to the config was "<attribute name="url">file:<path_to_servlets></attribute>".  I don't see an equivalent in tomcat.

 

Any hints or tips?

This topic has been closed for replies.

1 reply

Charlie Arehart
Community Expert
Community Expert
January 25, 2023

Jim, note first that of course that's a HUGE jump, and especially the step from cf9 (which as you say was bundled with jrun) to cf2021, which like cf10 (from 2012) changed to Tomcat.

 

And besides CF changing, licensing changed.  So first, note that if you may be running CF Standard, that license does not allow running JSPs on CF (including in that Tomcat underlying CF). And I do think that would extend to servlets. But maybe not, or maybe you are on Enterprise (or the free Trial or Developer edition).

 

In that case, it may be that you are needing simply to get the servlets working within Tomcat (within CF). And for that, Adobe doesn't document the steps, but Tomcat does, incuding how and where to configure servlet mappings.  Note it's in the web.xml file, in the conf directory. In CF, that would be coldfusion2021/cfusion/runtime/conf. Of course, you will need to restart CF for it to pick up changes to that file.

 

Let us know if that gets you going. Or maybe someone will have a better answer for you.

/Charlie (troubleshooter, carehart. org)
Participant
January 30, 2023

Hello,

 

Yes, it is a big jump 🙂  I am using Developer right now, so it shouldn't be a problem with licensing.

 

I was a little surprised you mentioned "coldfusion2021/cfusion/runtime/conf".  I thought it would be "<second instance>/wwwroot/WEB-INF/web.xml".  For fun, I tried it in the conf folder as well, but it didn't change anything.  The config info I placed in both files is:

 

<servlet>
<servlet-name>putData</servlet-name>
<servlet-class>putData</servlet-class>
</sevlet>
<servlet-mapping>
<servlet-name>putData</servlet-name>
<url-pattern>putData</url-pattern>
</servlet-mapping>

 

I even tried putting the class files in "<second instance>/lib" to no avail.  Like I said, a .cfm file placed in "<second-instance>/wwwroot" works, so the .cfm stuff is working, just not the servlets.

 

Jim

Charlie Arehart
Community Expert
Community Expert
January 30, 2023

Jim, I have confirmed that yes, we CAN call a servlet within CF2021, in the Developer edition.

 

And yes, I can now clarify that it works REGARDLESS of whether the servlet xml config lines are put in the web.xml that is in the runtime/conf or the wwwroot/WEB-INF folder (within cfusion or whatever instance you may be running). Again, I'm saying I have just confirmed that it works in EITHER place. (To be clear, I had mentioned the runtime/conf location in my first reply simply because I was pointing you to the Tomcat docs for still MORE detail on how such things should be confugured.)

 

So the last point to be clarified is where the CLASS for the servlet (or a jar containing it) should be placed. For now, I only did a class, and I can confirm that it works if the class is put in the wwwroot\WEB-INF\classes folder under the instance/cfusion. I suspect a jar (holding servlet classes) would work if put in the sibling WEB-INF/lib folder.

 

You say in your last comment here that you put it in the instance's lib folder. That is probably NOT going to work. Can you try it in the instance's WEB-INF/lib? That should work. Or if you have just a class (alone) to test, try that in its classes folder, and see if what you have wouldn't work. Again, it did for me.

 

Let us know how it goes.

/Charlie (troubleshooter, carehart. org)