gpt4 book ai didi

java - 无法从 null 获取实例 - PicketLink

转载 作者:太空宇宙 更新时间:2023-11-04 06:46:28 25 4
gpt4 key购买 nike

我们收到此错误:

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

}

最佳答案

检查您的数据库,是否有“默认”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");
}
}
}

关于java - 无法从 null 获取实例 - PicketLink,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23913728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com