in newer hibernate releases openejb: is restricted only java: and osgi: are allowed, however I tried every combination I can think of with java:,java:/,osgi:,osgi:/, just MYJPA and not scheme and all of them report jndi name not found. Has anyone been able to get hibernate working with tomee 9 or know the correct text to use for <*-data-source> tags ?
There is no beef
I guess that we didn’t think anyone would use a different prefix so we tried to get rid of some attack surface. If you create an issue in the issue tracker(https://hibernate.atlassian.net) and describe this situation I’ll make sure we work on this.
So one thing you could do until a Hibernate integration for Tomee is created, is to create a custom JndiService that allows parsing this path. To register that, you need a org.hibernate.service.spi.ServiceContributor which is a Java Service loader contract.
public class MyServiceContributor implements org.hibernate.service.spi.ServiceContributor {
@Override
public void contribute(StandardServiceRegistryBuilder serviceRegistryBuilder) {
serviceRegistryBuilder.addInitiator( MyJndiServiceInitiator.INSTANCE );
}
}
public final class MyJndiServiceInitiator implements StandardServiceInitiator<JndiService> {
public static final JndiServiceInitiator INSTANCE = new JndiServiceInitiator();
@Override
public Class<JndiService> getServiceInitiated() {
return JndiService.class;
}
@Override
public JndiService initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
return new MyJndiServiceImpl( configurationValues );
}
}
where MyJndiServiceImpl is more or less a copy of the existing JndiServiceImpl, but with code adapted to allow parsing the openejb namespace.
Note that this change was done to reduce the security attack surface, and as far as I understand, there is no desire to make it easier than what I described here to get back to the old behavior.