Error when stopping Tomcat 6 on Ubuntu 9.10

I recently installed Tomcat 6 on Ubuntu 9.10 and when trying to stop the tomcat server, I was receiving an error.

I was issuing the statement

sudo ./shutdown.sh 

and received an error, including:

Catalina.stop: java.io.FileNotFoundException: /usr/share/tomcat6/conf/server.xml

To get around this, I used a different command to stop and start the server:

$ sudo service tomcat6 stop

$ sudo service tomcat6 start

Hope others find this useful.

asp.net mvc IIS 7 404 erro

If you are having issue getting an asp.net MVC web site running on a server with IIS 7 you should check your web.config settings.  I tried a variety of things, searched around the net, and finally found what I was looking for.

After some trial and error, I found that in order for things to work in IIS7 you need the below entries in your web.config, in the system.Webserver section within modules and handlers (leave other items that may already be there). 

<modules runAllManagedModulesForAllRequests="true" >
                <remove name="UrlRoutingModule"/>
                <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            </modules>
            <handlers>
                <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            </handlers>

 

I found the below articles to be very helpful in troubleshooting the issue I was having.

 

 http://chriscavanagh.wordpress.com/2008/03/11/aspnet-routing-goodbye-url-rewriting/

 

disqus update_thread HTTP method for this call must be POST

Recently I was trying to work with the Disqus comment system's API (version 1.1) and when trying to update infomation via the API, I kepy receiving:

 HTTP method for this call must be POST

In order to no longer recieve the error, I modified the URL I was posting to to end with a "/", for example:

http://disqus.com/api/update_thread/

That fixed the issue...

 

 

SQL Server Protocol error in TDS stream Communication link failure TCP Provider: An existing connection was forcibly closed by the remote host

Recently ran into an issue with long running sql queries that used TCP to communicate between different SQL Server servers.  We sporatically noticed the below errors and SQL job failures for jobs that ran long running sql queries.

Error: 2009-09-28 08:43:40.62     Code: 0xC0202009     Source:      Description: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Protocol error in TDS stream".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Communication link failure".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "TCP Provider: An existing connection was forcibly closed by the remote host.  ".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Communication link failure".  An OLE DB record is ...  The package execution fa...  The step failed.

After some research, the below KB article outlines that TCP Chimney may be the cause.  Turns out, TCP Chimney may require an update the your NIC drivers.  

http://support.microsoft.com/kb/945977

We have not had the chance to upgrade our drivers, but we did disable TCP Chimney and that eliminated the error. To disable, issue the below statement at the command prompt (does not require a restart):

Netsh int ip set chimney DISABLED;

Need a developer, architect or manager? I am available - email me at [email protected]

.NET how to set the background color of a bitmap

I was struggling with this for a while...how to set the background of a bitmap.  I read a few suggestions, but none worked for me. 

My need was to set the background of the image to white, crop it, with the end result that after cropping, the background be set to white.

To do this, I used the Clear method on the Graphics class...essentially this sets the background.

 

Graphics grPhoto = Graphics.FromImage(bmpImage);

grPhoto.Clear(Color.White);

grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;

grPhoto.DrawImage(imgPhoto,
                new Rectangle(destX, destY, destWidth, destHeight),
                new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
                GraphicsUnit.Pixel);

            grPhoto.Dispose();

System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to

We were gettign an error with one of our WCF services "System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to..." and needed to get additional information on the problem.  Below are steps to use the built in diagnostics with WCF to find out more info for the error above as well as the overall health of your service.

  1. Add to your web.config:

     <system.diagnostics>
        <sources>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
              <add name="messages"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData="D:\LogFiles\SalesOrderTrackingService\messages.svclog" />
            </listeners>
          </source>
        </sources>
      </system.diagnostics>

    <system.serviceModel>
        <diagnostics>
          <messageLogging
               logEntireMessage="true"
               logMalformedMessages="false"
               logMessagesAtServiceLevel="true"
               logMessagesAtTransportLevel="false"
               maxMessagesToLog="3000"
               maxSizeOfMessageToLog="2000"/>
        </diagnostics>
    ...
  2. Create the necessary folder and ensure the security is set so IIS/ASP.NET can write to the log file
  3. Use the SvcTraceViewer.exe application to view your log file

    This tool can be found in the SDK directory...for me, this was C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin

System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (400) Bad Request

Recently I had a WCF service call that was returning the error System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (400) Bad Request.

Looking into this, I discivered that the messages we were sending were increasing in size.  We were using the basic http binding and it turns out the default readerQuotas were too small and were causing the"Bad Request" error.

I increased the readerQuotas to the values below and that resolved the error.

 

<basicHttpBinding>
        ...
          <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000"
            maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />

       ...

SQL Server Full-Text search remove noise words

SQL Server full-text search filters out certain noise words by default.  If you want to include some of these noise words in your full text search, you will need to do the following.

  1. Locate the noise file for your language.  For English, this would be noiseENU.txt and is located in the SQL Server install directory.  For example C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\FTData (Your location may vary).  You can also use the following query to help determine the location:

    select * from sys.fulltext_catalogs

  2. Edit this file.  You can add or remove noise words/numbers, etc. from this file.

  3. The last thing you must do is rebuild the catalog (*Note, if you have a large catalog, do this off-hours as it will impact performance):

    ALTER FULLTEXT CATALOG YourCatalogNameHere
    REBUILD WITH ACCENT_SENSITIVITY = OFF
Now, the next time you run a full-text search, your changes will be factored in.

No Software

I continue to see a trend with most businesses to move away from the self hosted, home grown, monolithic applications and move more to service based software.  While there are some big and well know players, such as Salesforce.com, there are many smaller up and comers offering a wide array of software services that do not require any on site software or custom development.

One compnay in particular, Feed.Us offers a wonderful online content management system (CMS) that in addition to traditional content management, offers many value added services.  The real joy of this system is you can get up and running in minutes.  You can transform your static web site into a dynamic web application with little to no custom development.

I really recommend you check out all of the features they offer...

 

 

jQuery UI modal dialog focus issue

I noticed while using the jQuery UI modal dialog that if you have a link (or form element) within your HTML in the modal, the focus will be given to the first one.  If the element is further down on the modal, then it will scroll down, which is not the desired behavior.

To correct this, I simply added a link at the top of the modal and gave it focus:

 Place at top of modal HTML:

<a id="top" href="#" ></a>

In document ready, add focus to #top:

jQuery(document).ready(function() {

            // Tell jQuery that our div is to be a dialog
            jQuery("#dialogTOS").dialog({ autoOpen: false, height: 400, width: 900 });

            jQuery('#linkTOS').click(function() {
                jQuery('#dialogTOS').dialog('open'); 

               // Focus on top element
                jQuery('#top').focus();
            });

        });