<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
On 4/10/13 2:31 AM, Thomas Lionel SMETS (prof) wrote:<br>
<span style="white-space: pre;">><br>
> Hello,<br>
><br>
> I base my code on what I found here :<br>
>
<a class="moz-txt-link-freetext" href="https://wiki.shibboleth.net/confluence/plugins/viewsource/viewpagesrc.action?pageId=3277019">https://wiki.shibboleth.net/confluence/plugins/viewsource/viewpagesrc.action?pageId=3277019</a></span><br>
<br>
<br>
The code that you have posted looks fine, as far as I can tell.<br>
<br>
<br>
<br>
<span style="white-space: pre;">><br>
><br>
> but the marshaller returned by the "marshallerFactory" is
always "null" <br>
> thought listening to the logger "org.opensaml" shows no
warning that the<br>
> initialization is not OK :(<br>
></span><br>
<br>
<br>
As Scott already said: assuming that the library has been correctly
initialized with DefaultBootstrap, the issue is probably that you
are trying to marshall an XMLObject/Element for which there is no
registered marshaller. What is that XMLObject's QName (and also its
xsi:type, if there is one? (Most won't have an xsi:type, unless
you've explicitly added one.)<br>
<br>
<br>
<br>
<span style="white-space: pre;">><br>
><br>
> [code]<br>
> public byte[] marshall(final XMLObject samlToken) throws<br>
> MarshallingException, ParserConfigurationException,
TransformerException {<br>
><br>
> if (LOG.isTraceEnabled())<br>
> LOG.trace("Request to marshall : " +<br>
> LoggingConstant.START_TRACE_TAG + samlToken.toString() +<br>
> LoggingConstant.END_TRACE_TAG);</span><br>
<br>
What does this output actually say? There's also a better way to
log the element's "name". There is a method on the XMLObject that
exposes the element QName.<br>
<br>
<br>
<br>
<span style="white-space: pre;">><br>
> javax.xml.parsers.DocumentBuilder docBuilder;<br>
> // Get the marshaller factory<br>
> MarshallerFactory marshallerFactory =<br>
> Configuration.getMarshallerFactory();<br>
> // Get the Subject marshaller<br>
> Marshaller marshaller =<br>
> marshallerFactory.getMarshaller(samlToken); // marshaller is
'null'<br>
> after this statement</span><br>
<br>
<br>
Yeah, you're not doing anything wrong here, this is the correct
code. The problem is either in what you are trying to marshall, or
in something about the configuration, initialization, environment,
etc. On environmental issues: if you have an odd classloader
hierarchy, this can cause problems. If you just have all the
opensaml jars + deps in the same classloader as your app code, then
that's fine. But if you're trying to distribute them in some way in
a hierarchical classloader environment, that could possibly be
another issue.<br>
<br>
--Brent<br>
<br>
<br>
</body>
</html>