ContextMenu 4.2 changes from previous versions

We’ve been using ContextMenu 3.x in our Vaadin 6 application. I just tried upgrading Vaadin to version 7.1 and one of the errors I get is related to apparent changes to the ContextMenu. We were doing something like this before:

ContextMenu contextMenu = …
VerticalLayout layout = …
layout.addComponent(contextMenu);

It appears the ContextMenu api has changed and we can no longer do this -
I see it now has methods like:
contextMenu.setAsContextMenuof(…), but that doesn’t work for a layout apparently. Is there a way to associate the contextMenu with a layout component?

From the addons examples :

public void init(VaadinRequest request) {              
VerticalLayout layout = new VerticalLayout();        
setContent(layout);        
ContextMenu contextMenu = new ContextMenu();        
contextMenu.addItem("Root Item").addItem("Sub item");        
contextMenu.setAsContextMenuOf(layout);
}

Make sure that the component that you are right-clicking on is the actual layout and not some other component that expanded inside the layout.