Sunday, December 19, 2004

JSSE: How to ignore CertificateException: Couldn't find trusted certificate"?

While testing SecureSocket code, sometimes you would need code to ingore certificate validation.
JSSE provides a simple way to do this by writing your own TrustManager. The below sample code lets you write simple clients ignore certificate validation:

01 
02 
03 import java.io.InputStream;
04 import java.io.OutputStream;
05 
06 import javax.net.ssl.SSLContext;
07 import javax.net.ssl.SSLSocket;
08 import javax.net.ssl.SSLSocketFactory;
09 import javax.net.ssl.TrustManager;
10 import javax.net.ssl.X509TrustManager;
11 
12 /*
13  * This example demostrates how to use a SSLSocket as client to
14  * send and recieve Data while ignoring the certificate validation.
15  */
16 
17 public class SSLClient {
18 
19     public static void main(String[] argsthrows Exception {
20 
21         // Create a trust manager that does not validate certificate chains like the default TrustManager
22         TrustManager[] trustAllCerts = new TrustManager[]{
23             new X509TrustManager() {
24 
25                 public java.security.cert.X509Certificate[] getAcceptedIssuers() {
26                     return null;
27                 }
28 
29                 public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
30                     //No need to implement.
31                 }
32 
33                 public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
34                     //No need to implement.
35                 }
36             }
37         };
38 
39         // Let us create the factory where we can set some parameters for the connection
40         SSLContext sc = SSLContext.getInstance("SSL");
41         sc.init(null, trustAllCerts, new java.security.SecureRandom());
42 
43         SSLSocketFactory factory =sc.getSocketFactory();
44         SSLSocket socket =(SSLSocket)factory.createSocket(args[0], Integer.parseInt(args[1]));
45         socket.startHandshake();
46 
47 
48         OutputStream out = socket.getOutputStream();
49         InputStream in = socket.getInputStream();
50 
51         //Do- Fun stuff with I/O classes.
52     }
53 }

Mustang: 2 new methods in String class.

Two new helper methods are added to String class. The changes are described in bug#6189137.

1. boolean isEmpty() { return length() == 0; }
2. boolean contains(String s) { return indexOf(s) >= 0; }

Thursday, December 16, 2004

BEA: Diablo (weblogic9 Beta) available for download

BEA made Diablo (Weblogic9 Beta) available for download as promised today.
Download it here.
Documentation is here.
What's new in 9.0 is here.

The changes to me looked like this release should have been 8.2 instead of 9. There are lot of little goodies but nothing that really make me want to move to 9 from 8.1. The most exciting change is support for JDK5.0

Tuesday, December 14, 2004

Google: Is this really possible?

Google did amazing JavaScript again with google suggest. I always hated Javascript and have to agree what google is doing is really amazing because its really cool and flaw less work with JavaScript and XMLHTTP.

Here is a link to the compresses javascript used by google (Don't you wonder why so few sites really compress js?).

Thursday, November 18, 2004

Why is Bill Gates so concerned about spam

Microsoft has been talking about Spam for a while. So why is Bill Gates so concerned about Spam? Apparently thats because he world's most spammed man.

Wednesday, November 17, 2004

J2SE 6.0 Snapshot Releases

Sun released a snapshot release of Mustang. You can download binaries and Source bundle too. Detailed list of changes is available (Thanks to Graham Hamilton for quickly providing a change list).

java -version output:
java version "1.6.0-ea"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b12)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b12, mixed mode, sharing)


This snapshot release mostly contains bug fixes. One of my favourite bug fix in 1.6 is:
4921296:ClassCastException needs more verbose detailMessage

Consider the following code:

