0

During compilation i have an error: "annotation type not applicable to this kind of declaration". And details:

void someFunc(@XmlElement(required=true) MyClass someParam).

I use JDK 1.6.18 and @XmlElement not available in this version. I found that the main problem in JAXB (it's version). It was discussed here:
XmlElement annotation dissallowed with WebParam
Is it possible to replace the version of the JAXB implementation in Java JRE 1.6 SE?.

I updated JAXB in JDK by using endorsed method ($JAVA_HOME/lib/endorsed), but it still not work.

Q:
1. How i can be convinced that compiler use updated version of JAXB?
2. What else there can be incorrectness reasons?

2 Answers 2

2

You said that you updated this folder (JDK_HOME/lib/endorsed) but it should be $JAVA_HOME/lib/endorsed (or $JDK_HOME/jre/lib/endorsed)
In order to be sure that you have put the jars in the correct location, you can check the current location of the endorsed directory by doing

System.out.println(System.getProperty("java.endorsed.dirs"));
2
  • What was the output of the instruction?
    – baki
    Commented Apr 30, 2014 at 9:15
  • Current location of the endorsed dir (thanks for check!) differs. And with this location compilation is successful. Thank you! As a result: current location of the endorsed directory not necessarily "$JAVA_HOME/lib/endorsed", it must be checked.
    – slider
    Commented Apr 30, 2014 at 12:22
0

Jaxb is used to read from/write XML files, putting the annotation in the header of a method doesn't make any sens.

2
  • Watch links in my post.
    – slider
    Commented Apr 30, 2014 at 7:25
  • Annotating the method parameter is available since JAXB 2.2. Some WebService implementations wrap methods and their return values into XML request/reponse objects. The only way to set certain XML binding properties of params of such method with a code-first Java WebService is through method parameter annotation.
    – Boris B.
    Commented Apr 30, 2014 at 19:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.