Archive for the ‘Error messages’ Category

Clean URLs in Drupal with Apache and Tomcat

Tuesday, October 6th, 2009

I've just returned from the land of jar -xzf. I've installed a couple of new Drupal sites (details to follow). One of those sites takes over the whole domain. The other is just a subset. I ran into trouble with the infamous "Clean URLs" feature, and only found the solution after hours of fruitless Googling.

Drupal is a PHP content management system. In PHP, the URL addresses the program, and any parameters must be supplied in the query string. Drupal URLs therefore look something like this:

There are a few things we can do to make the URL prettier. First, we can configure the web server to serve index.php by default. Most web servers are initially configured to do just that, so the URL could be written like this:

That's better, but SEO is harmed by the question mark. So we turn on mod_rewrite to change that URL to this:

A tale of two sites
This was all well and good. I followed the directions found on blogs too numerous to mention for configuring mod_rewrite. These instructions worked fine for one of my sites, but not the other.

What's the difference? On the site that worked, Drupal was installed in a subdirectory. On the site that failed, Drupal was installed in the root. The problem has something to do with the lack of a subdirectory in the URL.

In the course of troubleshooting, I tried removing the "?=q" from various URLs. It worked for content pages, but failed for admin pages. So, I reasoned, the problem is with "/admin" as the top folder.

What was most telling is what happened when I entered a URL with just "/admin". The Tomcat administration page appeared. I have Tomcat installed on my server, but I'm not using it on the full Drupal site. Drupal is PHP, not Java, and this site has no other content. So why is Tomcat showing up?

My host (eApps) defines a default configuration for any new site I create. This configuration includes Tomcat, because I typically host Java applications rather than PHP applications. The configuration includes this line in httpd.conf (located in /etc/httpd/conf):

JkMount /admin* ajp13

This directs the "/admin" URL to Tomcat through mod_jk. I just removed this line from this site's configuration, and I was able to turn on clean URLs.

Every site is different. The solutions that you find on blogs (including this one) won't necessarily work for you. It is best to hone your troubleshooting skills and attack the problem systematically than to Google for the error message. I mean, what are the odds that your environment is exactly like mine?

No public TypeConverter class?

Monday, September 14th, 2009

I just saw this error message:

'IEnumerable' type does not have a public TypeConverter class.

It referred to the following XAML:

<ListBox Grid.Row="0" ItemsSource="Contracts">
            <TextBlock Text="{Binding Name}"/>

Do you see the problem? I forgot the {Binding} markup extension. Sometimes the solution does not fit the error message.

Disable smart quotes in WordPress without requiring www prefix

Tuesday, January 6th, 2009

If you've attempted to visit this site without using the "deprecated" www prefix since the beginning of the year, you probably noticed that it wasn't coming up. I hope you noticed, because I didn't until this morning.

On December 31, I got tired of WordPress messing with my source code and changing all of the quotes. So I found instructions from Peter Cooper on disabling that feature. I took his advice and added the line "<?php remove_filter('the_content', 'wptexturize'); ?>" to the bottom of functions.php. A quick test showed that it worked. Hurray! I can copy and paste source code!

Fast forward to today, when I tried typed in and got a blank page. worked, as did (the www. and /blog get added via redirect). So I go through my 5-step process: panic, research, try to fix, fail, and call for technical support. The folks at eApps pointed me in the right direction. They found this error message (which I had seen and disregarded, to my peril):

PHP Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wordpress/wp-content/themes/ais2/functions.php:399) in /var/www/html/wordpress/wp-includes/pluggable.php on line 390

The problem is that Word Press is trying to perform a redirect to put the www back into the URL. In doing so, it ran up against the output that functions.php had already performed. The first output causes the HTTP header to be written, making it impossible to perform the redirect.

Here's my solution
Before doing anything else, I deleted the line that I had added to functions.php and tried the site again. It was back to its no-www-necessary behavior. But the troublesome "smart" quotes were back.

So the challenge was to find a way to remove the wptexturize filter without bringing down the site. I dusted off grep and took a tour through the code. I found the places in default-filters.php where that filter was being added. So instead of removing it, I just deleted those add_filter lines.

And so now, thanks to the help of Peter Cooper and eApps, I have copyable code and no www necessary. Now if I could only get Word Press to stop putting the www back into the URL for me.

I found two places in the site options where I had www in front of the domain name. I fixed those, and now it redirects you away from www instead of toward it. So even that is fixed.

Using the generic type ‘System.Action<T>’ requires ‘1′ type arguments

Sunday, December 7th, 2008

The Action and Func delegates are brilliant -- if late -- additions to the .NET framework. A delegate is a method that can be passed as a parameter. They can be used anywhere that you could use an interface with only one method. But delegate syntax is lighter weight than interface syntax.

The type of a delegate is really nothing more than a function signature. But even though the syntax for declaring a delegate is simpler than the syntax for declaring an interface, it is still more complex than it needs to be. Like any other type, a delegate is given a name. But the name is not important, only the signature.

The Action and Func generic delegates were added to the .NET framework in 2.0, which was the first version of the framework to support generics. Using these generics, the signature of a delegate can be declared in line. No separate type needs to be declared, no name needs to be specified, and all information is visible via intellisense.

One problem, however, was that no Action could be specified taking no arguments and returning no value. At least not until .NET 3.5. My guess is that Microsoft left this out so that the compiler wouldn't get confused having a class and a generic with the same name. But .NET 3.5 includes a compiler upgrade (for features like Linq, extension methods, and many more), so they probably fixed this minor issue at the same time. I haven't taken the time to test this theory.

Regardless the reason, if you need an Action with no parameters and no return type, then you have to target .NET 3.5. If you ever get this error message, check your Target Framework setting in the project properties.

Can’t create an instance of a managed WMI provider

Thursday, August 28th, 2008

Current Status

Using the .NET WMI provider extensions 2.0, I cannot create an instance of my custom provider class.

Windows Management Interface (WMI) is a way to expose management and configuration components from your application to scripting and operations tools, like SMS and MOM. In the past, creating a WMI provider required the use of COM. The WMI provider extensions for .NET created the ability to expose read-only management objects. In .NET 3.5, this capability was enhanced to allow for writing properties and calling methods.

Using these extensions, I created a management class for my application. I am having trouble creating instances of this class from the WMI command line, or any of the other WMI tools that I've tried.

Here's the class:

using System.Management.Instrumentation;

namespace ConsoleDecoupled
    public class Activity
        private string _name;

        public Activity(string Name)
            _name = Name;

        public string Name
            get { return _name; }

Here's the program that publishes the class to WMI:

using System;
using System.Management.Instrumentation;

namespace ConsoleDecoupled
    class Program
        static void Main(string[] args)

            Activity instance = new Activity("foo");

            Console.WriteLine("Press enter to exit");


And here's what wmic does when I try to create an instance:

wmic:root\cli>path Activity create Name="fee"
Create instance of 'Activity' class (Y/N)?y
Code = 0x80041002
Description = Not found
Facility = WMI

I know that the class is found, because I can query for the instance that I created programmatically:

wmic:root\cli>path Activity where Name="foo"

My next plan of attack is to go through this article on Writing coupled WMI providers, and seeing if I run into similar problems.

NullReferenceException while using bean:write

Wednesday, July 2nd, 2008

Here's an obscure error that I fought for several hours today:

Jul 2, 2008 5:42:42 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
at org.apache.struts.taglib.TagUtils.retrieveMessageResources(
at org.apache.struts.taglib.TagUtils.message(
at org.apache.struts.taglib.TagUtils.message(
at org.apache.struts.taglib.bean.WriteTag.retrieveFormatString(
at org.apache.struts.taglib.bean.WriteTag.formatValue(
at org.apache.struts.taglib.bean.WriteTag.doStartTag(
.... (the rest is unimportant)

This was thrown by the following line in a JSP:

<bean:write name="report" property="exceptionReportId" />

The problem is that my method getExceptionReportId() returns an int. The struts bean tag library expects all properties to be Strings. So by changing my method to return a String and using Integer.toString, I made it happy.

This presents a real separation-of-concerns problem. A bean should be a dumb data container. It should give you back exactly what you put in, and it should preserve your data types. The restriction that all properties are strings puts formatting into the bean, and therefore makes it specific to the JSP page.

Is there a tag library that separates formatting concerns from beans?

[UPDATE: You can format non-String property values using the bean:write format attribute. For a date, for example, <bean:write name="report" property="reportDate" format="MM/dd/yyyy"/>. Furthermore, to fix the NullPointerException above, I just added an empty format attribute, as in <bean:write name="report" property="exceptionReportId" format="" />.]

The WordPress plot thickens

Thursday, March 27th, 2008

I've upgraded WordPress and I'm working on putting things back to normal.

In the process, I've discovered a few more side effects of the hack. It appears that the hacker uploaded a new header.php and footer.php to my active theme. I only noticed this because I had changed the theme and placed some important markup in the header. Without this markup, the page doesn't render correctly. If you are viewing this site on the evening of the 27th, you might just well be seeing the old theme while I work on fixing the new one.

The footer was modified to include hidden links to various link farm pages on a health and fitness podcast. The header was modified to include only one link, this to a blog run by someone by the name of Erik Kastner. I won't give you the links because ... well ... that's the point.

I've posted a comments on these blogs asking for help in figuring out this connection. I'll let you know the response.

Please see Erik's reply in the comments. My current working theory is that the hidden links in the footer -- obviously placed to improve SEO, not to gather direct links -- are the main payload of this attack. I suspect that the hidden link (Erik's link) in the header points to the next site that the attacker plans to compromise. This forwards the page rank and makes the payload on the next page more valuable. Erik's blog runs on WordPress as well, but his was patched.

So thanks, Erik. Let's hope that I get a quick response from the health and fitness podcast.

Forensic analysis of WordPress version change

Thursday, March 27th, 2008

It happened again. The db_version was reset to 1 this morning, causing the error message "Your database is out-of-date".

My forensic analysis turned up nothing. Whatever caused this also had the effect of disabling the Spam Karma plugin, so all of the comments posted thereafter were sitting in moderation. This gave me a good timestamp for the occurrence.

Since the version change disables the spam filter, I suspected an attack. Perhaps someone takes advantage of a WordPress bug to turn off the filter and then post a bunch of comment spam. So I checked the server log for any suspicious entries around the time of the earliest comment in moderation.

The earliest comment was at 22:56 GMT. My server is located in the -400 time zone, so I scanned the access log for 18:56. I can see a "POST /blog/wp-comments-post.php" at that time, so that is the first comment post with the spam filter turned off. Scrolling back to the previous post at 18:43, I have my window. The version change and disabling of Spam Karma occurred somewhere in there.

At 18:45, there are several POSTs to various suspicious URLs.

  • /blog/wp-admin/options.php
  • /blog/wp-admin/upload.php
  • /blog/wp-admin/inline-uploading.php?post=-1&action=upload
  • /blog/wp-admin/upload.php?style=inline&tab=upload&post_id=-1

Unfortunately, I cannot see the body of the HTTP POST from the access log, so I don't know exactly what was done. But it appears that someone used these entry points to change some options and upload a file called "ro8kfbsmag.txt". Googling this filename, I found that it is indeed an attack.

It looks like this vulnerability has been fixed. So the solution is to upgrade to the latest version of WordPress. I know what I'll be doing tonight!

Cheap Zyrtec
Tramadol Hcl
Phentermine No Prescription
Information credit report
Highest credit score
Shell credit card application
Eminem Ringtones
Phentermine Hcl
Online Cialis Jelly
Ipsec VPN
Buy Xenical
Information credit report
Alprazolam Online
Remind Ringtones
Repair credit score
Alltel Ringtones
Credit reports com
Chase redit card srevices
3 credit report
Cheap Casodex
Cheap Zithromax
Cheap Neurontin
Buy Elavil
Credit score ranges
Buy Aristocort
Free Ringtones
Disputing credit reports
Counseling credit card debt
Ativan Online
Commercial credit report
Debt consolidation credit cards
Credit report
Online Herbal Phentermine
Viagra Alternatives
Nokia Ringtones
Buy Synthroid
Buy Augmentin
Free Mp Ringtones
Check credit report
Credit score system
Cheap Lasix
Buy Levitra
Cheap Viagra Jelly
Credit score in
Cheap Cephalexin
Credit card offer
Cleaning up credit report
Free credit report scores
Buy Ultram
Cialis Dosage
Credit report monitoring service
Credit card deal maker
Buy Prevacid
Ativan Drug
Buy Obestat
Cialis Soft Tabs
Cheap Protonix
Cheap Viagra Soft Tabs
Linksys VPN
Online Zithromax

Your database is out-of-date

Monday, March 24th, 2008

For some reason, WordPress started throwing the error "Your database is out-of-date. Please upgrade." whenever I visited the admin console. I had not upgraded either the code or the database prior to getting this error. I have no clue what caused it.

So naturally, I Googled the error message and found many other people with the same problem. Some of these people received replies to their cries for help. The replies included such helpful tidbits as "so upgrade, already", to "reboot the server". Naturally, I tried them and none worked for me.

Since WordPress is written in PHP, the source code is entirely in the clear. This makes it possible for a typical software blogger like myself to debug the application and figure out what's wrong. I used PuTTY to log into my server and peruse the code and database to see what could be done. I thought this would make for gripping television, so I did it all while streaming.

Here's my solution
I found that a single value in the wp_options table had been changed. It should be 4772, but it was 1.

If you grep for the error message, you will find a comparison between get_option('db_version') and $wp_db_version. Further grepping will reveal that $wp_db_version is set in wp-includes/version.php and that get_option selects option_value from the wp_options table. Log into mysql and select * from wp_options where option_name='db_version' and you will find the culprit.

This solution is not for the weak of heart. If you are not familiar with mysql, please take some time to get comfortable with it before messing around with your own blog. You run the risk of seriously messing things up, especially if you forget your where clause!

If you are not familiar with PHP, however, not to worry. This fix does not require any changes to the WordPress PHP code. In fact, this exercise is a great way to learn.

So if you found this post by Googling your error message, watch the video clip, get your PuTTY ready, and fix it!

BTW, how did the value get changed? Not a clue. If it happens again, I'll investigate further. And I'll stream the process!

WSS 1, Perry 0

Friday, February 22nd, 2008

I like writing posts that end with "Here's my solution". This is not one of them. I'm just documenting this fight so that I can come back to it if I ever find a solution.

I have completed the HTML/CSS/Javascript on the Ken Burns effect. It looks pretty good. I even eliminated the flicker that I talked about previously. Now I'm trying to add this new view to my office SharePoint server.

I opened up SharePoint Designer to create my new view. I selected "File: New: Page: List View Pages: Document Library View Page Wizard". I selected the picture library to which I wanted to add the new view, and named it "kenburns.aspx".

Once my new view came up, I opened the drop-down from the top-left corner of the list view and changed the columns. I removed all of the columns and added Preview. These were the same steps I went through on my local VM. The idea being that I would add the Javascript to turn the table full of images into a slide show. Sure, a web part would be better, but I haven't taken the time to build it yet.

It starts to go wrong
Here is where the experience deviated from development. When I hit OK on this dialog, it went back to the designer and spun for a while. After a long timeout, it came back with the message "You do not have permission to do this operation." I checked my permissions and confirmed that, yes, I have full control of the entire site.

Going back and forth, I discovered that any change I make to the page causes this error. I can create pages, I just can't edit them afterward.

I started up Wireshark and inspected the traffic. I noticed that there were several duplicate ACKs followed by retries. So packets were getting dropped on the way back to the server. This is probably related to the VPN. I wanted to get this change up tonight, so I didn't have time to fight with the VPN.

So I got clever
I made small incremental changes to the page, but instead of saving it, I copied the contents into a local file, deleted the one I was working on, and then uploaded the copy. After each incremental change and upload, I verified with a browser that the change worked. Tedious, yes, but it worked around the problem.

At least it worked for a while. After a few iterations of this, I could no longer upload the file. Within SharePoint designer, I received the same "You do not have permission to do this operation" message as before. Based on the range of problems that I saw when Googling this phrase, I figured this is SharePoint Designer's way of throwing up it's hands. I even discovered that this error message is a hold over from FrontPage. It's been there a while.

I also tried uploading the file through Explorer. SharePoint does some WebDav magic that makes it possible to connect to a site using "My Network Places: Add Network Place." I navigated to the proper folder and dropped the local copy into it. After a long timeout, I was greeted with "Connection closed by remote server." This is more accurate based on what Wireshark was telling me, but no more helpful. I'm still back in VPN land.

Then I got desperate
I logged into the server via Remote Desktop, opened a command prompt, and executed "iisreset". No help. Then I restarted the box.

Let me pause right here and tell you that I knew at the time that this was a bad idea. I've felt that disconnected, sinking feeling many times before when the machine I'm working on is miles away, I have only a tenuous connection, and decide to let even that connection go. It's like being in a Spielberg movie when the background falls away while the main character is suspended mid-frame.

So I hit "Start: Shut down" (scary enough already) and "Restart". This being Windows Server 2003, I selected an excuse. The remote session was wrenched away from me. And then I waited. And waited.

(fall away and queue eerie violins)

The server still hasn't come back up. I've sent emails asking the next person to go to the office to restart the machine. I'll be in the office tomorrow afternoon, so you can bet I'm installing SharePoint Designer on the server!