Germany and it’s energy companies Vattenfall and Lichtblick: From bad to worse

Opening my mailbox - those for letters not the one on my Mac - revealed a letter from my old energy provider Vattenfall. I've changed the provider last year from Vattenfall Europe to Lichtblick because the Vattenfall service was bad, I didn't want to support nuclear power any longer and because their prices increased sharply.

Now some months later, Vattenfall tells me they haven't received power by my new provider Lichtblick. They haven't told me that for months. Now out of the blue they tell me they have delivered power to me for months after I've left them. Which for them means that a new contract came into existence and I have now to pay ~40 EUR per month to them in the future (and the power I've used for the last months). Funny thing, I have been paying ~50 EUR each month to my new power provider Lichtblick who also claim to deliver power to me.

So two companies claim they supply me with power, and both want to be paid! Last time I've looked I haven't noticed my lights have been brighter because of double the power. The ultimate business case. Sell the same power twice! Now I have the hassle to proof them that only one of them can possibly have delivered my power. Funny world. I'm p*ssed.

From the Varttenfall homepage:

Operating profit rose 2.7% to SEK 28,583 million (27,821). The earnings improvement is attributable primarily to German electricity generation and is explained by a high level of available capacity of coal-fired plants and better prices received on the European Energy Exchange in Germany.

I know where the 2.7% profit rise comes from.

How to PUT binary data with REST?

Base64 in XML? Multi-mime? See the question, add a comment if you have an answer, the Google results are not very satisfying. Someone clearly solved the problem. But all REST discussions I've found do not adress the problem. Even the "RESTful Web Services" bible is mostly silent on the topic (And I don't want to declare the binary object a resource and PUT binary data into it).

Adding Web Beans JSR 299 to Jersey for REST

While playing with Web Beans I thought it would be nice to add Web Beans support to Jersey. Jersey is a JSR 311 implementation for RESTful web services in Java. Though it has taken some flak, I - and others - think it's easy to use. Because it's easy in Jersey to control the creation of objects by writing your own servlet with a Jersey ComponentProvider, I finished a quick hack in no time. Some help was the integration examples for Spring.

public class WebbeansJerseyServlet extends ServletContainer {

  private static class WebbeansComponentProvider 
    implements ComponentProvider {
    private WebBeansContainer webBeans = WebBeansContainer.create();

    public Object getInstance(ComponentProvider.Scope scope, Class c)
      throws InstantiationException, IllegalAccessException {
      return webBeans.getObject(c);

    public Object getInstance(Scope scope, Constructor contructor,
                              Object[] parameters)
      throws InstantiationException, IllegalArgumentException,
      IllegalAccessException, InvocationTargetException {
      return null;

    public void inject(Object instance) { }

  protected void initiate(ResourceConfig rc, WebApplication wa) {
    wa.initiate(rc, new WebbeansComponentProvider());

Having defined this servlet, a REST resource example for the UuidService from my last post about Web Beans, looks like this

public class UuidResource {
  UUIDService service;

  public UuidResource() {

  public String getUuuid() {
    return service.getValue();

Works like a charm. The UUIDService is injected through Web Beans and the scopes from Web Beans, @RequestScope and @SessionScope seem to work. This takes a big burden from the developer.

I hope to implement a SOFEA web application with Javascript parts which communicate with the backend via REST. For performance reasons it would be nice to populate and render the Javascript on the server. Therefore I would wish I could resolve REST calls to Jersey internally like


to pre-populate pages with REST calls in them.

Thanks for listening.

Update:The Jersey lead wrote about a Jersey client API which perhaps does what I want. Splendid.

Playing with JSR 299 – Web Beans

You can play with WebBeans! WebBeans looks nice as a web-layer-aware IoC container. I've been starring at Seam and Gavin to get my hands on a WebBeans implementation. Waiting. Consider my astonishment when I found the working Resin WebBeans implementation.

It's easy to get started with the JSF example. There are also example implementations for Wicket and Struts2. WebBeans in Resin works with simple JSPs too though. Suppose we want a page which uses a web bean to display an UUID. Simple, the JSP page:


and the web bean:

package de;

import javax.webbeans.Component;
import javax.webbeans.RequestScoped;
import javax.webbeans.Named;
import java.util.UUID;

public class UUIDService {
  private String value = UUID.randomUUID().toString();

  public String getValue() { return this.value; }

The annotations tell the container that it's a web beans component, we want to refer to it by the "uuid" name and the scope is a request. This means we want a new bean every request.

I had some smaller problems getting Resin working, but the nice thing about Resin are the excellent error messages. Very helpful.

Thanks for listening.