Fwd: marshallerFactory.getMarshaller(samlToken) returns a "null"
Brent Putman
putmanb at georgetown.edu
Wed Apr 10 11:30:16 EDT 2013
On 4/10/13 2:31 AM, Thomas Lionel SMETS (prof) wrote:
>
> Hello,
>
> I base my code on what I found here :
>
https://wiki.shibboleth.net/confluence/plugins/viewsource/viewpagesrc.action?pageId=3277019
The code that you have posted looks fine, as far as I can tell.
>
>
> but the marshaller returned by the "marshallerFactory" is always "null"
> thought listening to the logger "org.opensaml" shows no warning that the
> initialization is not OK :(
>
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.)
>
>
> [code]
> public byte[] marshall(final XMLObject samlToken) throws
> MarshallingException, ParserConfigurationException, TransformerException {
>
> if (LOG.isTraceEnabled())
> LOG.trace("Request to marshall : " +
> LoggingConstant.START_TRACE_TAG + samlToken.toString() +
> LoggingConstant.END_TRACE_TAG);
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.
>
> javax.xml.parsers.DocumentBuilder docBuilder;
> // Get the marshaller factory
> MarshallerFactory marshallerFactory =
> Configuration.getMarshallerFactory();
> // Get the Subject marshaller
> Marshaller marshaller =
> marshallerFactory.getMarshaller(samlToken); // marshaller is 'null'
> after this statement
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.
--Brent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/dev/attachments/20130410/fc6fba0e/attachment.html
More information about the dev
mailing list