MySQL Drivers, DSN's and Security Sandboxes

ColdFusion No Comments »
I have been having a problem with a CFMX6.1 server that just would not maintain connections to MySQL DSN's, if you added the DB username/password into the DSN, it would work for a while, but would eventually timeout and give the error below. Specifying the username/password in your code just did not work at all, always causing the below error. Cannot connect to MySQL server on servername:3306. Is there a MySQL server
running on the machine/port you are trying to connect to?
(java.security.AccessControlException)
It turns out this is caused if you have security sandboxes enabled. Even if you have NOTHING specified in your server/ports section which whould thus mean no restrictions, ColdFusion still disallows access to the MySQL Server. In my case I have a default sandbox on the folder where all the web sites are located. So I explicity allowed the Server/Port of the MySQL server here, and it has solved the problem. The Explanation as to the reason for this behaviour goes something like this:- When you create a DSN via the CFADMIN with a username/password, it creates a pooled connection which works because the CFADMIN has access to the Server/Port of MySQL. Any code that now uses that DSN uses the already verified pooled connection. This connection will however be closed after 20 minutes of inactivity. If you pass the username/password in your code, a new connection is created, which does not have access to the Server/Port because of the sandbox, thus it fails to connect. This behaviour does not however seem to be consistent, as I have other CFMX servers using sandboxing where MySQL DSN's work fine without neeidng to explicity specify the Server/Port of the MySQL Server in any sandbox. You would also expect the same problem to affect SQL Server DSN's, but it doesn't. On top of these problems, I also couldn't get the alternate connector/J MySQL driver to work on this server. After solving the above problem, I then started getting the below error. This was using the 3.2.0-alpha driver, which was the only one that I could previously get to work on other servers. But this was supposedly causing conflicts with log4j libraries in the newer 3.1.8 jar and greater and the CFMX own log4j interface. So I changed to the 3.0.16ga driver, which now appears to be working. Connection verification failed for data source: jf1[]java.sql.SQLException:
Unable to instantiate logger class 'com.mysql.jdbc.log.Log4JLogger', exception
in constructor?The root cause was that: java.sql.SQLException: Unable to
instantiate logger class 'com.mysql.jdbc.log.Log4JLogger', exception in
constructor?
Thanks to Nick Watson @ Adobe for his help in resolving this issue.

cfindex.dll: Can't find dependent libraries

ColdFusion No Comments »
Had a new error today that I have not experienced before on a CFMX7 server. In the server logs it said: C:\CFusionMX\lib\cfindex.dll: Can't find dependent libraries. After checking the dependencies for the cfindex.dll I discovered that "MSVCP60.DLL" was missing from the system32 folder. So I just copied it over from another server and this fixe dthe problem. The library file msvcp60.dll contains program code used to run programs written using Microsoft Visual C++. msvcp60.dll is required for programs written with Visual C++ to function correctly.

Remotely executing a DTS from ColdFusion

ColdFusion 1 Comment »
I recently had the requirement to execute a DTS on a remote SQL Server via ColdFusion. Doing it via CFExecute was the only method I could find in the Books online, and all the ASP scripts I found seem to asusme your SQL server runs IIS or is on the web server your site is on. Luckily I eventually found this rather handy answer over at pengo works. http://www.pengoworks.com/index.cfm?action=articles:spExecuteDTS the only caveat I have found is that you cannot do anything remotely to the SQL server. I found that I had to login to the server, run enterprise manager, login as the DBO of the database I want to install the DTS on and do it from there. Otherwise it will not run.

MS Access DSN errors

ColdFusion No Comments »
On on of our CFMX7 multi-server installs, we started getting these 2 errors when a customer tried to setup a MS Access DSN. Error 1

Unable to update the NT registry.Cannot open
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources: Windows error
number 5 occurred. Access is denied.
This error is actually caused by the user under which JRUN or ColdFusion MX runs under not having access to the specified registry key. This is most likely to happen if you are running the CFMX service under a user other than SYSTEM. Which was the case for me as our servers are locked down and secured and do not use any of the default install configurations. You need to edit the permissions on the ODBC key and give permission to all users under which your CFMX services run. Error 2

Unable to update the ColdFusion MX 7 ODBC Server.An error occurred when
performing a file operation WRITE on file
C:\JRun4\servers\\cfusion.ear\cfusion.war\WEB-INF\cfusion\db\slserver54\admin\xact.inp.The
cause of this exception was: java.io.FileNotFoundException:
C:\JRun4\servers\\cfusion.ear\cfusion.war\WEB-INF\cfusion\db\slserver54\admin\xact.inp
(The system cannot find the path specified).
This one is caused by the non existence of the folder "slserver54". If you are running multiple instances, this folder is not copied by default when you create a new instance, so you will need to copy it over from the default "Cfusion" instance. the location where this folder should on your installation be is given in the error.

JRUN Creeping Death

ColdFusion No Comments »
Many people have had the old creeping death problem, where JRUN just consumes more and more memory until it finally keels over and dies. Often this has been due to a memory leak that a patch has fixed or soimething easy to identifiy like massive cached queries. But we just had a client with the problem, and their server was CFMX7.0.1 and all patched up, so it had to be an application problem. It turned out to be a rather unusual one, so I thought I would blog it. Having spent a considerable time looking at all the usual issues, caching, or lack of, persistent variables, slow running pages, drivers etc, and tweaking code that looked like it might be the cause, I was coming up empty. Then after dumping out the entire session scope for the application, I discovered that the clients shopping cart CFC was persisting itself inside every session, and with over 1200 sessions in use, this was just eating up more and more memory. This handy bit of code, is what will dump out all your sessions. Thanks to Alex @ pixl8.co.uk for his help and putting me onto these handy java methods. <cfscript>
sessiontrackerObj= createObject("java","coldfusion.runtime.SessionTracker");
activesessions = sessiontrackerObj.getSessionCollection(application.applicationname);
nosessions=ListLen(structkeyList(activeSessions));
</cfscript>
<cfoutput>
<h3>Total Sessions : #nosessions#</h3>
</cfoutput>
<cfdump var="#activesessions#">
So the lesson to be learnt here is, watch out what you put in your sessions or other persisted scopes. In this example you only needed a single instance of a CFC to be invoked, and it should be used to populate an external structure in the session. Another example of why using the THIS scope in a CFC is bad. Here is a nice blog on other runtime methods you can use to access and manipulate session data. http://jehiah.com/archive/extended-operations-on-coldfusion-sessions
Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds