Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are Managed Beans not loaded in Tomcat?

Tags:

I created a JSF 2 web application with facelets. The libs for JSF where stored at tomcat/lib, to share it between several applications. I thought maybe it would be better to store the libs inside the WEB-INF/lib folder of the application, to get the application more independent from server configurations.

Now when I start tomcat via eclipse, the managed beans are loaded and working. But when I start tomcat directly / standalone the managed beans are not loaded automatically. I used

@ManagedBean
@SessionScoped / @RequestScoped

annotations to declare classes as managed beans.

Why is this? What can I do to fix it?

I don't use any faces-config.xml file yet.

Thanks in advance.

edited:

Maybe this helps to see whats going on:

javax.el.PropertyNotFoundException: /Artikel.xhtml @12,108 value="#{artikelBackingBean.nameFilterPattern}": Target Unreachable, identifier 'artikelBackingBean' resolved to null
    at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:93)
    at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
    at javax.faces.component.UIInput.validate(UIInput.java:934)
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1189)
    at javax.faces.component.UIInput.processValidators(UIInput.java:691)
    at javax.faces.component.UIForm.processValidators(UIForm.java:243)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1180)
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:619)
like image 374
c0d3x Avatar asked Mar 03 '10 09:03

c0d3x


People also ask

What is the difference between managed bean and backing bean?

1) BB: A backing bean is any bean that is referenced by a form. MB: A managed bean is a backing bean that has been registered with JSF (in faces-config. xml) and it automatically created (and optionally initialized) by JSF when it is needed.

How does Managed Bean work?

Managed Bean is a regular Java Bean class registered with JSF. In other words, Managed Beans is a Java bean managed by JSF framework. Managed bean contains the getter and setter methods, business logic, or even a backing bean (a bean contains all the HTML form value). Managed beans works as Model for UI component.

What is meant by managed beans?

Managed beans are container-managed objects with minimal supported services, such as resource injection, life cycle callbacks and interceptors, and have the following characteristics: A managed bean does not have its own component-scoped java:comp namespace.

Why do we need to define a managed bean?

The managed-bean-class element defines the fully qualified name of the JavaBeans component class used to instantiate the bean. It is the application developer's responsibility to ensure that the class complies with the configuration of the bean in the application configuration resource file.


1 Answers

The jsf find beans in WEB-INF/classes, when started with tomcat:run the classes isn´t this location.

Use mvn tomcat:run-war, worked for me.

like image 194
Luiz Henrique Avatar answered Sep 28 '22 19:09

Luiz Henrique