Getting Set up With Android

There’s plenty of posts on the internet for getting setup with Android, but they all typically run without problems, which is rarely the case – so posting my experience of it…

Download Android Studio

If you’re new to Android and just trying it out, then you’ll likely want to get up and running as quickly as possible to see if it’s for you. If so, invest in your life – don’t mess about installing the SDK, then configuring to work with your preferred IDE (which you can do), get going quickly by installing Android Studio, the official IDE.

Android Studio comes with the IDE, the SDK tools, the latest Android Platform, and emulator images – all of which you will likely need for Android development. What’s more, the SDK isn’t bad either – there’s certainly worse IDE’s out there. You can download it from developer.android.com.

First Launch

On first launch (and every launch in fact), check the SDK for updates (can do easily wi). These seem to be dependent, so there my be 5 updates, then after that, there may be 2 more updates. It’s a bit frustratingat times, but in early days of development, you want to know that you have all the latest code, and any errors aren’t caused by your own code.

Speaking of Errors…

When getting setup in Android Studio, you might see this error…

Installing Android 1

It’s a common problem, so installing HAXM to aid hardware acceleration will probably solve your pain…Installing Android

After you download it, make sure you run the setup located in:{SDK_FOLDER}\extras\intel\Hardware_Accelerated_Execution_Manager\intelhaxm.exe

Note: in Android Studio, the command “intelhaxm.exe” has been changed to “intelhaxm-android.exe”

If you get the error “VT not supported” during the installation disable Hyper-V on windows features. You can execute this command dism.exe /Online /Disable-Feature:Microsoft-Hyper-V. You will also need “Virtualization Technology” to be enabled on your BIOS

Still not working?

Nah – didn’t for me either. Instead I created a new VM in the VM manager, that wasn’t an x86 version. This recommended HAXM for running, but isn’t needed – so just ignore the warning. However, it was still very slow and you have some pretty good options anyway…

Emulator Alternatives

GenyMotion

When I found the Android Studio emulators to be a little slow on my laptop, I discovered GenyMotion, an Android emulator with different pricing plans – and yes, there was a free “non-commercial” version.

This did work well, and was much faster, however there were some limitations. Like many “free” versions, a lot of the good functionality was locked down for paying customers (e.g. different device configurations), so not ideal for anybody just looking to try out Android.

Nothing beats the real thing

