views:

325

answers:

2

Hi,

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)
+1  A: 

This is a sign that the webapp is using JSF 1.x instead of JSF 2.x. The configurator of JSF 1.x does not recognize @ManagedBean annotations which will cause that they're not loaded/initialized automagically without the need for faces-config.xml.

I would suspect some collision in the version of the JSF libraries used. Scan the entire classpath for JSF JAR files and use some zip/rar tool to determine the included MANIFEST.MF file for the actual JSF version. The classpath includes Tomcat/lib, JRE/lib/* and Webapp/WEB-INF/lib.

BalusC
A: 

Hi I have something similar. Always launching with eclipse : - When I start with : "Serve modules without publishing" option : it fails (no bean created) - When I start without : "Serve modules without publishing" option : it works (bean are created)

Maybe JSF2 only looks for @ManagedBean in WEB-INF/classes physically and do not scan the virtual classpath created for the not-deployed eclispe style, in whic case the .class are in a folder like /build/bin.

Did you solve your Pb ? does it match my own problem ? thanks

Gauthier