+
+ // NOTE: adding datasource to JNDI is no longer needed for
+ // JPA testing, but is nice to have available for other uses.
+ StubInitialContextFactory.register();
+ try {
+ InitialContext ctx = new InitialContext();
+ ctx.bind(persistenceUnit.getJndiName(), dataSource);
+ } catch (NamingException e) {
+ throw new RuntimeException("JNDI problem", e);
+ }