A couple of weeks ago we had a "Join Twitter" storm at Xebia. After the Linked-in, Plaxo, Hyves, Facebook and probably a dozen of other social network storms I initially decided to pass on Twitter. But then by colleague JCP Colleague & Friend Andreas posted an entry about twitter and that convinced me to join. Why? This sentence basically did it: "Twitter can promote your blog by sending out new blog posts." This could help to draw some extra traffic to the blog...

I immediately checked if there already was a plug-in for Pebble (the webapp that hosts this blog) that would allow me link my blog to Twitter. SinceI could not find something quickly and the functionality would be really simple I decided to create the plug-in for Pebble myself. So If all goes well each blog entry that I'll post or update to my blog will result in a Twitter update. And this blog entry should be the first proof of that ;-)

In case you're interested in including this in your own Pebble blog:

  • Download the TwitterTweeter.java source and compile it against your Pebble code
  • Add the resulting class (jar) to the classpath of your servlet container
  • Restart the servlet container.
  • Add net.vermaas.TwitterTweeter in the Blog Plug-in configuration as Blog Entry Listener and Comment Listener.
  • Add the following three properties in the Blog Plug-in configuration as Properties
    TwitterTweeter.password=[your Twitter password]
    TwitterTweeter.userName=[your twitter user name]

    ** UPDATE **:
    Sending out tweets on each publish, update, delete and each and every comment being posted proved to be a bit of an overkill. Therefore 2 additional properties are added:
    TwitterTweeter.blog.entry.tweets=[Determines on what blog entry actions to sent a tweet]
    TwitterTweeter.comment.tweets=[Determines on what comment actions to sent a tweet]
    (See comments in source for valid values for these last two settings)
    ** EO UPDATE **
  • Restart your servlet container
That should do the trick... I initially though that username/password had to travel unencrypted over the Net, but as you can see in the above properties list the TwitterTweeter.twitterUrl has a https prefix so username and password will be encrypted... no security constraints so what is stopping you from using this plug-in ;-)


  1. Gero said...

    Nice work, Gero. Saw your updates on twitter. I'm still fighting with more basic questions for my blog at the moment.
    Note: Comment imported. Original by Andreas Ebbert-Karroum ( email: Andreas.Ebbert@email.de website: http://blogs.karroum.de/andreas ) at 2008-04-06 22:35  

  2. Gero said...

    Thanks ;-)
    Note: Comment imported. Original by Gero Vermaas ( email: gero@vermaas.net website: http://vermaas.net ) at 2008-04-07 10:09  

  3. Gero said...

    And I also got a short message on my mobile for the new comment :) I just hope that there are not too many people commenting.
    BTW: Twitter is featured today in a major german newspaper, they also started tweeting now: http://twitter.com//weltkompakt
    Note: Comment imported. Original by Andreas Ebbert-Karroum ( email: Andreas.Ebbert@email.de website: http://blogs.karroum.de/andreas ) at 2008-04-07 10:17  

  4. Gero said...

    Simon posted a positive comment on the Pebble ML about the Twitter plugin. Simon proposed an alternative: http://www.twitterfeed.com/. What are the advantages to twitterfeed.com and does this solve the clear text password issue about posting from Pebble?
    Note: Comment imported. Original by David ( email: davd@davidwbrown.name website: http://davidwbrown.name ) at 2008-04-07 15:24  

  5. Gero said...

    I didn't know about http://www.twitterfeed.com/ yet, but that is also a nice solution. Advantage would be that you can use this solution with any blog that publishes an RSS/Atom feed... which is basically any blog. So you're not limited to a Pebble blog on which you can install new plug-ins.

    Disadvantages... well, it does not immediately publish to Twitter after you post to the blog. It only polls your feed periodically and this plug-in immediately published to Twitter once you post a blog entry or when a comment is posted. And you don't have the fun of building you own plug-in of course....

    On the authentication side, my solution and twitterfeed have the same limitations, see the "Authentication" section on of the Twitter API.

    However, just for fun I changed the Twitter URL from http to https and it looks as if this works... If this comments shows up on my Twitter I'll update the blog entry and remove the note on username/password traveling in plain text over the Net... so that's how you can see that it works ;-
    Note: Comment imported. Original by Gero Vermaas ( email: gero@vermaas.net website: http://vermaas.net ) at 2008-04-07 15:45  

  6. Gero said...

    Hello Gero, i added twittertweeter.java to the pebble project i have in eclipse. This is easier with the build.xml since allthe libraries and other goodies are already there. Also, since your packaging started with *net* i only had to add the codeunder: src/net/java and add a <jar> element to the build.xml build target to get the twittertweeter.jar.. BTW: your source-file package references net.vermaas but your instructions below use the package designation net.java so I changed to package name to reflect the proper package name according to the instructions below. i made two very small changes in the build.xml to get the needed twittertweeter.jar output along side the pebble.jar using the build.xml build target. I followed the instructions at: http://gerodt.homeip.net/blog/gero/2008/04/06/1207505880000.html verbatim but pebble.war failed to deploy with the twittertweeter.jar in the lib directory. I removed the twittertweeter.jar and pebble.war redeployed no problemo. Please find the server.log exceptions and the pebble messages are removal of twittertweeter.jar included below. TIA and please advise, David.

    2008-04-21 16:05:02,037 INFO [STDOUT] 2008-04-21 16:05:02,034 [main] WARN org.acegisecurity.intercept.AbstractSecurityInterceptor- Could not validate configuration attributes as the MethodDefinitionSource did not return a ConfigAttributeDefinition Iterator2008-04-21 16:05:02,117 INFO [STDOUT] 2008-04-21 16:05:02,116 [main] INFO net.sourceforge.pebble.web.listener.PebbleContextListener- Starting Pebble2008-04-21 16:05:02,622 INFO [STDOUT] 2008-04-21 16:05:02,617 [main] ERROR org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/pebble]- Exception sending contextinitialized event to listener instance of class net.sourceforge.pebble.web.listener.PebbleContextListenerjava.lang.NoClassDefFoundError: net/sourceforge/pebble/api/event/blogentry/BlogEntryListener
    Note: Comment imported. Original by David Brown ( email: david@davidwbrown.name website: http://www.davidwbrown.name ) at 2008-04-22 23:02  

  7. Gero said...


    Thanks for point to the typo in the package name, it is now corrected in the blog post.

    I'm not sure what is causing this problem. They way I'm deploying the generated jar is by just dropping in the  webapps//pebble-2.1/WEB-INF/lib directory of Tomcat (v. 5.5.20) and that works OK.

    I checked my catalina.out log file and noticed that I also have the Acegi warning and that is probably caused by the fact that the tweet(String msg) method is setting the Authenticator. It does work however, but probably could be improved by using Acegi just as Pebble does.

    The PebbleContextListener error is weird because the TwitterTweeter class is not using the PebbleContextListener interface at all. It did in an old version, but I though I never put that version on the web. Could you try again using the latest version? The link in the blog post points to the latest Java source.

    Furthermore I'm using Pebble 2.1... could that be a cause?

    Note: Comment imported. Original by Gero Vermaas ( email: gero@vermaas.net website: http://vermaas.net ) at 2008-04-24 20:37  

  8. Gero said...

    Hi Gero
    You seem to know Pebble pretty well and so I am asking you a question if you don't mind.
    I want to include an rss feed in my blog, that is, I want to show a feed formatted as html in the content area as a separate page. 
    I have an example of rss reading jsp but I cannot see how I can get it to show in the content area.
    Any ideas? Any clues would be appreciated.
    I'm on version 1.9 as my host has not upgraded to Java 5 yet...
    Thanks in advance.
    Note: Comment imported. Original by Anonymous ( email: lyndon@infomediauk.net website: null ) at 2008-09-19 15:30  

  9. Gero said...


    I'm not sure how this could be done. Have you tried asking on the Pebble mailing list at https://lists.sourceforge.net/lists/listinfo/pebble-user/?

    Note: Comment imported. Original by Gero Vermaas ( email: gero@vermaas.net website: http://vermaas.net ) at 2008-09-26 19:51  

  10. Gero said...

    I've done it!
    I just took template.jsp and renamed it, added the jsp code to read the feed (uses xslt and a transformer bean which is really cool) and added a link to sidebar.jsp to enable navigation to the page.
    Voila! Dynamically changing content!
    You can see the result at : Top 20 Best Selling Adult eBooks
    Thanks any way, if any one is interested I can provide more details.
    Note: Comment imported. Original by Lyndon ( email: lyndon@infomediauk.net website: http://www.adultsexotica.co.uk/ ) at 2008-09-26 20:20  

  11. Steve Carton said...

    Hi Gero -

    Is this code still available? I have a pebble blog and would like to create a tweet when a Blog entry is created.  

  12. Gero said...


    Yep, the code is still available. I fixed the link in the post to TwitterTweeter.java (guess the link was broken when I migrated to Blogger).


  13. Anavar said...

    Great post! Thanks for all the info.  

Post a Comment