Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

jakarta ee - java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/MessagingException

I have a maven dependency for javaee Bibliothek.

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

I get the error in Eclipse in some classes.

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

I added javax.mail dependency.

<dependency>
    <groupId>javax.mail</groupId>
    <artifactId>mail</artifactId>
    <version>1.4.5</version>
</dependency>

It did not not work. Any Idea??

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It did not work because classes from javax/javaee-api/provided dependency are specially constructed. They are not usable runtime because implementation of methods is missing.

Simply adding classes from javax.mail/mail/1.4.5 dependency to the classpath does not help, because classes from javax/javaee-api/provided are already there. Having javax.mail/mail/1.4.5 dependecy alone solves your problem, but most likely you also need other classes from javax/javaee-api/provided.

What you can do is to get rid of javax/javaee-api/provided dependency and get these classes for example from the dependencies provided by target application server. You can use for example following:

   <dependency>
        <groupId>org.jboss.spec</groupId>
        <artifactId>jboss-javaee-6.0</artifactId>
        <version>1.0.0.Final</version>
        <type>pom</type>
        <scope>provided</scope>
     </dependency>

Because scope is provided, it does not affect the artifact to be built. That's why you can use this one also with other application servers than JBoss. It is same API as in your original dependency, but it contains normal classes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...