Heat a small saucepan over medium-high heat and add the oil, onions, shallots, and a heavy pinch of salt; toss to coat with oil. Reduce heat to low and allow onions and shallots to soften, then caramelize for about 15 minutes, stirring often. Chop tomatoes coarsely. Combine all ingredients in a large saucepan and bring to a boil, uncovered. The pan should be no more than half full, because jam tends to bubble up so much that it might overflow. Cook about 30–40 minutes, stirring often, until reduced and thickened. The jam takes on a translucent quality when it is getting close to done. To test, put a drop on a chilled plate—if it holds together, it’s done; if it leaks liquid at the edges, it needs a little more time.