I have an OSGi
bundle with persistence service (using hibernate
) and a fragment, which contains configuration (xml file). In bundle's activator, I'm loading the configuration using:
@Override
public void start(BundleContext ctx) {
URL url = ctx.getBundle().getResource("hibernate.cfg.xml");
SessionFactory sessionFactory = new AnnotationConfiguration().configure(url).buildSessionFactory();
}
but sometimes, the URL
is null. When I've tried to list all available URL
s (using findEntries
method), it appeared that the bundle's own ones are available always, but the fragment ones only sometimes. I'm using Felix
4.0.2, the bundle and the fragment is started at the same Felix
. auto.start level.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…