Just tried the new snapshot, and there's still some problems. The container fails with the exception:
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lorg.hibernate.boot.registry.selector.StrategyRegistrationProvider;
at org.hibernate.osgi.OsgiPersistenceProvider.generateSettings(OsgiPersistenceProvider.java:133)[422:org.hibernate.osgi:4.3.0.SNAPSHOT]
at org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:102)[422:org.hibernate.osgi:4.3.0.SNAPSHOT]
The problem is in the class OsgiServiceUtil.
public <T> T[] getServiceImpls(Class<T> contract) {
final ServiceTracker serviceTracker = getServiceTracker( contract.getName() );
try {
T[] services = (T[]) serviceTracker.getServices();
if ( services != null ) {
return services;
}
}
catch (Exception e) {
LOG.unableToDiscoverOsgiService( contract.getName(), e );
}
return (T[]) Array.newInstance( contract, 0 );
}
You need to use Array.newInstance on both return statements since serviceTracker will return an Object array. Else, you'll get a ClassCastException when the variable of type Object[] is returned and assigend to StrategyRegistrationProvider[].
|