Failure initializing default SSL context

I was trying to use this apache HttpClient to have my web application publish posts to facebook wall.

At first sight, it looks good when I test it in my local machine. I can publish posts to user wall and I’m happy.

But when I deploy it to shared server. Things don’t go as expected. My application can not post to user’s wall and spit this error instead.

org.apache.http.conn.ssl.SSLInitializationException: Failure initializing default SSL context
   at org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext(SSLSocketFactory.java:360)
   at org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory(SSLSocketFactory.java:175)
   at org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(SchemeRegistryFactory.java:49)
   at org.apache.http.impl.client.AbstractHttpClient.createClientConnectionManager(AbstractHttpClient.java:306)
   at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:466)
   at org.apache.http.impl.client.AbstractHttpClient.createHttpContext(AbstractHttpClient.java:286)
   at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:851)
   at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
   at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
Caused by: java.lang.IllegalStateException
   at gnu.javax.net.ssl.provider.X509KeyManagerFactory.engineGetKeyManagers(libgcj.so.10)
   at javax.net.ssl.KeyManagerFactory.getKeyManagers(libgcj.so.10)
   at org.apache.http.conn.ssl.SSLSocketFactory.createSSLContext(SSLSocketFactory.java:226)
   at org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext(SSLSocketFactory.java:358)
   ...32 more

I thought it might be something related to the server since the code works properly on my local machine.

I tried googling but that didn’t help much.

About two weeks later, I came back to the issue and decided to switch to use basic connection using code from http://stackoverflow.com/questions/10913657/posting-to-a-users-wall-using-the-post-request-and-graph-api

and, viola, it works fine now, happy ending 🙂

A (free!) TED for teenagers: Announcing the incredible lineup for TEDYouth in New York City

TED Blog

Just like school … not! TEDYouth is like a TED Conference for high school students, starring a lineup of speakers working at the top of their fields of culture, science, technology and art. You’ll hear about scientific discoveries and crazy art projects that will surprise you, make you laugh and blow your mind a little.

TEDYouth will take place on Saturday, November 17, from 1 to 6pm EST, at the Times Center in Manhattan. After the jump, the exciting lineup of speakers from NASA flight director Bobak Ferdowsi to producer-slash-inventor  Young Guru.

OUR RECENTLY ADDED SPEAKERS:

Young Guru is one of the most important music producers of the past decade, having worked on 10 Jay-Z albums and countless more with other well-known artists. He’s currently working on the future of sound.

Kelly Benoit-Bird is a marine biologist using sophisticated sound technology to explore how animals in the ocean find their…

View original post 598 more words

Useful tips for frontend web development from catswhocode

http://www.catswhocode.com/blog/super-useful-online-tools-to-work-with-images

http://www.catswhocode.com/blog/best-practices-for-efficient-html5-coding

http://www.catswhocode.com/blog/10-useful-typography-tips-to-improve-your-website-readability

http://www.catswhocode.com/blog/7-new-techniques-every-web-developer-should-know

http://www.catswhocode.com/blog/awesome-tutorials-to-master-responsive-web-design

http://www.catswhocode.com/blog/amazing-css3-techniques-you-should-know

When ServletContext.getRealPath() return null…

The latest issue I have is when I call event.getServletContext().getRealPath(“/”); to set the path for log4j.properties. It turns out that somehow I cannot get my path and the method return null instead.

I do some researches and find the root of my problem.

Here, the API doc state that

This method returns null if the servlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive).

For my case, it’s likely to be that either my hosting service have disabled it for security reason or my application is deployed undexploded.

Now for the workaround, instead of using getRealPath to get the path for properties file, we can (and IMO, we better) use event.getServletContext().getResourceAsStream(“WEB-INF/log4j.properties”); instead

This method will return the resource located at the named path as an InputStream object and PropertyConfigurator.configure() also accept that as well.

Facebook Graph API : publishing user posts with link no longer show in feed

Yesterday I worked on publishing user’s post to his/her facebook wall and everything worked fine. Except one thing. The post won’t reach the feed.

After half an hour of research I found this document

It state that

Updating a User’s Status

You can use this method to simply update a user’s status. When you do so, the status message appears at the top of the user’s profile and on the Friends > Status Updates page. The message also appears in the stream with your application icon.

To use this method to set a user’s status do the following:

  • Do not include an attachment or action link. If you do, the story will get published and will appear in the stream and on the user’s Wall only. It won’t appear at the top of the profile or in the Status Updates page.
  • Make sure the message is no longer than 420 characters. Otherwise, an error gets returned

Now I have to choose between

  • still add a post with your link even it doesn’t show in feed
  • sending just a message and have it in feed?

think would go with first one.