The only reason I can think of as to why this isn't working is the
version of your
web.xml. Can you confirm it is 2.5?
glassfish_at_javadesktop.org wrote:
> Hi,
>
> I must be missing something obvious. I'm trying to implement my first JSF web application using EJBs, and I followed the patterns in the "dukesbank" example. I can spot nothing that I'm doing different from what is happening in the "dukesbank" webapp, but the first time an EJB is referenced from a backing bean I get a null pointer exception.
>
> The most simple scenario that fails is the following. I would be very grateful for any hint.
>
> I have a JSF page that gets a string from a backing bean's property:
>
> <h:outputText value="#{customerBean.demoString2}"/>
>
> These are the relevant code sections:
>
> The backing bean:
>
> public class CustomerBean {
> @EJB
> private CustomerSessionRemote customerSession;
>
> public CustomerBean() {
> }
>
> public String getDemoString2() {
> return customerSession.fetchTest();
> }
> }
>
> The remote interface of the session bean:
>
> @Remote
> public interface CustomerSessionRemote {
> public String fetchTest();
> }
>
> The implementation of the session bean:
>
> @Stateless
> @TransactionManagement(value=TransactionManagementType.CONTAINER)
> public class CustomerSession implements CustomerSessionLocal, CustomerSessionRemote {
>
> @javax.persistence.PersistenceContext(unitName="backoffice")
> private EntityManager em;
>
> public CustomerSession(){
> }
>
> public String fetchTest() {
> return "FETCH TEST";
> }
> }
>
> This is the exception when I access the JSF page for the first time:
>
> [#|2007-05-16T19:42:33.507+0200|WARNING|sun-appserver9.1|javax.enterprise.resource.webcontainer.jsf.lifecycle|_ThreadID=17;_ThreadName=httpSSLWorkerThread-8080-1;_RequestID=5817e8e1-7668-4fd3-8d7f-090652015169;|executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl_at_f1e6e4) threw exception
>
> javax.faces.FacesException: javax.el.ELException: java.lang.NullPointerException
>
> at javax.faces.component.UIOutput.getValue(UIOutput.java:176)
>
> at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:189)
>
> at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:320)
>
> at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:200)
>
> at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:833)
>
> at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:279)
>
> at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
>
> at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
>
> at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
>
> at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
>
> at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
>
> at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
>
> at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
>
> at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:244)
>
> at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:175)
>
> at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
>
> at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
>
> at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
>
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
>
> at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:398)
>
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
>
> at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:258)
>
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:189)
>
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
>
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
>
> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:81)
>
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:193)
>
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
>
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
>
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)
>
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)
>
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
>
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
>
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
>
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)
>
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)
>
> at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:255)
>
> at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:618)
>
> at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:549)
>
> at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:790)
>
> at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:326)
>
> at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:248)
>
> at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:199)
>
> at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:346)
>
> at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
>
> at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:93)
>
> Caused by: javax.el.ELException: java.lang.NullPointerException
>
> at javax.el.BeanELResolver.getValue(BeanELResolver.java:266)
>
> at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
>
> at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
>
> at com.sun.el.parser.AstValue.getValue(AstValue.java:125)
>
> at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:193)
>
> at javax.faces.component.UIOutput.getValue(UIOutput.java:173)
>
> ... 45 more
>
> Caused by: java.lang.NullPointerException
>
> at com.flabbergasting.web.beans.CustomerBean.getDemoString2(CustomerBean.java:23)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
>
> at javax.el.BeanELResolver.getValue(BeanELResolver.java:261)
>
> Thanks
> Stephan
> [Message sent by forum member 'smuehlst' (smuehlst)]
>
> http://forums.java.net/jive/thread.jspa?messageID=217447
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>