1 public class ExceptionTest {
2     public static void main(String args[]) {
3         String s = (Stringnew Object();
4     }
5 }


This used to give a not so useful message till mustang:

Exception in thread "main" java.lang.ClassCastException
at ExceptionTest.main(ExceptionTest.java:3)


Mustang includes both target and object class names in the message:

Exception in thread "main" java.lang.ClassCastException: java.lang.Object cannot be cast to java.lang.String
at ExceptionTest.main(ExceptionTest.java:3)

Thursday, October 07, 2004

JDocs: Sun is right

First of all, I think JDocs is a great a Idea. Especially if you need to refer to several open source java docs. But using JDocs for a while I can see why Sun didn't want to provide JavaDocs at JDocs.com.

JDocs.com doesn't have same uptime as java.sun.com: With little or no money that JDocs makes, Rick has little resources to maintain uptime required. Last two hours I am not able to access JDocs for whatever reason.

Missing features: There are several features that are missing in JDocs. Index is disabled on main page for all api's where as index link doesn't work in individual class docs(But link is not disabled).

Unwanted Advertisements: Do we really want to see Microsoft advertisements on JavaDocs?

EOL Docs removal: Sun prefers to remove javadocs for EOL products to encourage users to move to supported versions of J2SE. Everytime it needs to do this, it has to deal with Rick.

I love JDocs.com and use it very often but that doesn't mean I want J2SE JavaDocs on JDocs.com.

Firefox and Google Browser

Firefox seems to be already the most popular browser that java developers are using. Looking at sitemeter reports for my Blog showed that IE has less than 30% share (ofcourse among people who visit this blog).
A surprising entry is Google4.x browser. I am assuming its some fowl play :-)

Here is the report anyway:

Tuesday, October 05, 2004

Adding sound to a boring build

Well, the builds that I do at my day job take a couple of minutes and I hate wating for build to complete. So i decided to add a simple voice notification mechanism at the end of the build so that I can go back to poor dos prompt.

I was left with three options:

1. Using optional ant task Sound.
Using sound task is little boring since you need the audio files for what your build process want to say to you. Also this requires modifying the original build which could be annoying for other team members who don't prefer the sound notification.

2. Writing a custom ant task using FreeTTS.
Writing a custom ant task would help me relearn how to write custom ant task as it has been 2 years since i wrote a custom ant task. But the problem is this also requires modifying the original build which could be annoying for other team members who don't prefer the sound notification.

3. Writing a custom logger.
Well this option probably is simplest and doesn't require any change to regular build file. So this works great for me.


Its really amazing how simeple this task is using FreeTTS and Ant. Write a simple logger extending DefaultLogger. Extending DefaultLogger helps because you only need to listen to events that you want to add sound to. Here is my code for providing sound to build complete event:


package org.js.build;

import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.DefaultLogger;

import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;


public class FreeTTSLogger extends DefaultLogger {

    public void buildFinished(BuildEvent e)
    {
      //Let default logger do what ever it doing.
        super.buildFinished(e);

        String voiceName = "kevin16";
        //create voice 
        Voice buildVoice = VoiceManager.getInstance().getVoice(voiceName);

        if (buildVoice == null) {
            System.err.println("Cannot load a voice named " + voiceName + ".");
            return;
        }
        //Allocate the resources for the voice.
        buildVoice.allocate();

        /* Synthesize speech based on whether or not build is successful
         */
        if(e.getException() == null)
          buildVoice.speak("Build completed Mr. Kumar.");
        else
          buildVoice.speak("Build failed.");

        //cleanup. Be a good citizen.
        buildVoice.deallocate();

    }

}


For using the logger copile this code into a jar file of its own. You can download my jar file. copy this jar file into lib directory of your ANT_HOME. Now you need to copy FreeTTS libraries (all jars under freetts\lib directory) to ANT_HOME\lib directory. But ant 1.6 and FreeTTS 1.2Beta2, this throws a unexpected Exception:

java.lang.ArrayStoreException
at java.lang.System.arraycopy(Native Method)
at java.util.Vector.toArray(Vector.java:688)
at com.sun.speech.freetts.UniqueVector.toArray(VoiceManager.java:840)
at com.sun.speech.freetts.VoiceManager.getVoiceDirectories(VoiceManager.java:203)
at com.sun.speech.freetts.VoiceManager.getVoices(VoiceManager.java:109)
at com.sun.speech.freetts.VoiceManager.getVoice(VoiceManager.java:519)
at org.js.build.FreeTTSLogger.buildFinished(FreeTTSLogger.java:55)
at org.apache.tools.ant.Project.fireBuildFinished(Project.java:1796)
at org.apache.tools.ant.Main.runBuild(Main.java:693)
at org.apache.tools.ant.Main.startAnt(Main.java:188)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

