ops4j / org.ops4j.pax.cdi

Contexts and Dependency Injection for OSGi
Apache License 2.0
34 stars 26 forks source link

JSF Beans cannot be resolved [PAXCDI-210] #255

Closed ops4j-issues closed 6 years ago

ops4j-issues commented 8 years ago

Former user created PAXCDI-210

If you setup Karaf 4.0.3 with OpenWebBeans and try to run the pax-cdi-sample4-jsf it deploys and runs without any error, but as soon as you hit the Vote Button of the poll.xhtml nothing happens, you should see "Your choice: whatever you have chossen" and in the console you should see the System.out.println (form submitted) from the submit method of the FrameworkBean, but neither of both happens, if you add a command button like:

<p:commandButton value="CLICK ME!" action="#{framework.submit}" ajax="false" />

inside the form and hit that button you'll get a javax.el.PropertyNotFoundException:

javax.servlet.ServletException: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'framework' resolved to null
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:230)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:271)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:497)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.myfaces.view.facelets.el.ContextAwarePropertyNotFoundException: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'framework' resolved to null
    at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getType(ContextAwareTagValueExpression.java:79)
    at org.apache.myfaces.shared.renderkit._SharedRendererUtils.findUIOutputConverter(_SharedRendererUtils.java:78)
    at org.apache.myfaces.shared.renderkit.RendererUtils.findUIOutputConverter(RendererUtils.java:543)
    at org.apache.myfaces.shared.renderkit.RendererUtils.getConvertedUISelectOneValue(RendererUtils.java:982)
    at org.apache.myfaces.shared.renderkit.html.HtmlMenuRendererBase.getConvertedValue(HtmlMenuRendererBase.java:153)
    at org.primefaces.component.selectonemenu.SelectOneMenuRenderer.getConvertedValue(SelectOneMenuRenderer.java:60)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:662)
    at javax.faces.component.UIInput.validate(UIInput.java:598)
    at javax.faces.component.UIInput.processValidators(UIInput.java:274)
    at javax.faces.component.UIForm.processValidators(UIForm.java:210)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1457)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1457)
    at javax.faces.component.UIViewRoot._processValidatorsDefault(UIViewRoot.java:1697)
    at javax.faces.component.UIViewRoot.access$600(UIViewRoot.java:77)
    at javax.faces.component.UIViewRoot$ProcessValidatorPhaseProcessor.process(UIViewRoot.java:1804)
    at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1653)
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:909)
    at org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValidationsExecutor.java:38)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:196)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    ... 21 more
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'framework' resolved to null
    at org.apache.el.parser.AstValue.getTarget(AstValue.java:72)
    at org.apache.el.parser.AstValue.getType(AstValue.java:56)
    at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:171)
    at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getType(ContextAwareTagValueExpression.java:75)
    ... 41 more

Affects: 0.13.0 Fixed in: 1.0.0 Votes: 5, Watches: 6


Referenced issues

relates to:

ops4j-issues commented 8 years ago

Guillaume Nodet commented

Could you please provide a completely reproductible test / instructions based on pax-cdi 1.0.0-SNAPHOT / pax-web-4.4.0-SNAPSHOT please ?

ops4j-issues commented 8 years ago

Marc Schlegel commented

Pax-Cdi-Extension has a uses-constraint on org.osgi.dto which is provided by R6 runtimes. Pax-Web 4.x still uses OSGi R5. You might want to check your backport from Pax-Web 6.0.0 to 4.4.x.

I've added a integration-tests in master for Jetty and Undertow to master but not all injections work as desired.

ops4j-issues commented 8 years ago

Guillaume Nodet commented

The dependency is that pax-cdi depends on pax-web, not the opposite, so I don't think this is a very big problem that pax-cdi depends on R6 while pax-web depends on R5.

ops4j-issues commented 8 years ago

Guillaume Nodet commented

Is it expected that SomeSessionBean is annotated with @javax.faces.bean.SessionScoped instead of @javax.enterprise.context.SessionScoped ?

ops4j-issues commented 8 years ago

Guillaume Nodet commented

I have some changes to make the various combinations of openwebbeans/weld/jetty/undertow work, but I don't think any of them has been integrated with JSF.

The pax-cdi-undertow-weld bundle has some support for JSF, but I haven't been able to make it work so far:

I haven't seen any way to augment the pax-web WebApp application so far, so I think I'll defer this issue.

ops4j-issues commented 8 years ago

Guillaume Nodet commented

I've pushed my changes to clean / fix pax-cdi / pax-web integration with
https://github.com/ops4j/org.ops4j.pax.cdi/commit/1f8604e11e773f25d254fc01c10ade409370a949

This doesn't provide CDI / JSF support though.

ops4j-issues commented 8 years ago

Marc Schlegel commented

I've fixed the wrong annotation for SessionScoped in the sample. @javax.enterprise.context.SessionScoped should be used.

ops4j-issues commented 7 years ago

Marc Schlegel commented

Any update on this issue? Do we need to do something on Pax-Web side?

ops4j-issues commented 6 years ago

Grzegorz Grzybek commented

On pax-web side, I added some important improvements, so pax-cdi + jsf works. There's even dedicated integration test. The change is here.

Summarizing the change, I ensured that the listeners declared in faces-config.xml fragments are NOT registered too early (during web app parsing), but rather by org.ops4j.pax.web.jsp.JasperInitializer.

There's canonical example created here.

And changes in pax-cdi itself are pending in this branch. I hope to have them merged soon.

ops4j-issues commented 6 years ago

Grzegorz Grzybek commented

The change in pax-cdi is committed here