Java Opensaml接收正确的解组器时出错

Java Opensaml接收正确的解组器时出错,java,nullpointerexception,null,marshalling,opensaml,Java,Nullpointerexception,Null,Marshalling,Opensaml,我正在opensaml2.6上运行此代码 Element metadataRoot = document.getDocumentElement(); // Unmarshall UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(metadataRoot);

我正在opensaml2.6上运行此代码

Element metadataRoot = document.getDocumentElement();

// Unmarshall
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(metadataRoot);
if (unmarshaller == null) {
    System.out.println("Error receiving unmarshaller for this document.");
    return;
}
对于文档

<?xml version="1.0" encoding="UTF-8"?><saml2:EncryptedAssertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">


Unmarshaller
返回一个
null
,您能帮助我了解查找正确的
Unmarshaller
的标准是如何的,以及它在opensaml中是如何工作的吗?

我发现没有Unmarshaller寄存器,因为库中没有初始化:

重要代码:

// Initialize the library
DefaultBootstrap.bootstrap();

在OpenSAML3中,您必须首先确保在依赖项中包含
opensaml saml impl
工件,因为所有封送器和解封送器都在那里实现


然后,正如@Goblins和@Pegerto所指出的,您必须调用
InitializationService.initialize()
。我发现这个链接在使用依赖项注入进行正确初始化时非常有用

我发现没有解组器寄存器,因为库中没有初始化:重要代码://初始化库DefaultBootstrap.bootstrap();谢谢你,佩格托,你节省了我的时间我使用OpenSaml3的地方是:
InitializationService.initialize()
,但我仍然从MarshallerFactory获得空值。有人能帮忙吗?@小妖精,我也没有运气。在OpenSAML3中,我按照以下代码进行初始化:然后是unmarshallerFactory。getUnmarshallers()返回9个解组器(例如整数、布尔值、字符串),但对于我关心的解组器没有返回。