I used Weld SE:
import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
And then simply
Weld weld = new Weld();
try {
WeldContainer container = weld.initialize();
URI baseUri = UriBuilder.fromUri("http://localhost/").port(8080).build();
ResourceConfig config = ResourceConfig.forApplicationClass(MyApplication.class);
Server server = JettyHttpContainerFactory.createServer(baseUri, config);
server.join();
} catch (Exception e) {
e.printStackTrace();
} finally {
weld.shutdown();
}
Note that HK2 will handle REST classes, so I had to write a binder to make the injection work in those classes. This question helped me a lot.