1

我们收到此错误:

[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();
    }

}
4

1 回答 1

1

检查您的数据库,是否有“默认”PartitionTypeEntity 的条目?我认为您应该在开始使用它之前检查它是否存在。Picketlink 应该在您第一次使用它时自动创建一个默认分区,但我想有时它不会为您这样做。对我来说,在一个 中IDMInitializer,我必须首先检查是否有一个“默认”分区,如果没有,我必须Realm()在开始使用应用程序之前创建一个新分区。

    @Singleton
    @Startup
    public class IDMInitializer{
    @Inject
    private PartitionManager partitionManager;

    @PostConstruct
    public void init(){
            Realm defaultReam = this.partitionManager.getPartition(Realm.class, "default");
            if (defaultReam==null){
                    System.out.println("Couldn't find default partition, creating default partition");
                    defaultRealm = new Realm("default");
                    this.partitionManager.add(defaultRealm);
            } else {
                    System.out.println("Found default partition");
            }
    }
    }
于 2014-08-25T22:11:41.613 回答