Sunday, October 28, 2012

Tomcat:run will cause backing bean target unreachable

The same piece of source code is working just fine without Maven but there is error whenever run running with maven goal tomcat:run.

/hello.xhtml @16,59 value="#{helloBean.name}": Target Unreachable, identifier 'helloBean' resolved to null

This appear that there is a backing bean called HelloBean is not being configure properly. But looking at the programming syntax, everything is just fine and perfect. See the piece below:

I just discover something from @alehro's answer in stackoverflow. That problem is actually referring to Jetty but surprisingly this is also apply to Tomcat. The workaround on this problem is to change the maven goal to tomcat:run-war.

Saturday, October 27, 2012

Accidently configure javax.servlet-api to compile scope

There is a mistake in maven configuration. Actually I am trying to run a maven build with this command install tomcat:run in maven goal. But maven lead me to this error:

java.lang.ClassCastException: javax.faces.webapp.FacesServlet cannot be cast to javax.servlet.Servlet

Guess what? I have mistakenly configure the javax.servlet-api to compile scope. Basically Tomcat has already provide this package, thus it is not require to deploy again. To fix this, just set the scope to provided and I am done.

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.

Sunday, October 14, 2012

Exception throw when rendering JSF with JSP extension?

I didn't know that there could be an error when I am trying to render a JSF application with JSP extension.

I was running my Tomcat server. With JSF servlet mapping like this:


Suppose I should enter this URL http:// localhost:8080 / web6 / sample.jsf, and change the JSF extension to JSP, this could turn Tomcat server throwing an exception javax.servlet.jsp.JspException: Cannot find FacesContext:

Full stack trace: