No exceptions..

In a way the unmarshalling is successful, but some content (session manager) is missing

Am 02.03.2012 17:27, schrieb Lincoln Baxter, III:
Are you getting any exceptions?

On Fri, Mar 2, 2012 at 11:22 AM, Max Schwaab <max.schwaab@akquinet.de> wrote:
Hey there,

I've got another tricky problem with my hibersap plugin

I'm using the HibersapJaxbXmlParser to parse a hibersap.xml file.
What the parser does is the following:

* creating a JAXB context [ jaxbContext = JAXBContext.newInstance(
HibersapConfig.class ); ]
* creating a JAXB unmarshaller [ unmarshaller =
jaxbContext.createUnmarshaller(); ]
* unmarshall the given resource stream [ unmarshalledObject =
unmarshaller.unmarshal( resourceStream ); ]

The problem is:
It unmarshalles the file to the correct class, but some content gets lost.

The funny thing:
If I try this in a seperate test without forge, it works!
The test is part of the plugin and can be found at the github repo
(https://github.com/forge/plugin-hibersap)

What I want it to do:
Unmarshall a hibersap.xml file and recognize the hibersap config AND the
session manager in the config.
Within Forge it seems to recognize only the hibersap config and not the
session manager.

The hibersap.xml is something like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<hibersap xmlns="http://hibersap.org/xml/ns/hibersap-config">
<session-manager name="SM001">
<context>org.hibersap.execution.jco.JCAContext</context>
        .
        .
        .
</session-manager>
</hibersap>

Here is the code from the HibersapJaxbXmlParser:

public HibersapConfig parseResource( final InputStream resourceStream,
final String resourceName )
            throws HibersapParseException
    {
        Unmarshaller unmarshaller;
        try
        {
            unmarshaller = jaxbContext.createUnmarshaller();
        }
        catch ( final JAXBException e )
        {
            throw new InternalHiberSapException( "Cannot create an
unmarshaller. ", e );
        }

        Object unmarshalledObject;
        try
        {
            unmarshalledObject = unmarshaller.unmarshal( resourceStream );
        }
        catch ( final JAXBException e )
        {
            throw new HibersapParseException( "Cannot parse the
resource " + resourceName, e );
        }
        if ( unmarshalledObject == null )
        {
            throw new HibersapParseException( "Resource " +
resourceName + " is empty." );
        }
        if ( !( unmarshalledObject instanceof HibersapConfig ) )
        {
            throw new HibersapParseException( "Resource " + resourceName
                    + " does not consist of a hibersap specification. I
found a "
                    + unmarshalledObject.getClass().getSimpleName() );
        }
        return ( HibersapConfig ) unmarshalledObject;
    }


Thank you for your help and best regards

Max

_______________________________________________
forge-users mailing list
forge-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-users



--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"


_______________________________________________
forge-users mailing list
forge-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-users