Try closing that FileOutputStream you are marshalling to before you sync
with the refreshLocal call
-W
On 7/1/09, AudreyK <craukette_at_gmail.com> wrote:
>
>
> I am writing an Eclipse plugin that creates a project in the Workspace, and
> I
> have to access to some files contained is this project. Especially, I have
> to read an XML file, do some stuff, and then update this file. I use JAXB
> 2.0 for this.
> Everything works fine, excepted that when I try to open my modified XML
> file
> within Eclipse, an "Resource is out of sync with the file system" exception
> occures. The only way to avoid this problem is to refresh the Workspace
> using F5, but I really need to do this programatically (because I don't
> want
> the plugin's users to hit F5 each time the file has to be synchronized !!).
> Here's a code snippet:
>
> IFolder metaInfFolder = myContainer.getFolder(new
> Path(Constants.metaInfDir));
> IFile configFile =
> metaInfFolder.getFile(Constants.mmp_config);
> String configFilePath = configFile.getLocation().toString();
>
> try {
> JAXBContext jc =
> JAXBContext.newInstance(Constants.MODULE_CONFIGURATION_PACKAGE);
> Marshaller m = jc.createMarshaller();
> m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
> Boolean.TRUE);
> m.marshal(finalConf, new
> FileOutputStream(configFilePath));
>
> // Trying to refresh file here
> configFile.refreshLocal(IResource.DEPTH_ZERO, null);
>
> } catch (JAXBException e) {
> e.printStackTrace();
> } catch (FileNotFoundException e) {
> e.printStackTrace();
> } catch (CoreException e) {
> e.printStackTrace();
> }
>
> Do you have some hints on this issue ?
> Thank you for your replies,
> Audrey
> --
> View this message in context:
> http://www.nabble.com/Out-of-sync-issue-with-JAXB-tp24292429p24292429.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>