Saturday, October 27, 2012

JSF can only work with javax.servlet-api instead of servlet-api

Recently I come across this error when I am configuring maven for JSF development:

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

According to the answer given by BalusC in stackoverflow, he claim that:

"This problem is caused by having multiple FacesServlet class files of different versions in the runtime classpath, which in turn means that you've multiple JAR files containing the JSF API in the runtime classpath."

This give me a clue that I have did something wrong in the maven configuration. A quick spot on the maven configuration, I found out that I am using servlet-api package.

To get this fix, I replace servlet-api with javax.servlet-api.

No comments: