Monday, 26 May 2014

Eclipse: Maven m2eclipse shows 'Missing plugin' but JAR file is present and project builds

In my Eclipse Kepler installation, Maven plugin m2eclipse reported a missing dependency artefact, but I could see that the parent project had been built, the JAR in question was visible in my local Maven repository but somehow Eclipse 'couldn't see it'.

I tried a lot of different things to get the problem fixed, but Eclipse also built the project without any errors, so in the end it seemed like some kind of bug or 'feature' in the Maven Eclipse plugin that was causing this.

The solution (for me) turned out to be as follows:

  1. Right click on the project in Eclipse and choose Maven > Disable Maven Nature. This changes the \.settings\org.eclipse.m2e.core.prefs to show resolveWorkspaceProjects=false.
  2. The error disappeared from Eclipse.
  3. Delete the project from Eclipse.
  4. Change the file \.settings\org.eclipse.m2e.core.prefs to show resolveWorkspaceProjects=true.
  5. Import the Maven project again to Eclipse.
I'm still not sure what the actual issue was, but I'm pretty sure that in my case, there was no other way to resolve this one.

I was able to reproduce this same issue in other projects, and the fix above cleared the issue.

Tuesday, 12 November 2013

Sudden fatal issues with .NET Framework 4 - "Faulting module name: clr.dll" - FIXED

One of the applications I built and deployed some time ago had been ticking over nicely for months, when suddenly the users reported that they were no longer able to access the application.

When trying to access it, they were getting 'Page cannot be displayed' errors - which meant their request was not even getting as far as starting their session in the application.

After rooting around, trying various things in IIS to no avail, I finally identified a Microsoft Hotfix which did the trick. Having cleared out the application logs in Event Viewer, I could see that the .NET framework was throwing errors in clr.dll.

Information on the Hotfix (and details of the specific errors which showed in the Event Viewer) available from this link:
http://support.microsoft.com/kb/2640103

However, you can't actually download the hotfix directly from there - I think because Microsoft are trying to encourage you to carefully review your situation versus their described issue, and for you to be extra cautious about installing it.

I decided that this hotfix had to be the only option I could take, other than trying to get some tailored (and expensive) support from Microsoft by supplying them with a dump of the logs etc, and I eventually found that the hotfix can be directly requested using this URL (for some reason I had to access the site using Google Chrome since IE was throwing JavaScript errors):
http://support.microsoft.com/hotfix/KBHotfix.aspx?kbnum=2640103

Within 5 minutes, the link to the hotfix had arrived in my email and I was able to download and install it.

It's worth noting that I stopped IIS (net stop w3svc) before applying the hotfix, which meant that I did not need to restart the remote server.

Now, the application seems to be back to normal. Well, let's see what the users tell me tomorrow.

Note: As usual, I have to declare myself free of blame if you install this hotfix and it doesn't work or causes any issues for you! :)

Tuesday, 30 April 2013

FIXED: iPhone 5 with iOS6 keeps dropping Wi-Fi connection

My iPhone 5 keeps dropping its wi-fi connection, showing up with the Log In page and a weird HTTP 404 error at Apple.com.

This fixed it:
http://forums.macrumors.com/showpost.php?p=15759186&postcount=177

Wednesday, 30 January 2013

Flex: Add or subtract days from date

It's been a long time since I've posted anything! Possibly because I haven't been doing much development recently :(

Anyway I needed to be able to subtract a day from today's date in Flex, so that I could default one DatePicker field to today and a second DatePicker to yesterday's date.

Turns out it's pretty easy.

Today's date:
<pre class="brush: html">
<mx:DateField id="endDate" width="150" formatString="MM/DD/YYYY" showToday="true" styleName="Date" yearNavigationEnabled="true" editable="true" selectedDate="{new Date()}"/>
</pre>


Yesterday:
<pre class="brush: html">
<mx:DateField id="startDate" width="150" formatString="MM/DD/YYYY" showToday="true" styleName="Date" yearNavigationEnabled="true" editable="true" selectedDate="{DateUtils.addDays(new Date(),-1)}"/>
</pre>

In my project, DateUtils refers to org.as3commons.lang.DateUtils



Wednesday, 5 September 2012

Update: HTC Desire HD turns itself off, hope for nice new phones

An update to my original post concerning random rebooting of the HTC Desire HD.

Even after an update was applied to the phone over the air, I found that it would regularly reboot itself even when I'd left it unattended.

The answer turned out to be that the SIM card was gradually loosening from its slot, which I think was the original root cause of the phone rebooting unexpectedly (I thought this was something to do with the Alarm Clock, but it seems that was more of a symptom than a cause).

I taped my SIM card down inside the phone so that it couldn't budge from its slot, and it has never rebooted itself again.

That's the good news. The bad news is that the phone is badly playing up these days. When I call other people it randomly puts them on hold and dials other people's numbers, and more often than not it will just terminate the call without warning.

So I think it's almost time to lay the ol' HTC Desire HD down to rest. It will be interesting to see what comes of the Apple, Nokia (not so much) and other phone launches. 

When they announce the iPhone 5 (seems like it will actually happen this time!), I hope that the new version of iOS includes proper 'Android-esque' widget functionality - for me this will make or break my decision to buy an iPhone. 

So come on Apple, make your OS properly content-centric - not just a bunch of brightly coloured icons.

Monday, 3 September 2012

SQL Server: Split delimited string to table variable

In one of my projects I had to split a string which held a list of names delimited by the forwardslash '/' character into a proper table structure, so that the values could be used in a relational format.

I tried a few things including putting a bunch of PATINDEX type commands together, until I found a solution which works (it may not be particularly scalable). This also trims whitespace from either side of the delimiter in case they aren't evenly spaced:



IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fnSplitDelimitedString]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
 DROP FUNCTION [dbo].[fnSplitDelimitedString]
GO

CREATE FUNCTION fnSplitDelimitedString (@list nvarchar(MAX),@delimiter VARCHAR(1))
   RETURNS @tbl TABLE (name varchar(255) NOT NULL) AS
BEGIN
   DECLARE @pos        int,
           @nextpos    int,
           @valuelen   int

   SELECT @pos = 0, @nextpos = 1

   WHILE @nextpos > 0
   BEGIN
      SELECT @nextpos = charindex(@delimiter , @list, @pos + 1)
      SELECT @valuelen = CASE WHEN @nextpos > 0
                              THEN @nextpos
                              ELSE len(@list) + 1
                         END - @pos - 1
      INSERT @tbl (name)
         VALUES (convert(varchar(255), ltrim(rtrim(substring(@list, @pos + 1, @valuelen)))))
      SELECT @pos = @nextpos
   END
   RETURN
END

SELECT name FROM fnSplitDelimitedString('Gerry Smith /   Tom Martin / Michael Green/Rohil Sen/Dominic Davidson/Richard Wilson','/') as Split 


You can pass in your own delimiter (comma, semicolon etc), and the function returns a table in this format which is a whole lot more useful:


Name
Gerry Smith
Tom Martin
Michael Green
Rohil Sen
Dominic Davidson
Richard Wilson

I found this solution on a blog post by Erland Sommarskog which has a lot more potential solutions. If the solution I posted doesn't work for you and you need something which will scale up, try reading his detailed write-up.

This solution was tried and tested on SQL Server 2005.

Tuesday, 28 August 2012

Blackberry Deleted Emails Do Not Synchronize with Mailbox

It was annoying me that when I delete an email on BlackBerry, it didn't delete it in Outlook. So when I got to the office there were still lists of crap emails I didn't want.

Here's the fix (I nicked this from another blog):

Problem Description: This article describes where to change the setting to force emails deleted on the Blackberry to Synchronize with Outlook. When the user deletes an email on their Blackberry handheld device, it does not automatically delete the email in Outlook.

Troubleshooting Steps/ Resolution: By default, the Blackberry is set to not Synchronize any emails deleted on the Blackberry with the users mailbox. A setting must be set to force any e-mail deletions done on the handheld to also delete in Outlook. This setting can be found in the following:

  1. On the Blackberry device, go into the mail (the icon looks like three envelopes). 
  2. Single click the trackwheel to display the menu 
  3. Select Options 
  4. At the bottom of the 'Message List Options', under the 'Email' subheader, highlight 'Handheld' next to 'Delete On:' 
  5. Single click the trackwheel and choose 'Change Option'

Select one of the following options:

'Handheld' - deletes the e-mail on the handheld only
'Mailbox & Handheld'- deletes the email on the handheld as well as in Outlook 'Prompt'- Prompts the user to choose whether they want the email deleted in their Mailbox each time they delete an email on the Blackberry.

Click the trackwheel once and choose 'Save' to save your settings.

Monday, 23 April 2012

ASP.NET: AJAX Combo Box Item List placement problem - CSS Hacks

Occasionally, I like to use the ComboBox control from the Ajax Control Tookit. I hadn't used it for quite a while and added one to a recent project - one which I need to work in Chrome, Firefox and IE.
But the issue was that the ComboBox's item list would appear in a random place on the page, about 150 pixels away from the text box. No good.
It seems to be related to my use of Master pages but I couldn't find a solution which worked, so I decided (reluctantly) to hack the CSS. On my ComboBox control I have the CssClass set to 'CustomComboBoxStyle' and in my CSS I have a default selector for Chrome, then a hack for Firefox, followed by a second hack for IE 8 and 9 (if you're on any version of IE below 8, I don't care about you). The CSS ended up looking like this:

CSS
/* AJAX Combo Box Styles - HACKS here for item list */
.CustomComboBoxStyle table {margin-bottom:3px!important; top:0px!important;}
.CustomComboBoxStyle {position:relative;} 
.CustomComboBoxStyle ul { 
    position:absolute ! important; 
    left:2px ! important; 
    }
    
/* Chrome - default */
.CustomComboBoxStyle ul 
{
    top:2px ! important;    
}
/* Firefox */ 
@-moz-document url-prefix() {
        .CustomComboBoxStyle ul {
        top:22px ! important;
    }
}
/* IE 8 + 9 */
.CustomComboBoxStyle ul 
{
    top:15px \0/ !important;    
}

Markup
<asp:ComboBox ID="cmbCity" runat="server" 
    AutoPostBack="False" 
    DropDownStyle="DropDownList" 
    AutoCompleteMode="SuggestAppend" 
    CaseSensitive="False"  
    ItemInsertLocation="Append" CssClass="CustomComboBoxStyle"  >
    <asp:ListItem Value=""> -- Select city -- </asp:ListItem>
    <asp:ListItem Value="Aberdeen"></asp:ListItem>
    <asp:ListItem Value="Dundee"></asp:ListItem>
    <asp:ListItem Value="Edinburgh"></asp:ListItem>
    <asp:ListItem Value="Glasgow"></asp:ListItem>
    <asp:ListItem Value="Paisley"></asp:ListItem>
    <asp:ListItem Value="Perth"></asp:ListItem>
    <asp:ListItem Value="Stirling"></asp:ListItem>
</asp:ComboBox>

In my solution, this worked (with pangs of guilt at such hackery). I absolutely do not guarantee or even assert that it will work for you, but it could be worth a shot. 

Monday, 16 April 2012

HP N40L Windows Home Server 2011: Mount Linux EXT2 drive and clone disk

Realising that I needed a home server to keep all my files on and run IIS, SQL Server etc, I recently upgraded from my D-Link DNS-320 to an HP N40L Microserver.

Of course, I needed to copy my files from the DNS-320 (Linux) to the N40L (Windows) and didn't fancy leaving it to copy the files over the network and I couldn't get Windows to mount the drive (when you put the Linux formatted disk into the N40L, Windows can see the physical disk but can't mount it as a drive with a letter etc).

So after rooting around a bit for solutions regarding mounting Linux EXT2/EXT3 drives in Windows, I found EXT2 File System driver on SourceForge and installed it (version 0.51). Then I put the drive from the DNS-320 into the new server and booted it up.

Note that the main solution which tends to come up is EXT2 IFS, which at the time of writing wasn't compatible with WHS 2011 (though it works with Windows 2008). So that was of no use to me but if you're running a supported version of Windows it may be of use to you.

Back to the problem in hand; when I ran the EXT2 volume manager I was able to mount the drives in Windows and use SyncToy to clone one disk to another - since the intention is to copy the data off the Linux drive and then once done, format with NTFS.

It worked nicely for me, and I hope this info is of use to someone!

Monday, 12 March 2012

Come on Apple, get your Googles on and see the need for widgets!

I am tired of Android.

I find it to have generally poor implementation in a lot of apps, poor usability and half-hearted attempts to Apple-ify the user experience. There have been vast improvements in the past few months, but it's still lacking.

After I'd had my iPhone 3GS for 18 months I genuinely wanted to give Android a chance, not only because I was tired of the locked-down iOS ecosystem, but because I thought maybe it was a viable alternative for the fairly serious phone user.

Having owned an Android phone in the form of an HTC Desire HD for over a year, I am on the verge of returning to Apple via iPhone, iPad and my next computer will be a MacBook.

In my opinion, Android is the PC of phones and tablets. It's just not quite there. There's no 'ooh-ahh', in the experience - just mediocrity. I want a tablet for home and travel, but I wouldn't consider an Android tablet for a minute - not even with the knocked down prices we're seeing at the moment. I'm intrigued by Windows 8, but it's too long away.

Now to the point - my only sticking point with my return to iOS is homescreen widgets.

The best thing about Android is the great widgets you can add to your homescreen. Instantly accessible and useful information, quick shortcuts to the information you need, and general interest. Every section of my homescreen is rammed full of something I find useful.

Compare that to iOS' sweety box of colourful icons which mean virtually nothing. You can see which apps you have to launch as well as a few basic pieces of information, but nothing particularly useful to you at a glance. I really wish Apple would realise that they need to add user widgets to the iOS homescreen - the lack of widgets was one of the reasons I plumped for Android 12 months ago and it's the only thing which somewhat puts me off buying Apple iOS devices.

If I think that, then I very much doubt I'm alone.

Sort it out Apple - you may have queues out the door and up to the distant horizon when you launch a new product, but that queue could be a few people longer if you do the right thing and add widgets to iOS.

Saturday, 10 March 2012

Dell laptop: HDMI output has black border

When I upgraded to WIndows 7, my Dell Studio 17 suddenly lost the ability to display 1920x1200 (1080p) in full screen mode, either on the laptop display or my Philips 24 inch monitor.

I couldn't find any answer to it within the Windows display settings or control panel, and after a long time rooting around on Google and trying various things, I discovered I needed to:

a) Download the latest Catalyst drivers and control suite.
b) Once installed, use the 'scaling options' to adjust the size of the output display to 'match my flat panel'.

Finally! Back to a usable full screen without having to compromise on resolution.

Wednesday, 1 February 2012

Solved: DNS-320 P2P folder disappeared

I upgraded the firmware on my D-Link ShareCenter Pulse DNS-320 to version 2.02, and suddenly the P2P folder disappeared.

I thought everything had been deleted, but it continued to download torrent files - where was it saving them to?

Turns out that the new firmware changes the way your P2P folder is shared on your network, and that all you need to do is disable and then re-enable the P2P service using the web interface.

Back to normal!

Tuesday, 17 January 2012

Solved: Visual Studio 2010: ASP.NET project - can't add web reference

I hadn't worked on a project for a while (since upgrading to Visual Studio 2010), and I needed to add a web reference to get it to compile. The normal method is just to right-click on your project name in Solution Explorer and click Add Web Reference.

But I had no option to Add Web Reference, only an option to 'Add Service Reference' which seems to be designed for WCF references.

It's a legacy project though, so I needed to add the reference in the legacy format - adding a service reference creates different components in your project than a web reference.

I got round it by:

1. Change the target framework to .NET 2.0
2. Close and reopen the solution - you should see the option to Add Web Reference.
3. Add the web reference.
4. Change the target framework back to whatever you had before.
5. Close and reopen the project.
6. Continue upon your way.

This might not work for everyone since I don't really know why the option to add web reference disappeared in the first place - but it worked for me.

Friday, 16 December 2011

Lots of screens? Lots of windows? WindowPad!

I use three screens for work, and I usually have about 12-15 windows open at once. I'm also a bit precious about the window sizes and positions of the things I'm working with - especially when using Visual Studio or another tool with a lot of dockable windows.

I hate having to drag windows about and manually resize them. Enter WindowPad!

It's a little utility which consists of an executable file and an ini file for configuration - you just put it in your Startup folder to use.

WindowPad uses a virtual "pad" to arrange windows, where you can use the Numpad to move and resize windows to fill the appropriate sections of your screens.

Features include:
- Move windows within the current monitor or between monitors (in multi-monitor setups).
- Customize hotkeys via WindowPad.ini with AutoHotkey-like command syntax.
- Define custom commands as labels or functions in WindowPad.ahk.
- Execute WindowPad commands specified on the command-line.

This is one of the tools mentioned in my .NET tools post, but it's the best utility I've discovered in a long time.

Friday, 9 December 2011

Power tools every .NET developer should have

Working every day within a Windows environment, you get used to your own specific way of customising your workspace.

I'm always on the look out for ways to make my laziness less of an issue by being able to do common tasks more quickly, and Scott Hanselman's Ultimate Developer and Power Users Tool List for Windows is brilliant.

There are some really useful applications on there and in particular I liked WindowPad because it helps you to quickly arrange the various Visual Studio windows on your screens rather than having to drag and resize constantly.

Wednesday, 23 November 2011

Visual Studio: Selecting which browser to debug with

I love Google Chrome. It's fast to start up, fast to render pages, it knows how to use CSS and it's just generally excellent.

I'm less keen on IE though. However, since it's the most popular browser that's the one I tend to debug my web applications with. But Visual Studio kept launching Chrome instead of IE - turns out it's a simple fix:

1) Right click on a .aspx page in your solution explorer
2) Select the "browse with" context menu option
3) In the dialog you can select or add a browser. For example, if you want Firefox in the list click "add" and point to the firefox.exe filename
4) Click the "Set as Default" button to select the default browser when you run any page on the site.

Works. Life made easier.

Solution bumped from Stackoverflow.

P.S.: If you don't see a 'Browse with' option - check you're not debugging already! Stop debugging and the option will appear.

Tuesday, 30 August 2011

Windows Remote Desktop: The terminal server has exceeded maximum number of allowed connection, mstsc

I kept getting the dreaded 'The terminal server has exceeded maximum number of allowed connection' when attempting to log onto a remote server. I must've forgotten to log out and just clicked close on the mstsc session!

The answer:

You can start a control session to the server and logoff your other connections. Please always use "LogOff" when you leave remote desktop.

Open Command Prompt.
Type: "mstsc /admin".
Remote Desktop Connection will start. Type the computer name or IP address of the computer you want to connect to in the Computer box.
Configure any other desired options, and then click Connect.

Solution from the page at this link

Thursday, 11 August 2011

ASP.NET: Scrollable GridView with Fixed Headers: jQuery

Sometimes I find that it's almost impossible to achieve something which should really be incredibly straightforward. Maybe it's because I'm an idiot, or maybe it's because Microsoft have missed a trick.

In this case, I needed to be able to freeze the colum headers of a GridView and make it vertically scrollable. I tried about a dozen different methods, from pure CSS to various JavaScript hacks, and even attempting to do it server-side to try to ensure browser compatibility. I won't link to any of the solutions I tried except one, since only one of them actually worked.

As usual, it was jQuery to the rescue. A simple plugin which you can use to freeze the column headers and add a vertical scrollbar, and with minimal effort. It works as tested in Firefox 3, Chrome and Internet Explorer 8 - though sometimes the column headers are a couple of pixels out of line here or there.

