Blog

CodeChef - ColdFusion Builder extension to speed up CFML coding
Tue, 11 Aug

CodeChef which Is available on github is a ColdFusion Builder extension to help you make you very productive in your CFML coding.

 

What is CodeChef?

CodeChef(as the name suggests) cooks up CFML code for you in no time. Just type in kewords related to what you want to do and you are done. Keyword can be a use cases like “write”, “read”, “create” etc. just a keyword like “file”, “pdf” etc. Once you type keywords in the search filed CodeChef presents you with various options based on it. You select the option based on your requirement and just hit enter. That’s it!!. Basic CFML code related to the selected option will be added to the file currently open in editor.

How to Run the Extension

Just select Code Chef from dynamic Views drop down and click Show View to get started.
Once Code Chef view is launched just type the action/keyword in Code Chef view (ex. write file, create pdf, loop, or get current directory), select appropriate option from suggestions and hit enter. Appropriate code will be inserted in any file already open in editor. Here is a screenshot of CodeChef view in ColdFusionBulder showing various options for a given keyword

 

 

 

 

 

 

 

 

 

The current version is only a working prototype with limited options just to demonstrate the idea and its power. Here are few screenshots to give an you an idea. Download the extension and give it a try.

 

As I mentioned its just a working prototype right now so the options are not extensive. I will try to keep adding more code options and keep the project getting better and make CodeChef a really powerful CFML development tool. I will write another post on how once can contribute to add more options to it but since its just CFML and XMl it will be easy to figure it out.

Do give it a try.

 

Configuring Connectors Manually for IIS 10
Fri, 07 Aug

 

Important update: Note that ColdFusion 10 and 11 have been updated to support Windows 10, a couple months after this blog post was first written. Consider applying that update rather than this manual configuration.

 

With Windows 10 out, there is a problem that most of the ColdFusion customers will face, configuring connectors for IIS 10. Wsconfig, the connector configuration tool, only supports till IIS 8.x. While the ColdFusion team is working on this issue and will try to provide the fix for it as soon as possible, there is already a KB article which can be referred for configuring the connectors manually. Although the article was originally written for CF10, it can be used for CF11 also. After following all the steps in the article, you need to do one more thing. Add index.cfm as default document for your website in IIS.

This solution is only recommended for development environments as thorough testing of the connectors with IIS 10 is still going on. So for production machines, you should wait for the actual release from Adobe.

Important bug fix related to in memory files in ColdFusion 11 update 5
Thu, 06 Aug

An important bug related to VFS or in memory files was fixed in ColdFusion 11 update 5.

Issue was related to clearing up any in memory files once VFS was disabled. Suppose your app had previously enabled VFS and created few files in memory. Now at any point in time if VFS was disabled these files will still be in memory and were not getting cleared.

With ColdFusion 11 update 5 the same issue has been fixed and VFS files will be cleared as soon as VFS is disabled.

The same fix is also available for ColdFusion 10 update 16.

