CFC file not being processed properly in Railo when changes made to servlet-mapping in web.xml - coldfusion

In order to play around with search engine friendly urls, I have added the following mappings to my web.xml:
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>/mywebsitename.com/index.cfm/*</url-pattern>
<url-pattern>/mywebsitename.com/posts/*</url-pattern>
</servlet-mapping>
This has allowed me to work with urls like this mywebsitename.com/posts/my-first-post
However, one little glitch is occurring. If I try and access a CFC file that was working before, it now simply returns the html text of that CFC instead of actually processing it in Railo.
To explain it better, if I add the servlet-mapping above to web.xml and call mywebsite.com/Components/CFCProxy.cfc - the html of that cfc is returned.I would expect to see a Railo dump of the functions.
However, if I remove the servlet-mapping from the web.xml file, then when I access that same URL, I see the proper railo dump of the CFC functions that can be called, which is what I expect to see.
So without the servlet-mapping it works fine, but with the servlet, only html text of the CFC is returned.
So my guess is that by adding the servlet-mapping, I am disabling the processing of that CFC by Railo somehow.
So all I would like to know is how to get that CFC file to process properly again?
Do I need to add another line to the servlet-mapping for that and if so, what?
Thanks

I ran into this same issue recently.
Try adding
<url-pattern>*.cfm</url-pattern>
<url-pattern>*.cfc</url-pattern>

Related

How to consume component from file in different folder

Working with version: 2016,0,10,314028
I know there are other questions addressing the issue, but since they are a bit old I wonder if anything has changed since then. Here is my problem:
In the "OnRequestStart" function inside Application.cfc (located in root folder), I have this:
<cfset application.cfclogin = "comp.login" />
"comp" begin the folder and login the name of the cfc file.
Inside the same Application I consume the cfc without a problem, like this:
<cfinvoke component="#application.cfclogin#" method="sgice_redirect" >
Even in a logout.cfm file located in root, the same cfinvoke method works.
But if a try the same cfinvoke from a file located in /subfolder/Layout.cfm for example, the cfinvoke throws an Error. Which looks like this:
I tried putting the name of the app in the dot notation declaration (APP.folder.cfcfile) but that doesn't work even in the files located in root invoking the cfc.
Other websites inside the same server are using this method of declaring the dot notation name for the cfc inside OnRequestStart and using that variable throughout the files, but I can't find the reason of this not working in this specific site. If you are wondering about the F:/ route, F:/WebSitesTij/CFSites/sit_tij/ is supposed to be my root folder in this case. Any help is appreciated.

Can't refresh CFC CF9 when using an application.cfm

I was charged with making some modification to an old application, and I created a new page which was being passed a URL parameter page_name, which is a you guessed it a name of a page with .cfm appended. So, in my haste, I continued using it, and was building out my CFC and using the page_name as the identifier for a record. Then I realized that there is a possibility of that name being duplicated in the table, and changed that url parameter to use the page_id, which is unique. I modified my CFC to use the new key, and nothing worked. So I started going through my code and figured I made a typo, started commenting things out, and finally dumped out my CFC object and voila, none of the edits I made were actually being used. This was fairly obvious, since page_name was a string, and page_id was numeric.
So I started googling,The first thing I saw as adjust things in the CFAdmin. I don't have access to it, and restarting the server isn't an option since I'm using an RDS to live code. The next thing I tried was to add applicationStop(), onApplicationStart(), to my Application.cfc. Well the problem is that the Application.cfc, is actually an Application.cfm. So after fiddling with the <cfapplication ... > tag, and nothing being updated, I'm here asking for help.
So is there a quick fix for this? Should I go ahead and create an application.cfc? I hope I explained myself, and sorry for all the text.
Confirm that your cfc is bound to either the session or application scope.
If it is, then you can rename the application in application.cfm and it will reset the object.
If your cfc is NOT bound to session or application scope, you have a cacheing issue. You need to go the the CF admin -> Server Settings -> Cache tab and uncheck component cache and possibly some others.
For further recommendations, ColdFusion Components Inheriting Functions Of Others
Sounds like you have been painted into a corner. Last option IF you have access the the server it self and can get into the C:\ or whatever drive that ColdFusion have been installed on, you can just manually delete the generated Java Class files that the server is using that has the old code. When ColdFusion sees there is no Class file it will recompile the newly changed file and whoa black betty go bam-a-lam your changes will be in production.
For more information here is an posting you can read up on: http://kalyan-coldfusion.blogspot.com/2010/08/how-coldfusion-works-and-its-key.html
Cheers

Railo View Source has a few thousand blank lines

I just noticed that when I view my source code in a browser, I have a few thousand blank lines before my actual code begins.
Is this a known issue in Railo? Or is there just a setting I'm missing somewhere?
I'm running Railo 4.0, on Ubuntu
In your Railo web administrator, you can turn on "Whitespace Management" in the "Output" settings page (e.g. yoursite.com/railo-context/admin/web.cfm?action=server.output ). It is disabled by default.
You can also use the <cfprocessingdirective suppresswhitespace="true"> setting to turn suppression on and off during the request.
The reason for the blank lines is that when you write a CFML template, you are probably putting much of your <CF...> tags (queries and logic) before you write the output/HTML, and each line of code has a CR/LF after it which is rendered in the final output. If you have an Application.cfm (or cfc) file then all that code is also rendering whitespace before your .cfm page as well.
You can use the Whitespace Management feature in the administrator or you can wrap your entire page with a <CFProcessingdirective supresswhitespace="true"> tag, but you can also use the <cfscript> tag, or put your logic inside a <cffunction output="no"...> tag or even a <cfsilent> tag.
Personally, I am big fan of using CFComponent tags (inside a .cfc file) to encapsulate much of the code into "classes" and leave the .cfm files strictly for output rendering.

Using onMissingTemplate in lieu of stub cfm files

In our ColdFusion application each request goes through index.cfm
Application.cfc decides form the query and form parameters which componetes the user is actually wanted. Those components are instantiated and the content is dropped through OnRequestStart.
Rather than always hit index.cfm with a query/form parameter, for simple cases, we would like to hit a "missing" cfm (i.e. MyApp.cfm) and allow the OnMissingTemplate function parse out the fact that we really want the content of a component (i.e. MyApp).
Another way to do this would be to actualy put cfm stub files in for "generic" calls to the components but it seems like with OnMissingTemplate we do not need to do that.
Is this a reasonable use for OnMissingTemplate?
That's a great use for onMissingTemplate. Just make sure that if you're using IIS, that you make sure that the files you're linking to are actually .cfm (MyApp.cfm) files, and not directories (/MyApp/). See these links for more information:
http://www.bennadel.com/blog/1625-ColdFusion-8-s-OnMissingTemplate-So-Close-To-Being-Good.htm
http://www.bennadel.com/blog/1694-ColdFusion-s-OnMissingTemplate-Event-Handler-Works-With-CFC-Requests.htm

Cannot find CFML template for custom tag

I am not a ColdFusion coder. Doing a favor for a friend who ported his CF site from a Windows server to Unix on GoDaddy.
Site is displaying error:
Cannot find CFML template for custom tag jstk. ColdFusion
attempted looking in the tree of installed custom tags but did not
find a custom tag with this name.
The site as I found it has at document root /CustomTags with the jstk.cfm file and a set of files in cf_jstk
My Googling located this:
You must store custom tag pages in any one of the following:
The same directory as the calling page;
The cfusion\CustomTags directory;
A subdirectory of the cfusion\CustomTags directory;
A directory that you specify in the ColdFusion Administrator
So I have:
Tried creating placing /CustomTags in /cfusion/CustomTags
Tried copying /cfusion/CustomTags to above document root
Tried copying jstk.cfm and subfolders into same directory as calling file(index.cfm)
Update: Per GoDaddy support I have also tried adding the following to no effect: <cfmodule template="CustomTags/jstk.cfm">
Can any one give me some tips on this or should I just tell my guy to look for a CF coder?
Thanks!
I don't know how GoDaddy is setup, so as a quick test, please do the following:
Create file test.cfm in the webroot with contents:
<cf_testtag/>
<cfoutput>test</cfoutput><cfabort/>
Create file testtag.cfm in the webroot with contents:
<cfdump var=#ThisTag# />
Then in a browser visit the test.cfm page.
You should get two debug dumps, followed by the 'test'; this will confirm that custom tags in general are working.
If that works move the testtag.cfm to the CustomTags directory, and see if you get the same behaviour or an error.
If this produces an error, for CF8 and above, you can add <cfset This.CustomTagPaths = "/CustomTags" /> inside the Application.cfc file (assuming there is a App cfc and not an Application.cfm) to ensure that directory is checked for tags.
It is possible to convert Application.cfm to Application.cfc - how easy this is depends on how complex the code is in there - might be something you could figure out, or might need an experienced CF dev, it depends.
Depending on the outcome of this, we can attempt to debug why the jstk tag isn't working (unless one of the above solves it).
In an effort to check the simple things before worrying about complex things:
Remember that filenames on *nix systems are case sensitive, but on windows are not.
For example, a windows server will pick up "application.cfm" but a linux server won't. It requires "Application.cfm".
Check to make sure all filenames/paths are the correct case.
Normally, CFML check every custom tags in current directory first, if not found, second is in CFMX8/customtags/.