Hi Joachim,

Thanks for your response.

There is no mapping information and is using static Marshall/Unmarshall
methods. Here is that code:

private void save(String location, Object o) throws Exception {
        FileWriter writer = null;
        
        try {
                writer = new FileWriter(location);
                Marshaller.marshal(facet, o);
        } finally {
                writer.close();
        }
}

private <T> T load(String location, Class<T> c) throws Exception {
        FileReader reader = null;
        
        try {
            reader = new FileReader(location);
            return (T) Unmarshaller.unmarshal(c, reader);
        } finally {
            reader.close();
        }
}

The answers to the rest of your questions are all No.  The code is very
basic. We wanted something extremely simple so we started with this.

I can try using the non-static marshaller/unmarshaller, but can it be used
without a class specific mapping file?

Let me know if I can provide any more information.

Thanks,
Mohnish


Joachim Grüneis wrote:
> 
> Hello,
> I try to help you with some hints... but to be more precise
> I have not enough information
> 
> It seams that you use the static methods of marshaller and unmarshaller -
> this often leads to problems as no configuration step takes place which
> e.g.
> would load the mapping information...
> 
> so please instantiate an XMLContext, introduce the classes to map by using
> addClass or loadMapping, create marshaller and unmarshaller  instance and
> work with this instance - that might already solve your problem
> 
> on the other
> hand you might have a problem caused by class loading mechanisms of felix
> (OSGi)
> marshaling takes existing Java
> objects instances and serializes them into XML - no problem there, all
> Java classes are known and can easily be
> marshaled to XML without any mapping information...
> the other way round is more complicated
> Caster has to find a corresponding class for each element found in the XML
> and needs to be able to
> instantiate this class - this is where two problems might occur:
> 1) no matching class can be found, mapping information is not
> available cause static methods are used so nothing is unmarshalled
> 2) no matching class can be found because Castor is not allowed to
> access these classes because they are bound to a different class
> loader
> 
> These are just some ideas of what might have happend...
> 
> to really help it is required to know more about your implementation:
> Is an XSD definition existing?
> Has the Java code been generated using code generator?
> Have you included the .cdr files into the jar?
> Do you use a mapping file?
> How does the marshaling/unmarshaling code look like?
> 
> Hth Joachim
> 
> 2009/6/24 mohn3310 <[email protected]>
> 
>>
>> Hello,
>>
>> I'm using castor-xml in introspection mode to write out simple POJOs to
>> files (one POJO per file). I've written unit tests and verified that this
>> works. I've also inspected the files and made sure they have appropriate
>> xml.
>>
>> I then packaged this up into an osgi bundle and deployed it to a
>> container
>> (felix). For some reason when I run it, it ends up creating the file but
>> it
>> is empty... i.e. no xml in the file. Yet another strange thing is that I
>> use
>> Unmarshaller.unmarshall() to convert the xml files back to their
>> associated
>> POJOs. As a test I generated the xml by hand and it was able to load it.
>> So
>> Marshaller.marshall() doesn't work, but Unmarshaller.unmarshall() does!
>>
>> Any idea why it is behaving this way? Same code... works great
>> "normally",
>> but doesn't work inside an osgi container.
>>
>> Thanks,
>> Mohnish
>> --
>> View this message in context:
>> http://www.nabble.com/castor-xml-writing-empty-file-tp24175804p24175804.html
>> Sent from the Castor - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/castor-xml-writing-empty-file-tp24175804p24176402.html
Sent from the Castor - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to