Monday, February 25, 2013

Windows 7 : Windows event log error 4201

Today morning, I faced a new problem. When I tried to connect to my VPN, I got the following error:

"Could not start the Remote Access Connection Manager service on local computer. Error 1068. The dependency service or group failed to start."

That is simple. So I went to the Remote Access Connection Manager Service and found 2 dependencies : Telephony and SSL. Started both of them and tried to start the service again: Same Error !!

Hmm.. thats a problem. To know more details, I looked in to the Eventlog and now that too gave an error :

 The service has not started and when I tried to start the service I got the error :  Cannot start windows event log service on Windows 7. Error 4201.

Now that's a bigger problem. Something has gone real bad with my laptop. All the solutions pointed to deleting the "C:\Windows\System32\LogFiles\WMI\RtBackup" directory and to do so I need to go to Safe Mode. Now my company's laptop does not allow you to go to Safe Mode without a password. So what to do.


  1. Make a copy of the folder RtBackup - just to be safe.
  2. Take the ownership of the folder - From System to Yourself and reboot your computer
  3. Now that you are owner - you can delete the folder :)
  4. And yes post restart everything was back to normal.

Sunday, February 10, 2013

How to download videos in Opera

I have used Opera as my favorite browser for last 10 -12 years now (since its 6th version). I had always liked it for its tab support, being light weight and also being available in Linux (a browser with better fonts for those days). Internet Explorer was slow and Firefox in its earlier versions was good but got quickly gloated with extensions and addons. Chrome is way to heavy.

So the good and bad thing in Opera is that it does not have too many addons. Without them the browser was solid and light weight. Without them, its features were limited so was good for browsing but lacked some features readily available on others. One of the features was to download flash streaming videos. Firefox and Chrome, both have good extensions to support it. Opera did not have it readymade and and all its supposed extensions were links to some video donwloader site which I don't prefer So how to do it.

Yes there's a way. Opera is known for its excellent cache and I tried to use it. Lets take the example of dailymotion from which say I want to download a video. So here are the steps:
  1. First clear the cache (Setting :: Delete Private Data)  - It will help us clear the old data and knowing new URLs will be easy. Later you will almost remember them.
    Before I move ahead, let me explain how things are working for video sites. First say a site like www.dailymotion.com will use another site (CDN) to deliver it content. For dailymotion its dmcdn.net similarly for youtube its ytimg.com. Also now the whole video is not delivered as one big file to the client browser. Its broken in to fragments. So now if you pause a video, you can see the download stop after some time i.e. after the fragment ends. This was always the case with dailymotion. With youtube, the download did not stop earlier but now even they too have implemented it. Its more like dowload on demand. So when the player reaches the end of fragment one, it starts downloading the fragment two. So here we go.
  2. After the cache is cleared, type in "opera:cache" in your browser location bar. It should show the cache as empty.
  3. Open dailymotion.com and search for say "gangnam style"
  4. Don't open the video. In the "opera:cache" tab now you will see URL's being cached
  5. Now play the video and pause it after 10 seconds. Refresh the cache now. Select the 4 checkboxes for video and then click the Preview link next to dmcdn.net. It will open a new tab:
  6.  Play the video for another 30 seconds and refresh the Cached Video list for dmcdn.net. You will find more items getting listed there.
  7.  Now have a close look at the URLs. They look like:
    1. http://vid2.ak.dmcdn.net/sec(6f246bdc0f86287961fdadfc57ab38e2)/frag(1)/video/623/746/50647326_mp4_h264_aac.flv
    2. http://vid2.ak.dmcdn.net/sec(6f246bdc0f86287961fdadfc57ab38e2)/frag(6)/video/623/746/50647326_mp4_h264_aac.flv
    3. http://vid2.ak.dmcdn.net/sec(6f246bdc0f86287961fdadfc57ab38e2)/frag(4)/video/623/746/50647326_mp4_h264_aac.flv
  8.  From inspection, you can see that that the whole URL is same except for the frag(N) part.
  9.  So we now we have the URL of the whole video if we just remove the frag part. In the above case, it is : http://vid2.ak.dmcdn.net/sec(6f246bdc0f86287961fdadfc57ab38e2)/video/623/746/50647326_mp4_h264_aac.flv
  10. Open this link in a new tab and you can now save the video in you local disk.
Enjoy downloading videos. 

Hint: You can do the same in firefox using "about:cache" but with addons who will do all this :)

Wednesday, February 6, 2013

Fix issues with Windows Update in Windows 7

Recently I got a lot of errors while updating Windows 7 from windows update. A lot of errors specially Code 66A was returned.

Tried a lot of things but finally a tool from Microsoft itself worked. Try this out : http://go.microsoft.com/fwlink/?LinkId=231149

Good luck :)

Friday, January 25, 2013

Microsoft Office 2010 icons missing in Windows 7

Since yesterday, I found the icons of Office 2010 files like Excel, Word, PPT's got replaced by the generic file icons.

I looked throughout the web for a solution but nothing worked. The primary solutions put forward were:
  1. Delete the IconCache.db file in %userprofile%\AppData\Local
  2. Create a registry key "Max Cached Icons" in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer and set it to 4096 (4MB) or 8192 (8MB)
