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”
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.
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>184.108.40.206</version> <scope>provided</scope> </dependency>
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.