The good thing about Android Studio, is that you can setup your actual Android Phone to act as an emulator for testing your app. I found this to be the best way to get a good feel for your app, and it was easy to setup:

  • Enable Debugging Mode on your device (the process is different depending on which version of Android you’re running – so just Google the “how-to”.
  • Open Android Studio, and configure in the AVD manager.

With your phone plugged in via the USB cable, Android Studio runs your app on your phone – giving a proper sense for how it works – and shows logging on what your phone is doing the whole time.

After the “Hello World”…

Once you’ve followed the obligatory “Hello World”, and got your head around the framework for build apps, writing apps is the fun part. If you’re like me and “making it pretty” takes far longer than the pay-off, Google have made this easy for you with an online resource to help make your apps pretty with a set of standards you can copy. It includes styles, layouts, icons, colours and loads more that you probably never thought of.

https://www.google.com/design/spec/material-design/introduction.html

 

Is ColdFusion Dead?

Yup, this one again. For literally years people have been asking “is ColdFusion dead?”, each time one of the well-known developers in the CF community would scoff “Pah! Of course not because of xyz…” – but for a while I have been thinking, perhaps there is no smoke without fire….

Not dead, but more like Duran Duran or ShedSeven…

Personally, I don’t think ColdFusion is actually dead; more like a has-been pop band, living out its days putting out the odd release for a hugely diminished yet loyal fan base. Most of the followers from “back in the day” have moved on and found something new, and the only current fans have been there since the beginning – but it’s not gaining any new ones…

I still think ColdFusion is good at what it does; it’s great for fast development of both small and enterprise applications; it’s just that it’s not as popular any more – which comes with it’s problems.

Back in the “Macromedia Days” of ColdFusion, there was a bit of a buzz about it, albeit not in the majority, it was still popular and you didn’t get blank looks from other developers when you mentioned it. There weren’t many real server-side options to choose from (compared to today), and ColdFusion managed to win a few people over with its rapid development, and enterprise features. Still, PHP and ASP were probably more popular than CF, mainly because they came without the prohibitive licencing costs – however CF was better (in my opinion).

Over time however, ColdFusion became less prevalent and is now competing against more alternatives for enterprise environments, and competing against even more for server-side developments. Within about 10 years, ColdFusion slipped from being a popular trend, to some forgotten part of the pre “Web 2.0” era, and is now mostly found in legacy systems and the phrase “is ColdFusion dead?”

Where things went wrong

The Development Community is essential

One of the most important aspects of any programming language is the community – without it, you don’t have anyone to build for, nobody pushing for new features, and a poor support community which is essential. ColdFusion had a big community (it still has a knowledgeable one), but it has shrunk and there seems to be no effort from Adobe to combat this, other than put out new releases.

The question “is ColdFusion dead yet?” is asked so often because it doesn’t seem to be putting up any fight against its contemporaries from back in its heydey, nor has it really evolved or changed much (oh sorry, it’s got rid of JRun and now uses Tomcat). Look at some of the alternatives to ColdFusion 15 years ago:

  • Java is everywhere” as they put it – and they’re right. The software is everywhere and so are the developers. It’s also a nice strongly typed language.
  • PHP is hugely popular, and used to build some of the most popular content management systems in the world (WordPress, Magento, Drupal)
  • ASP though classic ASP is arguably on the decline, this is likely because Microsoft gave everyone something new to use in ASP.NET, which is also hugely popular.

Where is ColdFusion? What massive things has it done? Well, software giant Adobe became its new owners in 2005, and since then…..well, nothing much really.

It’s greatest strength…

A huge problem with ColdFusion is that it’s greatest strength is also it’s greatest weakness – it’s so easy to pick up. This meant that during its heyday, anyone who picked it up could start writing code quickly – regardless of their ability, which made it a pretty popular choice. However, this meant that almost anyone could cobble something together and even if it wasn’t done well, would still get a result (just because something works, doesn’t mean it’s been done right). This meant that memory leaks became common, and due to a lack of understanding, this often resulted in a call to “restart JRun” with ColdFusion taking the blame – not the developer.

Other languages like Java or .NET, are complex to write but you have to understand it in order to make it work; their complexity is almost a barrier to entry which means that less experienced developers are likely to opt for something more “scripty” or actually learn it properly.

Licencing Fees…

Of course, the cost of ColdFusion licencing has also played a big part in the shrinking of the community; why would a development company pay for an expensive CF licence when it could use PHP for free? True the development process with CF is faster, but businesses would not know this without first buying the software, and unlikely to see a financial benefit until their developers were up to speed with CF.

It definitely is shrinking…

The signs are there that it is undoubtedly decreasing in popularity; the number of jobs in ColdFusion are a fraction of what they used to be, and any companies that still use ColdFusion are diversifying into more common platforms (typically seems to be .NET or Java). For me, the greatest sign of ColdFusion’s demise is the diversifying of its high profile users/bloggers, that the CF community seems to rely heavily upon for reassurance that it still exists…

  • Raymond Camden (apart from heralding new CF releases) seems to spend a lot of his time developing PhoneGap applications and is becoming one of Adobe’s faces for this.
  • Ben Nadel is becoming more involved with Javascript frameworks, though still blogging on CF.
  • Joe Rinehart (contributor of the ColdFusion ModelGlue framework) publicly announced he was moving away from CF in a thought-provoking open letter to ColdFusion on YouTube – favouring other technologies such as Grails.

Apart from these, there are many other developers (other companies, my colleagues, and myself!) that have moved elsewhere. For me, I decided to move to .NET – why? I made a conscious decision to look hard at a few other languages before making a solid decision to throw myself into another one. What are other companies using? What are the better language alternatives? How can a language be used? What is the community like? Where are the better jobs found?

Nails in the Coffin

A large part of me wanted a change, and ColdFusion doesn’t seem to change much. Nothing incredibly radical in the language happens to improve it. However, some final nails in the coffin really helped me make up my mind…

  • Frameworks are being left. A while ago there was a message on www.reactorframework.com to say that the ORM project was being “parked”, however the site is now entirely dead. Machii framework has also been “sun-setted” at version 1.8, with a message on its website to say that its original developers have all moved away from ColdFusion (what does that tell you). Finally ColdSpring, the DI, IoC and AOP framework modelled loosely on Java’s Spring. If it were an animal, a kid would be poking it with a stick by now; it’s there, but nothing seems to be happening any more (version 2 has been in Alpha release since 2011). The documentation is weak, and searches for tech info often bring up unrelated results from “www.mail-archive.com” (always a sign you’re getting nowhere).
  • Nobody Uses it anymore. It’s true. There were a handful of organisations locally that I knew of using CF, however these have moved/moving to other technologies now.
  • Adobe isn’t interested in ColdFusion, and doesn’t really seem to push it or develop it. After Adobe bought out Macromedia, it took about 2 years before the “Macromedia ColdFusion Service” was renamed (how hard could it have been?), and even 10 years on, db error messages still refer to “[Macromedia][SQLServer JDBC Driver]”. Has it really been so long since they took a look at the code, that the previous owners name is still on it? Adobe did however release a “dedicated ColdFusion IDE”, ColdFusion Builder – based upon the open-source IDE Eclipse. Apart from the logo and the price, both IDE’s are identical – they’re even as buggy as each other.
  • I want to try other things. CF is a web language, whereas others such as Java, Python or .NET can be used in other ways too. I’m interested in developing software for other uses, not just the web.
  • CF Documentation is appalling. Adobe Livedocs (whatever they call it now) is terrible, and it has been for some time. Compare this with the in-depth, ever-deep-linking documentation of Java or .NET and it doesnt even compare. The examples on livedocs have for a long time been terrible, often with comments from the public correcting them. Also, if Google takes me to a tag reference for CF8, and I then click on the CF9 link – I expect to see the equivalent tag reference for CF9 (llike .NET does) – not an introduction to CF9. The poor standard of what is supposed to be the “official documentation” is just another example of how Adobe invests minimal effort into the software and its community.
  • CFscript frustrates me so much. Things are so convoluted to write in comparison with CFML or only even possible in CFML, so why bother even bothering with CFscript if it’s only a matter of time before you have to come out of it and use CFML to get everything you want done? I would actually prefer to be able to write everything in cfscript (more OOP feel, and less markup-type coding) but things are just much easier in CFML.

Since ColdFusion MX I’ve been building large applications ColdFusion, but now the time has come to move on. The software world is changing, and CF doesn’t seem to be part of it; so many other platforms take precedence over CF, and for the future prospects of businesses/developers, it’s not a great horse to back with a shrinking community, and no new blood coming in.

Fork Me – I am a Git (hub)

Previously I have been using Beanstalk for personal SVN, though Github seems to be much more prevalent amongst the dev community, so last week I thought I would setup my own Git repository and give it a try. I have setup an account at https://github.com/cfphil where people can fork my projects, and so far I’m pretty happy with Github.

First up, I thought I would upload a ColdFusion testbench application that I gradually built up over a couple of years. It’s been built on an ad-hoc basis, and only driven if/when I needed to investigate a particular piece of logic. It’s not pretty, and it’s certainly not sophisticated (no really, it doesn’t even use OOP), but it strips away tests to their bare elements to examine the disadvantage/advantage of different programming approaches.

testbench-screenshot

My ColdFusion Testbench – “You won 3p in a beauty contest”

No matter what programming language you use, I recommend running the same sort of tests, as gaining this type of insight into a programming language is essential when trying to optimise performance of an application. It also gives you a greater appreciation of what is happening in the background, rather than regurgitating the findings of some high-profile blogger.

I haven’t really touched my ColdFusion TestBench in a while, but more recently writing a .NET MVC equivalent (though much prettier). I will get around to uploading that to my repository at some point too.

Checking HTTPS in ColdFusion on Tomcat

So this came about after I was asked to debug a problem with an application that was misbehaving when users were logged in. As I setup the application on my machine, I noticed that all links were reverting to HTTPS by default. Initially, I thought this might be caused by the “baseref” tag, or the rules in the .htaccess file, but nothing.

It was actually caused by some logic in the codebase of an in-house framework that we use, that was checking for HTTP/HTTPS and correcting according to some predefined logic. Even the logic seemed fine – if “HTTPS” eq “off” then use “HTTP” – so this led me to think there was something up with the headers…

Usually, when CF is running through IIS, the HTTPS value is set, but in tomcat at least, it seems to be blank when running through HTTP. Perhaps it is only set when running through HTTPS? I quickly setup HTTPS on my local machine using a self-signed cert (see previous post on how to do this) and tested it when running through HTTPS….STILL NOTHING!

This is where the benefit of installing CF on native Tomcat is really becoming moot, as it is causing more disruptions than was intended to avoid. According to Charlie Arehart’s presentation on a few months ago, there is limited support for CGI variables in a native Tomcat installation (which I have – running CF9).

It seems I cannot add these additional headers without writing my own filters for Tomcat, which I haven’t the time for right now, and I would rather know WHY it wasn’t working, than fix it for now. Besides, there are other ways in which our in-house MVC could check for SSL anyway, like checking the port – which to be fair is platform independent, as relying upon the CGI variables in CF clearly isn’t.

Another alternative could be to install Bilal’s IIS to Tomcat Connector. This MIGHT contain enough to get the additional CGI headers there. Freezer food for future thought.

Enabling HTTPS in local Apache Tomcat

Sometimes it’s useful to run a site through HTTPS during testing, without the actual cost/hassle of installing a valid certificate. In case you need to, this is how you do it through Apache Tomcat – IMPORTANT THIS IS ONLY FOR LOCAL MACHINE – NOT A SERVER!

Click here to skip the intro to SSL and HTTPS

Brief Intro to SSL and HTTPS

SSL (secure sockets layer) is a protocol that is used to achieve a secure layer of communication between two machines over the Internet. In order to make use of SSL/HTTPS, the server must have a valid secure certificate installed to allow this to happen. Without a secure certificate, SSL cannot be used, and the client/server connection is not encrypted.

Certificates are typically issued by trusted third-party organisations called certificate authorities (such as VeriSign, Thawte, Comodo), and effectively are offering THEIR assurance that the server/domain is a valid company or organisation. SSL certificates do not need to be signed/verified by a certificate authority, however if they are not – the client browser is warned of a problem with the certificate, and warns the user to proceed at their own risk.

Self-Signed Certificate

To use HTTPS within the bounds of your local machine (acting as the server and the client), there is no risk of the connection being exploited by an external malicious user, as the connection never leaves your machine. It would be unnecessary to purchase a secure certificate that is authorised and signed by a certificate authority, as there would be no other users needing assurance that you were legitimate? Instead you can generate you own secure certificate it, “self-signing” it yourself. Once the certificate is installed, you can then use HTTPS on your local machine (ONLY VALID FOR TESTING ON YOUR MACHINE HOWEVER!)

How to create your self-signed certificate

  1. Load up the command line tool, and browse to the “bin” folder in the Java root. Prepare the keystore with the following command (change to suit your own preferred keystore location):
    1 - setupkeystore

    keytool -genkey -alias tomcat -keystore c:\keystore\tomcat.jks -keyalg RSA
  2. At the prompt for the keystore password, enter “changeit” (Tomcat default) and again for the confirmation.
    enter password "changeit"
  3. Complete the following questions according to your business. This is obviously an essential part of the validation process when using a certificate authority (they use this to check the organisation requesting the certificate is legitimate), and is also presented to users who choose to view the certificate details in their browser. For our purposes however, it’s not so important…
    Organisation Details
  4. Next, it will ask for the Key Password, which is specific to this Certificate – as opposed to the password used for the whole keystore (step 2). Although it implies that you can set different passwords, a restriction with the Tomcat implementation means that the key password and the keystore password MUST be the same (so just press enter).
  5. Browse to the folder of your keystore, and you should see the keystore file, and the certificate to be used by your server.
    keystore folder
  6. Open up “[apache directory]/Tomcat/conf/server.xml” and add the SSL connector below, ensuring that you set the passwords/paths correctly for your environtment…
    <!-- Define a SSL HTTP/1.1 Connector on port 8443 This connector uses the APR configuration --> <Connector clientAuth="false" port="8443" minSpareThreads="5" maxSpareThreads="75" enableLookups="true" disableUploadTimeout="true" acceptCount="100" maxThreads="200" scheme="https" secure="true" SSLEnabled="true" keystoreFile="c:/keystore/tomcat.jks" keystoreType="JKS" keystorePass="changeit" truststoreFile="c:/keystore/tomcat.jks" truststoreType="JKS" truststorePass="changeit" SSLVerifyClient="require" SSLEngine="on" SSLVerifyDepth="2" sslProtocol="TLS"/>
  7. Restart Tomcat server. Test the HTTPS by browse to your localhost, with the SSL port appended (for example, https://127.0.0.1:8443). If everything went well,you SHOULD see a warning from your browser, advising you that the certificate is not trusted by any certificate authorities…
    Security certificate is not trusted!But it’s fine – click “Proceed Anyway” to see your website now using HTTPS (sort of)…
    no_https

Important note: This SHOULD ONLY be used for LOCAL testing, not for the production environment.

How to wipe categories in Magento 1.7.x

Magento is pretty awesome at what it does, but it’s a pain when it comes to deleting a load of categories at once. It’s strange that deleting products is so quick and easy to do, but there’s no similar feature for products.

On a Magento install with a few plugins, I typically like to avoid manual DB updates as it’s hard to tell what tables the external plugins rely upon, and it becomes a minefield for disaster. Still, there were over 900 categories that someone had created, and they wanted me to delete them – and I didn’t fancy sitting and doing it manually.

After some careful searching for a decent SQL query to wipe the categories (SQL queries posted on the web as ‘solutions’ to a problem can be few and far between), I found one on www.myscienceisbetter.info by Romeo Adrian Cioaba, and then checked it against www.magereverse.com (probably the best Magento DB resource out there), and again on the actual project DB to make sure. Even then, I created a DB backup before trying it – and recommend you do the same.

Code:

SET FOREIGN_KEY_CHECKS = 0; -- Disable foreign key checking.
TRUNCATE TABLE `catalog_category_entity`;
TRUNCATE TABLE `catalog_category_entity_datetime`;
TRUNCATE TABLE `catalog_category_entity_decimal`;
TRUNCATE TABLE `catalog_category_entity_int`;
TRUNCATE TABLE `catalog_category_entity_text`;
TRUNCATE TABLE `catalog_category_entity_varchar`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `catalog_category_product_index`;
SET FOREIGN_KEY_CHECKS = 1; -- Enable foreign key checking.

insert into `catalog_category_entity`(`entity_id`,`entity_type_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`position`,`level`,`children_count`) values (1,3,0,0,'0000-00-00 00:00:00','2009-02-20 00:25:34','1',1,0,1),(2,3,3,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1/2',1,1,0);
insert into `catalog_category_entity_int`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) values (1,3,32,0,2,1),(2,3,32,1,2,1);
insert into `catalog_category_entity_varchar`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) values (1,3,31,0,1,'Root Catalog'),(2,3,33,0,1,'root-catalog'),(3,3,31,0,2,'Default Category'),(4,3,39,0,2,'PRODUCTS'),(5,3,33,0,2,'default-category');

Aside from having to disable Foreign Key Checks (for ‘catalog_category_entity’) this script worked well. It deletes the product lookups for the categories, deletes the categories and their meta data, and then recreates the “Default Category” that Magento relies upon.

So for clarity, it is only a small SQL script, but credit goes to Romeo Adrian Cioaba, not me. I’m just posting this as a “I tried this one – it works” for anyone looking.

Sutocom.net – Blogger Jam, Harmless Spam, or Unethical Scam?

Today I received a notification that a couple of my posts on Apache Tomcat had been reposted by Sutocom.net. I thought that this is likely spam; the type of “random following” that you get on Twitter, where someone follows you just to “ping” you, so that you look up their profile, and be advertised at.

If it was, it worked – because I checked their site – I wanted to find out who was linking to me.

Blogger Jam?

Sutocom.net seems to be a site consisting totally of reblogged content, taken from whole load of other WordPress.com blogs, and authors. It’s all done “fair” in that it provides references and links to the original blog/author, but this cannot be good for SEO – for them at the very least?

Harmless Spam?

Still, Sutocom.net currently has a domain authority of 32, which is surprising for the unethical way that they source their content (I think anyway). On the face of it, this ought to provide my blog with some decent “link-juice”, however it just feels wrong.

  • No original content – Sutocom doesnt produce any original blog articles. Original articles are duplicated on their blog from whatever source they came from.
  • Too many posts – They re-blog about 30 articles on a day. Google isn’t stupid – it’s a small site relatively “heavy” on the blog side.
  • Duplicate Comments – They post the same comment/link on the original articles “Reblogged this on Sutoprise Avenue, A SutoCom Source“. If it was genuine guest/reblogging, this wouldn’t be identical – and I suspect that Google will realise this.
  • Poor Quality – The whole site itself is poorly written, vague, and low quality.

Unethical Scam?

Despite the whole blog consisting entirely of reblogged articles, requiring minimal effort from the site owner, there is a “donate” page, which appeals for contributions:

In order to upheld the quality of the site and maintain I am asking for a voluntary donation to fund improvements to this site and sutocomblogs.com.

(there is no site at sutocomblogs.com – perhaps there wasn’t enough donations?)

Anyway, this all adds up to the feeling that this is a site that I don’t want to be associated with (primarily for SEO reasons to be honest).

What would Matt Cutts do?

I think the Google spam team would see that the common link in this duplicate content issue is Sutocom.net, not the author sites that it copies content from – so it’s probably nothing for me to worry about.

With that, I do think it’s a bit unethical what Sutocom are doing (reblogging content, and asking for donations) so I’ve reported it to WordPress as a spam site – we’ll see what happens.

Apache Serving Blank Screen – even in CF Admin

Apache has started doing this; a blank screen. A restart of tomcat seems to fix it, but this cannot be the answer, especially when it’s only just started, AND it’s not like it is poor code; the error occurs even in ColdFusion administrator.

apache timeout.PNG

A quick check in the Apache logs (C:\Program Files\Apache Software Foundation\Tomcat 6.0\logs) shows the following error:

Mar 27, 2014 9:40:47 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet CfmServlet threw exception
     java.lang.OutOfMemoryError: PermGen space
          at java.lang.Throwable.printStackTrace(Throwable.java:643)
          at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:100)
          at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
          at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
          at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
          at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)

This is either caused by a memory leak, or the PermGen space is just too small for what I genuinely need. I’m thinking that it might just be too small for the size of application I am running, as it is quite a large application, and the last time this happened, it was on the first deploy of another large application (albeit both times I was in CF Admin to configure the setup). So, it could be a memory leak in CF Admin (which I doubt), a memory leak in the application CF (very possible if someone has been sloppy with “var scoping”), or a larger PermGen space needed (possible from deploying a large application).

Forcing Garbage Cleanup

To check if the problem was memory related inside Tomcat (which looks likely), I first enabled “Class Unloading” inside Tomcat, so that unused classes were free to delete in memory. This isn’t an ideal or long term solution however; for one thing, it increases processing time as classes have to be recreated as they are called, but this is a useful test nonetheless – especially when exploring an application for a memory leak:

  1. Open “Tomcat Properties”: Open C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Apache Tomcat 6.0 Tomcat6/ “Configure Tomcat”. This runs Tomcat6w.exe with additional arguments.

  2. Stop Tomcat: Click on the “General” tab, click on “Stop”. Check the task manager for when the service has stopped. This can take a while sometimes, as much as 15 minutes waiting for the service to stop. If Tomcat hangs with “Stopping” status, read this post to kill it.

  3. Update Java Options: Click on the “Java” tab, and add the following arguments to the bottom of the Java Options box:
    -XX:+CMSClassUnloadingEnabled
    -XX:+CMSPermGenSweepingEnabled
    Apache Java Memory Cleanup

  4. Restart Tomcat

This worked for me, both the application and ColdFusion Administrator are running well now – proving that the problem is a memory issue (no surprise there really).

Using Memory Limits

I could leave the server running as is, but class unloading slows down an application, and it won’t tell me if there’s a memory leak in the application. If there IS a memory leak, this would eventually manifest itself on the production server too – so I would rather know about a memory leak now, than later. Think of it like a car that is running rich, and burning to much fuel; putting in more fuel keeps the car running, but this does not fix the problem, only hides it. The car is using far more fuel than it should, and eventually we will run out of money to fuel the car – so its best to fix the engine.

To use the memory limits (either increasing or decreasing), follow these steps:

  1. Open “Tomcat Properties”: Open C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Apache Tomcat 6.0 Tomcat6/ “Configure Tomcat”. This runs Tomcat6w.exe with additional arguments.
  2. Stop Tomcat: Click on the “General” tab, click on “Stop”. Check the task manager for when the service has stopped. This can take a while sometimes, as much as 15 minutes waiting for the service to stop. If Tomcat hangs with “Stopping” status, read this post to kill it.

  3. Update Java Options: Click on the “Java” tab, remove the arguments added for garbage cleanup, and add the following arguments to the bottom of the Java Options box:
    -XX:MaxPermSize=128m” (set the 128 to whatever you want)

  4. Restart the Server

It’s working for me, for now at least – but if ColdFusion Admin or my application breaks down again, then it is possible that there is a memory leak somewhere. I could increase the memory again further (if it is genuinely needed) but I would need justification to think that it needs the extra memory. To be honest, I would probably check for issues in the code before I increased the memory again.

 

 

Apache Tomcat "Stopping"

Apache Tomcat service “Stopping”

Apache takes a silly amount of time to stop its service. It’s not something I need to do often, but when I do, the Tomcat service seems to hang in a status of “Stopping” for at least 10 minutes.

I have no idea why it does this, but I haven’t the enthusiasm to explore. You could restart your machine if you like, but sometimes this is not possible or ideal (especially if on a production server).

A quick way around it that I am recording for my own benefit mostly:

  1. Open Task Manager: [ctrl] + [alt] + [delete], then click “Task Manager” then click on the “Services” tab.
  2. Find your Tomcat service: In the list of services, find the name of the Apache Tomcat service with a status of “Stopping”. Make a note of this service name (not case sensitive).
  3. Run the Command Prompt: Open the “Start” menu, type “cmd”, then right-click on the “Command Prompt” and click “Run as administrator”.
  4. Check the Service Status: Enter the command “sc queryex Tomcat6” into the command prompt (replace “Tomcat6” with the name of your tomcat service as shown in step 2)
    force_stop_apacheIt should then present you with the status of that service, including the process ID (PID).
  5. Kill the service: Enter the following command “taskkill /PID 2248 /F” where “2248” is the PID as found in step 4. Note: you need the “/f” argument to “force” the task to be killed.
  6. Success: You should get the confirmation message “SUCCESS: The process with PID 2248 has been terminated”

 

ColdFusion “Cannot access java.rmi.RemoteException bad class file”

Opting for a “custom install” of CF9 on Tomcat (rather than CF10) still throws up the occasional obstacle; the latest being the following error:

coldfusion.jsp.CompilationFailedException:
Errors reported by Java compiler: C:\workspace\WEB-INF\cfusion\stubs\WS-326788660\
  coldfusion\xml\rpc\CFCInvocationException.java:10: cannot access java.rmi.RemoteException
  bad class file: C:\Program Files\Java\jre7\lib\rt.jar(java/rmi/RemoteException.class)
  class file has wrong version 51.0, should be 48.0 Please remove or make sure it appears in
  the correct subdirectory of the classpath. public class CFCInvocationException extends
  org.apache.axis.AxisFault implements java.io.Serializable { ^ 1 error


So clearly, there’s some conflict with the java class versions. I’m currently running the latest version of the Java JDK (1.7), but according to Adobe, CF9 ships with 1.6 by default, so likely the problem is here. I’m wondering if I am seeing this problem now, because the CF9 hotfix doesn’t work on Win 8.1, and that this hotfix included an upgrade for CF9 to work on Java 7?

Anyway – my first thought was to simply add the “Java_home” to the system path (via “This PC” > “Properties” > “Advanced System Settings” > “Environment Variables”), and restart, but no such luck. However….

To fix the problem is simple; update “tools.jar” with the latest from your SDK…

  1. Stop Apache Tomcat (or whichever server you’re running)
  2. Create a backup “C:\workspace\WEB-INF\cfusion\lib\tools.jar” (or wherever you CF is configured)
  3. Browse to “C:\Program Files\Java\jdk1.7.0_51\lib” (or wherever your JDK is) and copy “tools.jar” to clipboard.
  4. Go back to “C:\workspace\WEB-INF\cfusion\lib” and paste “tools.jar” from clipboard
  5. Restart Tomcat, and hey presto – it now works.