سؤال

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?

هل كانت مفيدة؟

المحلول

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"));

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top