1

Actually I'm introducing myself into JSF. For that reason I copied the project from this location: http://www.concretepage.com/spring-4/spring-4-jsf-2-integration-example-using-autowired-annotation Setup:

  • OpenSUSE 13.2
  • JDK-1.8.0_77
  • Gradle 3.0
  • Spring 4
  • JSF-2
  • Apache Tomcat 8.0.33
  • Eclipse MARS 2 (4.5.2)

Building this project with "gradle build" and deploy it manually to Tomcat and access an URL works just fine. So this project seems to be OK. So I try the same procedure inside eclipse with a configurated server. But as soon as I access the same URL, I'm getting an IllegalStateException (No WebApplicationContext found: no ContextLoaderListener registered?).

java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
  org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:81)
  org.springframework.web.jsf.el.SpringBeanFacesELResolver.getWebApplicationContext(SpringBeanFacesELResolver.java:90)
  org.springframework.web.jsf.el.SpringBeanFacesELResolver.getBeanFactory(SpringBeanFacesELResolver.java:78)
  org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:49)
  com.sun.faces.el.DemuxCompositeELResolver._getValue(Unknown Source)
  com.sun.faces.el.DemuxCompositeELResolver.getValue(Unknown Source)
  org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:94)
  org.apache.el.parser.AstValue.getValue(AstValue.java:137)
  org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
  com.sun.faces.facelets.el.TagValueExpression.getValue(Unknown Source)
  javax.faces.component.ComponentStateHelper.eval(Unknown Source)
  javax.faces.component.ComponentStateHelper.eval(Unknown Source)
  javax.faces.component.UIOutput.getValue(Unknown Source)
  javax.faces.component.UIInput.getValue(Unknown Source)
  com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(Unknown Source)
  com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(Unknown Source)
  com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(Unknown Source)
  javax.faces.component.UIComponentBase.encodeEnd(Unknown Source)
  javax.faces.component.UIComponent.encodeAll(Unknown Source)
  javax.faces.render.Renderer.encodeChildren(Unknown Source)
  javax.faces.component.UIComponentBase.encodeChildren(Unknown Source)
  javax.faces.component.UIComponent.encodeAll(Unknown Source)
  javax.faces.component.UIComponent.encodeAll(Unknown Source)
  javax.faces.component.UIComponent.encodeAll(Unknown Source)
  com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(Unknown Source)
  com.sun.faces.application.view.MultiViewHandler.renderView(Unknown Source)
  com.sun.faces.lifecycle.RenderResponsePhase.execute(Unknown Source)
  com.sun.faces.lifecycle.Phase.doPhase(Unknown Source)
  com.sun.faces.lifecycle.LifecycleImpl.render(Unknown Source)
  javax.faces.webapp.FacesServlet.service(Unknown Source)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

I think this exception is already seen pretty often. I've tried serveral confirmed solutions, but all of them mess up the simplicity of the project. Also the manual deployment is working, so I don't think there is something wrong with the project itself. (e.g. adding a context-listener,...)

I'm pretty sure, there is something wrong with the configuration of the server or the project inside eclipse.

I compared several settings against the standalone-tomcat:

  • Usage of the same JRE
  • configuration of project's libs and deployment-assembly
  • eclipse launch-configuration by ps -Af

Also neither warnings nor errors are printed into the console-log. I added a breakpoint to WebAppInitializer.onStartup. This breakpoint was not visited.

Do you have other suggestions what to check or even a solution for this?

-- Solution -- Could it be that simple?

Next day I started the enviroment again. I added an index.jsp (I didn't configure the web.xml) started the tomcat inside eclipse. It worked. Afterwards I removed the index.jsp restarted my complete enviroment, redeployed and it is still working.

I think the solution is a simple restart (simple eclipse-caching-problem). I don't get the point, why adding a file should influence the bootstrap.

Thanks in advice

Mike

6
  • Because your web app have no entry point (index.jsp). Add a simple index.jsp into webapp directory. Try localhost:8080/student.xhtml, enter number 2, then submit, you will see result. Commented Sep 6, 2016 at 7:45
  • @Do Nhu Vy: Hi there. What exactly will change in eclipse, if I add an index.jsp? As I mentioned in the question: "It works on a standalone-tomcat". Nevertheless I tried your solution. It works finally, but I'm not quite sure if it was the single add of a jsp or the complete restart of my system to solve the problem. After I saw the project running in eclipse, I removed the *.jsp again and restarted the full enviroment again. It still keeps running. For me my problem is solved but I want to understand what was going on there. Commented Sep 6, 2016 at 7:58
  • @Do Nhu Vy: As the only reason for adding the index.jsp is to have an entry-point. I'm pretty sure this answere won't work generally. Entry-Points don't need to be configured. 404 will be the result by accessing not mapped urls. Commented Sep 6, 2016 at 8:09
  • I have been seen your sample source code in IntelliJ IDEA Ultimate IDE, run it on Mac OS X 10.11.6, see its error at first step. Merely, you add a entry point (index.jsp) is enough. Your sample source code has a mistake. Commented Sep 6, 2016 at 8:21
  • Did you try to achive the student.xhtml in IntelliJ without entry-point? Commented Sep 6, 2016 at 8:27

1 Answer 1

1

It seems to be a simple eclipse-chaching-problem. Here is the reason why (additionally I added this information to the question)

Next day I started the enviroment again. I added an index.jsp (I didn't configure the web.xml) started the tomcat inside eclipse. It worked. Afterwards I removed the index.jsp restarted my complete enviroment, redeployed and it is still working.

I think the solution is a simple restart.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.