A simple way to get around this is by copying FreeTTS libraries to JRE\lib\ext directory. Now to use this new logger, just use the command:

ant -logger org.js.build.FreeTTSLogger

What bubble got Right

Paul Graham has a great write up on What The Bubble Got Right. Its a great read since everthing that became fashionable during the Bubble is now unfashionable.

Sunday, October 03, 2004

Longest Stack Trace Ever?

Jason Hunter posted a stack trace that appears to be longest ever. Ofcourse credit goes IBM :-)

Here it goes:


Nested Exception is java.lang.IllegalStateException
at com.ibm.wps.pe.pc.legacy.impl.PortletRequestImpl.getInputStream(PortletRequestImpl.java:221)
at com.oreilly.servlet.multipart.MultipartParser.(MultipartParser.java:183)
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:222)
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:109)
at resume.ResumePortlet.doView(ResumePortlet.java:166)
at org.apache.jetspeed.portlet.PortletAdapter.service(PortletAdapter.java:154)
at org.apache.jetspeed.portlet.Portlet._dispatch(Portlet.java:744)
at org.apache.jetspeed.portlet.Portlet.access$100(Portlet.java:88)
at org.apache.jetspeed.portlet.Portlet$Context.callPortlet(Portlet.java:899)
at com.ibm.wps.pe.pc.legacy.cmpf.impl.PortletFilterManager.doFilter(PortletFilterManager.java:253)
at org.apache.jetspeed.portlet.Portlet.dispatch(Portlet.java:636)
at org.apache.jetspeed.portlet.Portlet.doPost(Portlet.java:516)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jetspeed.portlet.Portlet.service(Portlet.java:491)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:972)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:554)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:246)
at com.ibm.wps.pe.pc.legacy.invoker.impl.PortletInvokerImpl.callMethod(PortletInvokerImpl.java:474)
at com.ibm.wps.pe.pc.legacy.invoker.impl.PortletInvokerImpl.render(PortletInvokerImpl.java:144)
at com.ibm.wps.pe.pc.legacy.PortletContainerImpl.callPortletMethod(PortletContainerImpl.java:1372)
at com.ibm.wps.pe.pc.legacy.PortletContainerImpl.renderPortlet(PortletContainerImpl.java:380)
at com.ibm.wps.pe.pc.PortletContainerImpl.doRenderPortlet(PortletContainerImpl.java:413)
at com.ibm.wps.pe.pc.PortletContainerImpl.renderPortlet(PortletContainerImpl.java:98)
at com.ibm.wps.pe.pc.PortletContainer.renderPortlet(PortletContainer.java:95)
at com.ibm.wps.composition.PortletHolder.render(PortletHolder.java:87)
at com.ibm.wps.engine.tags.PortletRenderTag.doStartTag(PortletRenderTag.java:151)
at org.apache.jsp._Control._jspService(Control.jsp :176)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:357)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:675)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:773)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.ServicingServletState.service(StrictLifecycleServlet.java:333)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:967)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:554)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:246)
at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.handleRequest(DispatcherServiceImpl.java:89)
at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.include(DispatcherServiceImpl.java:50)
at com.ibm.wps.services.dispatcher.Dispatcher.include(Dispatcher.java:44)
at com.ibm.wps.engine.templates.skins.Default.render(Default.java:70)
at com.ibm.wps.engine.templates.SkinTemplate.render(SkinTemplate.java:75)
at com.ibm.wps.composition.elements.Component.render(Component.java:906)
at com.ibm.wps.composition.elements.Control.render(Control.java:210)
at com.ibm.wps.composition.Composition.render(Composition.java:2745)
at org.apache.jsp._UnlayeredContainer_2D_V._jspService(UnlayeredContainer-V.jsp :12)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:357)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:675)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:773)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.ServicingServletState.service(StrictLifecycleServlet.java:333)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:967)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:554)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:246)
at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.handleRequest(DispatcherServiceImpl.java:89)
at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.include(DispatcherServiceImpl.java:50)
at com.ibm.wps.services.dispatcher.Dispatcher.include(Dispatcher.java:44)
at com.ibm.wps.engine.templates.skins.Default.render(Default.java:70)
at com.ibm.wps.engine.templates.SkinTemplate.render(SkinTemplate.java:75)
at com.ibm.wps.composition.elements.Component.render(Component.java:906)
at com.ibm.wps.composition.elements.SingleEntryContainer.render(SingleEntryContainer.java:207)
at com.ibm.wps.engine.tags.CompositionRenderTag.doStartTag(CompositionRenderTag.java:318)
at org.apache.jsp._LayeredContainer._jspService(LayeredContainer.jsp:176)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:357)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:675)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:773)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.ServicingServletState.service(StrictLifecycleServlet.java:333)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:967)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:554)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:246)
at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.handleRequest(DispatcherServiceImpl.java:89)
at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.include(DispatcherServiceImpl.java:50)
at com.ibm.wps.services.dispatcher.Dispatcher.include(Dispatcher.java:44)
at com.ibm.wps.engine.templates.skins.Default.render(Default.java:70)
at com.ibm.wps.engine.templates.SkinTemplate.render(SkinTemplate.java:75)
at com.ibm.wps.composition.elements.Component.render(Component.java:906)
at com.ibm.wps.composition.elements.SingleEntryContainer.render(SingleEntryContainer.java:207)
at com.ibm.wps.engine.tags.CompositionRenderTag.doStartTag(CompositionRenderTag.java:318)
at org.apache.jsp._Home._jspService(Home.jsp :2)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:357)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:675)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:773)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.ServicingServletState.service(StrictLifecycleServlet.java:333)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:967)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:554)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:246)
at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.handleRequest(DispatcherServiceImpl.java:89)
at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.include(DispatcherServiceImpl.java:50)
at com.ibm.wps.services.dispatcher.Dispatcher.include(Dispatcher.java:44)
at com.ibm.wps.engine.templates.screens.Default.render(Default.java:73)
at com.ibm.wps.engine.templates.ScreenTemplate.render(ScreenTemplate.java:64)
at com.ibm.wps.engine.tags.ScreenRenderTag.doStartTag(ScreenRenderTag.java:69)
at org.apache.jsp._Default._jspService(Default.jsp :572)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:357)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:675)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:773)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:967)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:554)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:246)
at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.handleRequest(DispatcherServiceImpl.java:89)
at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.include(DispatcherServiceImpl.java:50)
at com.ibm.wps.services.dispatcher.Dispatcher.include(Dispatcher.java:44)
at com.ibm.wps.engine.templates.themes.Default.render(Default.java:129)
at com.ibm.wps.engine.templates.ThemeTemplate.render(ThemeTemplate.java:71)
at com.ibm.wps.engine.Servlet.callPortal(Servlet.java:770)
at com.ibm.wps.engine.Servlet.doGet(Servlet.java:465)
at com.ibm.wps.engine.Servlet.doPost(Servlet.java:801)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:76)
at com.ibm.wps.mappingurl.impl.URLAnalyzer.doFilter(URLAnalyzer.java:185)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:132)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:71)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:963)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:554)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:198)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)

