I am getting a strange ClassFormatError when using the javaMail api to send email on my spring mvc web app.
Below is my mail-cfg.xml
<
I too faced the same kind of exception when running junits with jmock and maven:
Exception in constructor: testDoExecute (java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/http/Cookie at java.lang.ClassLoader.defineClass1(Native Method)
It is due to classes your code try to access which are not available in the javaee api jar used in the project because your code compiles against incomplete classes, like the JavaEE6 Api and your Unit tests try to access code thats not there. JUnit will simply fail and mark the test as error, printing something like the above exception.
It could be solved either by adding javax.servlet jar/dependency or changing javaee jar version shown below:
javax.servlet
servlet-api
2.5
**OR**
javax.j2ee
j2ee
1.4
provided
PS: Please add the jar version compatible with your other existing jars in the project.