Folks talked about fixing the "C:\Windows\Installer\" but the solution was not complete. So the steps are:
  1. Open Registry Editor : regedit.exe
  2. I have taken the example of Excel icons missing. So Navigate to HKCR\AppId\EXCEL.EXE
  3. Look for the value for "Appid". For me the value was "{00020812-0000-0000-C000-000000000046}"  - this may be different for you. So note it down.
  4. No look for the value HKCR\CLSID\{00020812-0000-0000-C000-000000000046}\DefaultIcon (Change the Appid value to what you noted above).
  5. Find the value for "Default". For me it is : "C:\Windows\Installer\{90140000-0011-0000-0000-0000000FF1CE}\xlicons.exe,3"
  6. Now look for this location "C:\Windows\Installer\{90140000-0011-0000-0000-0000000FF1CE}\xlicons.exe" in your drive. If you already have it then it is a different issue for you and look for other solutions in this thread. If you do not have this folder, copy it from some other desktop and it should work.
Good luck :-)

Tuesday, May 22, 2012

Minimum Jars to load a Spring context

I was looking for the minimum set of jars required to load a Spring Context but could not find one on the internet. So am listing them out here:
  1. org.springframework.core
  2. org.springframework.web
  3. org.springframework.context
  4. org.springframework.context.support
  5. org.springframework.beans
  6. org.springframework.asm
  7. commons-logging

Wednesday, April 18, 2012

Automatic Logging in to .NET / ASPX using Firefox

If a .NET / ASPX site's authentication mode is marked as 'Windows Authentication', then IIS authenticates the web request with the domain on behalf of the site. This works seamlessly with Internet Explorer but with Firefox , it asks for domain credentials which shows up as a popup in Firefox. This is the usual situation in an Enterprise network where we have Sharepoint and some internal sites built on .NET technology.

Now how do we configure firefox to automatically send the user credentials to the server (IIS) which can authenticate it automatically. To do so:
  1. In the Firefox URL bar enter "about:config":
  2. Acknowledge the warning, and in the "Filter:" box, enter "network.negotiate-auth.trusted-uris". Double click on this, and give it a value of "ad.com,intra.com" (internal domains to which you want firefox to automatically log in to). Click OK.
  3. This will allow Firefox to log you in automatically to internal sites of your company.




Thursday, March 15, 2012

Helloworld web service in Eclipse using Tomcat, Apache CXF and Spring

I have just started working on Spring and was required to expose an existing application as a web service. So to get started I needed to learn about how to create one in Eclipse and deploy it on tomcat. Sadly spending hours and Google and downloading dozens of samples, I was unable to get them work on Eclipse. Most worked using Maven but I wanted to build one in Eclipse from scratch. So lets get started.

Requirements:

To get started:
  1. In Eclipse : Create a New 'Dynamic Web Project'. Name it as 'HelloWS' and click Finish.


  2. Go to Build Path: Configure Build Path.
    1. Under the 'Source' tab: Change the 'Default Output Folder' from 'HelloWS/build/classes' to 'HelloWS/WebContent/WEB-INF/classes'.

    2. Under Libraries tab: Add Spring and Apache CXF libraries.
    3. Under 'Order and Export' tab: Check the chekboxes next to these libraries
    4. Under 'Deployment Assembly' (just above 'Java Build Path' in the 'Properties of HelloWS'  windows) : Click 'Add' :: Java Build Path Entries and select these 2 libraries so that they can be deployed to the Tomcat App Server.
  3. With the configuration done, lets write some code.
  4. Create an interface 'HelloService' under package 'my.service'. Annotate the class with @WebService . Add a simple sayHello method. So it looks like:

    package my.service;

    import javax.jws.WebService;

    @WebService
    public interface HelloService {

        public String sayHello(String name);
       
    }
  5. Next create the implementer class 'HelloServiceImpl' which implements 'HelloService'. Annotate the class with @Webservice and parameter endpointInterface = "my.service.HelloService" which defines the Contract for this Endpoint. So it looks like:

    package my.service;

    import javax.jws.WebService;

    @WebService(endpointInterface = "my.service.HelloService")
    public class HelloServiceImpl implements HelloService {
       
        @Override
        public String sayHello(String name) {
            return "Hello " + name + " !!";
        }
    }
  6. Coding complete. Now lets configure the Spring context which will invoke this service we just created.
  7. Update 'web.xml' under WebContent/WEB-INF folder with the following xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="...">

        <display-name>My Webservice</display-name>

        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:my/service/application-context.xml</param-value>
        </context-param>

        <servlet>
            <servlet-name>CXFServlet</servlet-name>
            <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
            <servlet-name>CXFServlet</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
      
    </web-app>

    Read this configuration file bottom up. First it instructs all requests matching the URLpattern /* (that is everything to be handled by a servlet named ' CXFServlet' which is defined just above. This is a Apache CXFservlet. Above it we provide the configuration file location which will configure this servlet (details below). Above this, it specifies the Spring Listener class which will listen to all these Http requests.
  8. Now create a 'application-context.xml' file at the same level as the 2 java files coded above with the following xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:jaxws="http://cxf.apache.org/jaxws"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

        <import resource="classpath:META-INF/cxf/cxf.xml" />
        <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
        <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

        <!-- Spring manage ServiceBean -->
        <bean id="myServ" class="my.service.HelloServiceImpl" />

        <!-- JAX-WS Service Endpoint -->
        <jaxws:endpoint id="myService" implementor="#myServ"
            address="/myService" />

    </beans>

    In here, again reading from below, first we define an endpoint named 'myService which is implemented by the bean 'myServ' whose class is 'my.service.HelloServiceImpl' and its binded to the address '/myService'
  9. And we are done with coding.
  10. To deploy it, create a 'Tomcat 7 Server' under Servers in Eclipse and deploy the 'HelloWS' module to it using 'Add and Remove'
  11. Start the server
  12. To check, open your browser and type in : http://localhost:8080/HelloWS and it should open up the default page. You can also get the wsdl at : http://localhost:8080/HelloWS/myService?wsdl
  13. You can use SOAPUI to test your service too.
  14. And in 10 minutes your service is ready :)