ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/MessagingException

后端 未结 4 905
轮回少年
轮回少年 2020-11-30 07:48

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

<         


        
4条回答
  •  庸人自扰
    2020-11-30 08:16

    You normally get this error when you have multiple conflicting JAR's in your class path. One of the more common reasons is if you include an artifact in your classpath that is supposed to be provided by the application container. Looking at your POM, you have several redundant and overlapping dependencies. Remove these:

    
        javax.servlet
        servlet-api
        2.5
        provided
    
    
        javax.validation
        validation-api
        1.0.0.GA
    
    
        javax.servlet
        jstl
        1.2
    
    
        javax.mail
        mail
        1.4.3
    
    
        javaee
        javaee-api
        5
    
    

    And change the scope of your Java EE dependency to 'provided':

    
        javax
        javaee-api
        6.0
        provided
    
    

    Finally, make sure you are deploying to a Java EE 6 capable web server, and the error should go away.

    --- Edit ---

    Just noticed that you are compiling to a Java 5 compliance level. Change this:

    
        1.5
        1.5
    
    

    And make the source and target values 1.6.

提交回复
热议问题