Anyway, there's a nice article describing how to use it on ASP Snippets.

The only drawback I found was that I couldn't really get it to behave properly when the window was resized - but I suspect that was my poor implementation of the plugin rather than a fault with the jQuery code itself.

In conclusion: Microsoft: Get your act together and make this a feature that can be enabled via a property.


Sunday, 31 July 2011

Atlassian JIRA Startup Failed: Configuring JIRA to access SQL Server 2008 Express R2

I recently upgraded my SQL Server 2008 Express Edition with Advanced Services to R2, and found that my JIRA installation stopped working (received Tomcat 404 errors).

I tried everything, but could not get it to work - I kept getting 'connection refused' errors in the JIRA logs. I hadn't modified my server.xml configuration since the upgrade, and I checked that the protocols in SQL Server Configuration Manager were enabled on Port 1433.

Something wasn't right - even with the same configuration as before I just could not get JIRA to start.

Eventually, I found the answer which worked for me:

  • Run config.bat in the /bin folder of the JIRA installation folder.
  • Click the Database Tab:
  • Database type: SQL Server
  • Hostname: localhost (Or your server name. Note: NOT "localhost\SQLExpress")
  • Port: 49374 (Find this value in your registry, in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\SQLEXPRESS\MSSQLServer\SuperSocketNetLib\Tcp for your SQL instance name. i.e. SQLEXPRESS. You can edit your registry by typing 'regedit' at the command line.)
  • Database: jiradb
  • Username: jirauser
  • Password: *****
  • Schema: jiraschema
  • Connection Pool: 20
  • Click Test Connection.
Hopefully the utility will return 'Connection successful.'. Restart the Atlassian JIRA service and you should find that you are able to access your JIRA installation.

Worked for me - I'm not sure why I needed to do this for R2.

More info in the comments attached to this forum post.

Thursday, 21 July 2011

SQL Server: Columns truncated to 255 characters when using OPENROWSET or OPENDATASOURCE to import from Excel

I was using the SQL command OPENROWSET to directly import a load of text from an Excel spreadsheet to my database. The columns were of varying widths, some up to 3,000 characters.

The problem I experienced was that for some columns the output of the statement was being truncated to 255 characters - but not for all of them. I couldn't understand why this would happen and tried various combinations of OPENROWSET and OPENDATASOURCE, but to no avail.


sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO

INSERT INTO tblRichTextFields (Requester,feet,approval)
SELECT * FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0','Data Source="C:\RichtextFields.xls";Extended Properties=''Excel 12.0''')...[Sheet1$]

GO

sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 0
GO
RECONFIGURE
GO
sp_configure 'show advanced options', 0
GO
RECONFIGURE
GO


The only thing I could think of was that it was something to do with the Excel cell formats. I compared the columns which were being truncated to the column which was not, but they were the same. I tried changing them all to Text to see if that made any difference. Still truncated.

I couldn't find much more on Google, nor in my brain - but eventually I did find a fix which proved me right - it was some underhanded 'guesswork' on Microsoft's part - surprise, surprise. See this quote:

"Your data may be truncated to 255 characters if the first 8 records for the field(s) being truncated contain 255 or fewer characters. The Microsoft Excel ODBC driver will, by default, scan the first 8 rows of your data to determine the type of data in each column."

I changed the Registry Setting which controls the 'Excel format guessing' behaviour from 'on' to 'off', logged out and back in - and Hey Presto! it worked.

Setting:
HKEY_LOCAL_MACHINE\SOFTWARE\Mi­­crosoft\Jet\4.0\Engines\Excel­\­TypeGuessRows

Change the value from 8 hex to 0

I don't think this fix will work in every situation and I haven't considered every possible implication of changing this registry setting, but if your text is being truncated like this - this is worth a try. Take a backup of your registry before changing it and it's not my fault if you Michael Berk it up!

Here's some detailed info on the Microsoft website.