[forge-users] Problem with unmarshalling resource with jaxb unmarshaller

Lincoln Baxter, III lincolnbaxter at gmail.com
Fri Mar 2 12:41:58 EST 2012


That's very strange. Perhaps the session manager is not serializable? Or is
somehow @XmlTransient?

Can you copy the fields you need into a DTO before you send it over the
wire?

~Lincoln

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

>  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 at 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 at 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 listforge-users at lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/forge-users
>
>
> _______________________________________________
> forge-users mailing list
> forge-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/forge-users
>
>


-- 
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-users/attachments/20120302/e59ebab9/attachment.html 


More information about the forge-users mailing list