0

I would like to create XML Documents from XSD files on GWT-based server. Unfortunately I can't use the javax.xml.bind package, the compiler gives me the following error:

No source code is available for type javax.xml.bind.Marshaller; did you forget to inherit a required module?

I tried alternative libraries but they use the Marshaller or JAXBContext from the above package Parse XML file in GWT server-side. GWT's XML Parser doesn't work on the server side. Overriding the package implementation didn't work either. In addition I would like to validate XML files with the schema.

Edit solution:

I referred to the given solution and the links in my initial question. I couldn't get the JAXB-stuff to work on the client side, because there were too many dependencies and I don't like to add all source files in a new package. Nevertheless I can use the xml annotations in shared code. Due to the amount of explanations, their confusing style (my opinion) and the current year, I will explain my approach. It is the same as in other solutions, maybe a little bit easier to understand and totally based on Tassos Bassoukos from the accepted solution:

  1. Find your needed source file in your JDK. There is a source.zip folder in your installation folder.
  2. Create a package in your project based on the Overriding one package implementation with another. This new package path corresponds to the path of your desired Java files. Add the <super-source path="jre" /> annotation in your gwt.xml !
  3. Copy the files from (1.) in the new package and change their import declaration (All classes referencing the desired classes import the real java package path, not your custom one).
Community
  • 1
  • 1
Sincostan
  • 361
  • 2
  • 11

1 Answers1

1

You must keep the XML code out of the client or shared folder. You can use all classes and technologies on the server.

If you need to add annotations to shared classes, you need to add the xml annotations in a supersource path.

This is explained already here How to use JAXB annotations in the client side for GWT?

If this is not your issue, you may want to show some code you have tried that fails.

Community
  • 1
  • 1
thst
  • 4,592
  • 1
  • 26
  • 40
  • I actually put these lines in shared code. Didn't come to my mind in this moment. Will check on this tomorrow again and probably accept your answer, sounds good. Want to try it first though. – Sincostan Jun 08 '16 at 22:14
  • Thanks, I added a step-by-step solution to my initial question. – Sincostan Jun 09 '16 at 13:42