Fixing error “Absent Code attribute in method that is not native or abstract…”

Goal

Deal with an error message such as “Absent Code attribute in method that is not native or abstract in class file javax/servlet/http/HttpSessionEvent”

Description

Recently, during the execution of a Jenkins job to build a project and during the sonarqube integration to perform code analysis for that project, I had the error shown above.

After some Google searches, I realized it was related to one of the dependencies for the project: javaee (you may read more here.

How to

All I had to do was replace the javaee dependency with the equivalent dependency that contains not only the APIs name but also the method bodies. So, the following is that I did in order to make things work properly:

<!-- Remove the old dependency -->
<!--
<dependency>
  <groupId>javax</groupId>
  <artifactId>javaee-web-api</artifactId>
  <version>6.0</version>
<dependency>
-->
<!-- Include the equivalent dependency. E.g. -->
<dependency>
  <groupId>org.glassfish.main.extras</groupId>
  <artifactId>glassfish-embedded-all</artifactId>
  <version>3.1.2.2</version>
  <scope>provided</scope>
</dependency>

Explanations

Any time we get an “Absent code” error message, it means we have a dependency on our project in which that dependency does not contains the methods bodies but only the APIs names. So, in order to fix that kind of issue, all we should do is replacing that dependency with the equivalent that also contains the methods bodies.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s