我们收到此错误:
[ERROR] Caused by: java.lang.Throwable: WELD-000044 Unable to obtain instance from null
[ERROR] at org.jboss.weld.bean.builtin.CallableMethodHandler.invoke(CallableMethodHandler.java:48)
[ERROR] at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)
[ERROR] at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
[ERROR] at org.jboss.weldx.persistence.EntityManager$1841842027$Proxy$_$$_Weld$Proxy$.getCriteriaBuilder(EntityManager$1841842027$Proxy$_$$_Weld$Proxy$.java)
[ERROR] at org.picketlink.idm.jpa.internal.JPAIdentityStore.getPartitions(JPAIdentityStore.java:298)
[ERROR] at org.picketlink.idm.jpa.internal.JPAIdentityStore.get(JPAIdentityStore.java:290)
[ERROR] at org.picketlink.idm.internal.DefaultPartitionManager.getPartitions(DefaultPartitionManager.java:325)
[ERROR] ... 80 more
并进行调查,我可以看到这是根本原因:
DefaultPartionManager.java
抛出错误的方法:
public <T extends Partition> List<T> getPartitions(Class<T> partitionClass)
这里:
throw MESSAGES.partitionGetFailed(partitionClass, "not specified", e);
但是,当我们在 IDMConfiguration.java 中设置 PartitionTypeEntity.class 时,我对这个错误感到困惑:
@ApplicationScoped
public class IDMConfiguration {
@Inject
private EEJPAContextInitializer contextInitializer;
private IdentityConfiguration identityConfig = null;
@Produces
IdentityConfiguration createConfig() {
if (identityConfig == null) {
initConfig(null);
}
return identityConfig;
}
public void configureIdentityManagement(@Observes IdentityConfigurationEvent event) {
initConfig(event.getConfig());
}
public void initConfig(IdentityConfigurationBuilder builder){
if (builder == null){
builder = new IdentityConfigurationBuilder();
}
builder.named("default" + "").stores().jpa().mappedEntity(
AccountTypeEntity.class,
RoleTypeEntity.class,
GroupTypeEntity.class,
IdentityTypeEntity.class,
RelationshipTypeEntity.class,
RelationshipIdentityTypeEntity.class,
PartitionTypeEntity.class,
PasswordCredentialTypeEntity.class,
AttributeTypeEntity.class)
//UserImpl.class)
.supportGlobalRelationship(Relationship.class)
.addContextInitializer(this.contextInitializer)
.setCredentialHandlerProperty(PasswordCredentialHandler.SUPPORTED_ACCOUNT_TYPES_PROPERTY, UserImpl.class)
.supportAllFeatures();
identityConfig = builder.build();
}
}