0

I am banging my head against the wall on this one...

My app runs well when deployed, really, I wonder why I need tests :).

mvn test gives me:

Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.008 sec <<< FAILURE!
testAddTo_Email(org.red_angus.utils.mail.test.MailMessageTest)  Time elapsed: 0.007 sec  <<< ERROR!
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/internet/InternetAddress
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)

Here is an abstract of the POM:

   <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>javax.mail-api</artifactId>
        <version>1.5.1</version>
    </dependency>

    <dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>mailapi</artifactId>
        <version>1.5.1</version>
    </dependency>

    <dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>smtp</artifactId>   
        <version>1.5.1</version>
    </dependency>

    <dependency>
        <groupId>net.htmlparser.jericho</groupId>
        <artifactId>jericho-html</artifactId>
        <version>3.3</version>
    </dependency>

Help me save my weekend ;)

jgp
  • 2,069
  • 1
  • 21
  • 40
  • 1
    http://stackoverflow.com/questions/15948598/classformaterror-absent-code-attribute-in-method-that-is-not-native-or-abstract – Jean Logeart Mar 15 '14 at 14:18

1 Answers1

2

From an other answer on SO:

The javax:javaee-api is only intended for compiling against, not for running against, including unit tests. If you need classes suitable for running against, you really need a full Java EE application server.

That's why it works when your app is deployed on a real app server and not while running tests.

Community
  • 1
  • 1
Jean Logeart
  • 52,687
  • 11
  • 83
  • 118