Tuesday, September 28, 2004

Java Quiz - Win a GMail Invitation

Why does the following program compile:


public class Kumar {

public static void main(String args[]) {

// Hoping this code will not compile ?#$%&**\u000d{
for (int i=0; i<10; i++) {
System.out.println("Hello");
}
} //Additional close braces
}
}


The first one to answer gets a free GMail invitation. Answer to be posted tomorrow if no one get posts the correct answer.

Wednesday, September 15, 2004

Preventing Google from caching your site

When your site goes down or someone want to refer a old version of web pages google cache comes to rescue. But at times you don't want some pages to be cached by google. You can inform google not to cache a web page by adding a metatag as follows


<meta name=”googlebot” content=”noarchive”>

Monday, August 30, 2004

ShortHorn and Long XP

I am trying to make some meaning out of all the misguiding press relases and Interviews from the dark side about Longhorn changes.

Longhorn now to be called ShortHorn:
* WinFS is not part of the Longhorn2006 release.

WinxowsXP now to be called LongXP:
* Avalon and Indigo will be available on XP and Windows 2003.

What does this mean?
* Avalon being available for WindowsXP is a big push to Avalon based based applications.
* This would bring out the ugly mixed applications that are needs interoperability between Avalon and Windows Forms.
* All the killer apps that are going to be based on WinFS are going to wait little longer.
* Longhorn is not a "Many shoots at moon" anymore. Its just an incremental release over XP.
* Longhorn Client OS to be released in 2006 and Server OS to be released in 2007.


Sunday, August 29, 2004

Visual Studio learns from Java IDE's

Gone are the days when every java developers hoped to find an IDE which is as capable as Visual Studio. Now Studio 2005 seem to be following Java IDE's. Here are the latest features in Visual Studio 2005 :

The Visual Studio IDE also includes new features. Refactoring intelligently updates your source code, and Expansions speed up code entry with predefined templates.


Monday, June 07, 2004

Yahoo using Google adsense?

A friend sent an Email that Yahoo web hosting ad appears on my blog as part of Google Ads. Here is the Yahoo web hosting ad:

Film deal for 'Baghdad blogger'

Film deal for Baghdad blogger. Salam Pax, whose real name has never been revealed, spent months writing an often bleakly humorous weblog which detailed the fears and hardships of Iraqi citizens. The diary began as a way for the 29-year-old architectural student to keep in touch with his friend Raed in Jordan. "It was just simple things about what was happening in Baghdad so he could stay in touch with what was happening," he told the BBC's Today programme last year. Salam Pax began a fortnightly column in The Guardian newspaper in May last year.


Wednesday, June 02, 2004

Debugging thread related hangs in the JVM

Moazam Raja blogged on Debugging thread related hangs in the JVM. This is nice a read. Also make sure to check out code names for all J2SE versions here.

Microsoft granted patent for double click

United States Patent: 6,727,830 abstract: A method and system are provided for extending the functionality of application buttons on a limited resource computing device. Alternative application functions are launched based on the length of time an application button is pressed. A default function for an application is launched if the button is pressed for a short, i.e., normal, period of time. An alternative function of the application is launched if the button is pressed for a long, (e.g., at least one second), period of time. Still another function can be launched if the application button is pressed multiple times within a short period of time, e.g., double click.

Get ready to pay M$ every time you write a UI with double click :-)

Tuesday, March 02, 2004

General: AOP and AOM

Aspect Oriented Programming might be doom but according to Dilbert Aspect Oriented Management works Great :-)


Friday, February 06, 2004

J2SE1.5: javax.pack is awesome but ..

javax.pack.Pack200 which transforms JAR file to or from a packed stream in Pack200 format is really awsome. When Pack200 is used over rt.jar with the default example code below, its size is reduced from 35,804,926 bytes to 10,114,786 bytes. There is one gotcha though. P200 in J2SE1.5beta writes to System.out. Here are the messages written to System.out when rt.jar is compressed:


*** Error at input offset 343 of java/lang/Deprecated.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/Deprecated.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/Deprecated
*** Error at input offset 267 of java/lang/Overrides.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/Overrides.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/Overrides
*** Error at input offset 322 of java/lang/annotation/Documented.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/annotation/Documented.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/annotation/Documented
*** Error at input offset 439 of java/lang/annotation/Inherited.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/annotation/Inherited.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/annotation/Inherited
*** Error at input offset 457 of java/lang/annotation/Retention.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/annotation/Retention.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/annotation/Retention
*** Error at input offset 451 of java/lang/annotation/Target.class{*}
Warning: Passing class file uncompressed due to unrecognized attribute: java/lang/annotation/Target.class
javax.pack.Attribute$FormatException: class.RuntimeVisibleAnnotations: passing attribute bitwise in java/lang/annotation/Target


But these doesn't really seem to be the errors though when P200.unpack is used on the packed rt.jar, the file generated is identical to original rt.jar. Hopefully this spitting to System.out will go away in final realease.

Code to Pack a Jar file:

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.jar.JarFile;
import javax.pack.Pack200;

public class Pack200Test {

public static void main( String args[]) throws IOException {

Pack200 p200 = new Pack200();

// Initialize the state by setting the desired properties
Map p = p200.getProperties();
p.put(Pack200.PACK_EFFORT, "7");
p.put(Pack200.PACK_SEGMENT_LIMIT, "-1");
p.put(Pack200.PACK_KEEP_FILE_ORDER, Pack200.FALSE);
p.put(Pack200.PACK_MODIFICATION_TIME, Pack200.LATEST);
p.put(Pack200.PACK_DEFLATE_HINT, Pack200.FALSE);
p.put(Pack200.PACK_STRIP_DEBUG, Pack200.FALSE);
p.put(Pack200.PACK_UNKNOWN_ATTRIBUTE, Pack200.ERROR);

//Pack the jar file
JarFile jar = new JarFile(args[0]);
FileOutputStream out = new FileOutputStream(args[1]);
p200.pack(jar, out);

}

}


Code for Unpacking a jar file:

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.jar.JarOutputStream;
import javax.pack.Pack200;

public class UnPack200Test {

public static void main( String args[]) throws IOException {

Pack200 p200 = new Pack200();

// Initialize the state by setting the desired properties
Map p = p200.getProperties();
p.put(Pack200.PACK_EFFORT, "7");
p.put(Pack200.PACK_SEGMENT_LIMIT, "-1");
p.put(Pack200.PACK_KEEP_FILE_ORDER, Pack200.FALSE);
p.put(Pack200.PACK_MODIFICATION_TIME, Pack200.LATEST);
p.put(Pack200.PACK_DEFLATE_HINT, Pack200.FALSE);
p.put(Pack200.PACK_STRIP_DEBUG, Pack200.FALSE);
p.put(Pack200.PACK_UNKNOWN_ATTRIBUTE, Pack200.ERROR);

//Unpack the jar file
File file = new File(args[0]);
JarOutputStream out = new JarOutputStream(new FileOutputStream(args[1]));
p200.unpack(file, out);

}

}

Thursday, February 05, 2004

J2SE1.5: First of its kind

atleast in one aspect. i.e un deprecating. This is probably the first release where a method is undeprecated.

The method public static String getenv(String name) in the class java.lang.System which has been deprecated since JDK1.1.x days is undeprecated with J2SE1.5. The docs of the undeprecated method can be found here. Also rightly a new Generics based getenv method is being added.

SPAM: We need your Debit Card PIN number

This mail is being circulated today. I recieved this mail to my yahoo account.


_Dear citibank_ _Client_,

This_ leter was seent by_the CITI_bank server to
veerify your _email_ adderss_.
You mmust clpemote this pcresos by clicking on_the_link
beelow and enttering in the smmall window your Citi-Bank
_Debit card number and PIN that you use_ in the Atm_Machine.
This is done - for_your pocrettion -T- becourse some of our
memmbers no lneogr have acescs to their email adredesss
and we must verify it.

(I removed the link here for Security reasons)
To veerify _your _EMAIL_ address and access your _Citibank
account, clik on_the_link beelow.

Kh8vHt1w



Check the spelling mistakes to avoid Yahoo spam blockers. But bad for them I am not a CitiBank customer :-)

Monday, February 02, 2004

Oracle: 10G - Wait is over

Oracle made 10G downloads available for both Solaris 64 bit and HP-UX. You can find the downloads here. The Register reports Price cut is on the way.

Wednesday, January 28, 2004

General: Look who is making money

From Register's IT giants criticised for running third world 'sweatshops'


In Thailand, a worker making hard drives for Dell is paid the equivalent of £2.50 per day. Michael Dell, the CEO of Dell, earned £134,000 per day last year.

Michael Dell is making (more than) 50 thousand times an ordinary employee in the company. May be he deserves it for building a company which provided employment for 39,100 :-)