Refer to bug (https://bugbase.adobe.com/index.cfm?event=bug&id=3039708) for more details on the same.

 

When should tools.jar be updated in ColdFusion Server
Mon, 27 Jul

tools.jar contains the utilities to compile java source into class files.

While using ColdFusion Web services stubs have to be generated.

So, this utility is required for this feature to be functional.

The tools.jar is shipped by default with ColdFusion along with full installation of ColdFusion which would be same version of the jre that ColdFusion is shipped with.

If you are just using this default installation and the built-in jre, your ColdFusion web services do work fine.

However, due to security bugs or platform support you would want to update the jre version that ColdFusion runs on.

Once you do that, please make sure to copy the tools.jar file manually from {JDK_Home}/lib to {cf_install_home}/cfusion/lib/

Only JDK contains the tools.jar file not the jre installation. You don't have to install JDK on the machine where ColdFusion is installed. You can just have jre on this machine and get tools.jar from any other machine's JDK installation.

And also make sure that the earlier stubs are cleared from {cf_install_home}/cfusion/stubs/ to get the newly compiled classes.

It is necessary to update tools.jar ONLY if you are upgrading the jre to a a higher major version.

Say, if you are upgrading from 1.8 U5 to 1.8 U51 you don't have to update tools.jar file.

But, say   if you are upgrading from 1.7 U55 to 1.8 U51, you have to update tools.jar file.

 

Another case where you would want to update the tools.jar is JEE deployments.

Say, if you are using Websphere application server with IBM JDK, you have to place the corresponding JDK's tools.jar under  {cf_install_home}/cfusion/lib/.

The same applies to any other application server as well.

The simple rule is that tools.jar has to be from the same major version of Java (minor version doesn’t matter) that ColdFusion runs on.

 

This applies to any version of ColdFusion and the same applies to all platforms.

You can copy tools.jar from Windows machine to Solaris macine as well as long as the version is correct.

 

 

Some of the factors that help in deciding the memory that application needs
Mon, 27 Jul

Would like to explain the some of the factors that decide how much maximum memory that an application needs.

Here are two examples. One is with cffile upload action and the other is with cfpdf thumbnail action.


Sometimes, while uploading large files using cffile with upload action (<CFFILE ACTION= "UPLOAD") you would have run into the following error

"500 - Internal server error.

There is a problem with the resource you are looking for, and it cannot be displayed."

 

File upload is dependent on “Maximum size of post data” value that you can set in ColdFusion Administrator.

However, it can’t exceed the total available free memory.

Say, if 512 MB is the Xmx memory value (jvm.config) and 350 MB is already occupied by the application, even if “Maximum size of post data” value is set to 200 MB, it can upload files of up to ~150 MB (512 MB- 350 MB).

It can’t upload files of size 200 MB.

To fix it, Xmx should be increased which is again subjected to the available memory in that machine.

 

Here is other example:-

Say, you are using CFPDF's Thumbnail Action and the thumbnails background is not generated properly.
Here the issue would be insufficient memory.

        Just to hold the decoded image data, java application needs large memory (say 1.2 GB depending on the image pixels).

It is because of the format and high pixel nature of the image that is being converted. Number objects created are equal to the total number of pixels in that image.

So, high pixel imge would consume more memory.

To fix this, Xmx value in jvm.config should be at least -> Applications memory Size + 1.2 GB (from the above example) i.e. a minimum of 1.5 GB and can be more depending on your application.

Changing the value and restarting the server would fix this.

How to enable/disable Tomcat logs
Sun, 26 Jul

Sometimes, depending on your need, you may want to enable or disable the tomcat logs.

This can be simply done changing a setting a in <ColdFusion_Home>\cfusion\runtime\conf\server.xml file.

At the end of this xml file you can see the following tag.

<!--

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 

               prefix="localhost_access_log." suffix=".txt"

               pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>

-->

Uncomment this tag as follows and restart the server for the changes to be effective.

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 

               prefix="localhost_access_log." suffix=".txt"

               pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>


Similary, to enable the Tomcat logs, comment this tag.

When Tomcat logging is enabled, you can change the logging level in the logging.properties file by changing the following setting.
<ColdFusion_Home>\cfusion\runtime\conf\logging.properties

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = WARN

 

 

Configuring JNDI Data sources in ColdFusion
Sat, 25 Jul

For configuring JNDI data sources, it should firstly be supported by the application server.

Tomcat server, which is built-into ColdFusion server, has the support for this by default.

While there is a blog Here on this how to configure, I want to explain few mistakes that are tend to be done while configuring. 


  One common mistake generally done is:-
  When the data source is configured from the ColdFusion administrator by providing irrelevant    username/password.
  You may tend to provide Database's username/password. This is NOT Database's username/password.
  It is the application server's username and password on which data source is configured.
  It should be left blank when the credentials are not required by the server.


Prepending java:comp/env/ is required for the actual JNDI name that is registered in xml while registering the name in administrator.

It is not mandatory that you register the JNDI data source in ColdFusion administrator.

As long as the app server supports JNDI, you can invoke the data source that is configured in the application server in cfm source code directly either in case of standalone installation or EAR/WAR deployment.
But for consistency and preferred names that can used in ColdFusion should be registered in ColdFusion.

This is applicable to both ColdFusion 10 and ColdFusion 11.

 

ColdFusion 11 and dbvarname attribute
Fri, 24 Jul

First, some background.

dbvarname is an attribute for cfprocparam to specify named parameters while calling a stored procedure. For details refer https://wikidocs.adobe.com/wiki/display/coldfusionen/cfprocparam

Versions prior to ColdFusion5 had support for dbvarname. This was deprecated in ColdFusion MX, brought back in 7.0.1 and deprecated again in 7.0.2. The reason was the lack of proper support from multiple jdbc drivers. Since then, this was a major ask among ColdFusion users.

ColdFusion 11 brought this attribute back from the dead. It was disabled by default with a flag to enable it. ColdFusion 11 update 3 enabled it by default. Databases need a variable prefix for named parameters. (eg:- ":" for Oracle and "@" for SQLServer). If the database is SQLServer, it should be dbvarname = "@param1". This will break applications which were using this attribute without the prefix because this attribute was being completely ignored in prior versions. So to give some time for customers who don't want to change their code, in update 4 we introduced a flag to disable dbvarname.

-Dcoldfusion.ignoredbvarname=true jvm flag can be used to disable dbvarname attribute. This flag is only for CF11 and not for later versions.

Having to change lot of code is not pleasant but we believe that is the way forward.


Configuring Status Worker in Connectors
Mon, 20 Jul

Sometimes there is a requirement to know the realtime load on a ColdFusion Server. One way to get this information is through cfstat which displays the relevant information at CF server/Tomcat level. One more way to get this information is through Status worker which displays the information at Webserver/Connector level. 

A status worker is a special type of worker which does not communicate with Tomcat. Instead it gathers configuration and load details from other workers and displays it. It can also be used to change some details dynamically. Configuring a status worker is pretty straightforward. After the connectors are successfully configured with wsconfig tool, we need to change worker.properties and uriworkermap.properties to enable status worker. In worker.properties, add a new worker:

worker.list=cfusion,cfstatus

worker.cfstatus.type=status


In uriworkermap.properties, add a uri mapping to this worker:

/cf/status = cfstatus

Restart the webserver.

Now whenever a request comes at http://WebserverIP:Port/cf/status, it will be redirected to this status worker which will display the relevant information based on the query parameters in the request. Some of the common parameters are:

 

  • mime: Specifies the output format. If someone is running a script to get status information and parse it, the value should be xml. If its only used for display purpose, then it should be html.
  • cmd: Specifies what action you want to perform. list displays details of all the configured workers. show displays information of a specific worker.
  • w: Specifies name of the worker. It should be used along with cmd=show.
  • sw: Specifies name of subworker if w referred to a lbworker.
  • opt: Specifies which information should not be displayed. It is bitmask of desirable options. The allowed values are:

0x0001: hide members of lb workers

0x0002: hide URL maps

0x0004: hide the legend (Works only with html)

0x0008: hide load balancer workers

0x0010: hide ajp workers

0x0020: only allow read_only actions for a read/write status worker.

0x0040: hide load balancer configuration  (Works only with html)

0x0080: hide load balancer status summary (Works only with html)

0x0100: hide configuration for ajp and load balancer member workers (Works only with html)

 

So to get details of cfusion worker, an example url will be:
http://IP:Port/cf/status?mime=html&cmd=show&w=cfusion&opt=262 (0x0002 | 0x0004 | 0x0100)

Status worker can also be used to modify some config parameters dynamically. If someone doesnot want that functionality, it can be configured in read-only mode also. Just add the following line in worker.properties:
worker.cfstatus.read_only=True

For all the configuration parameters and query parameters refer to the following document: