1 Reply Latest reply on Dec 8, 2011 6:15 AM by krzychk2

    JBOSS 5 jsf 1.2 and EJB 3.0 injection gives always NullPointerException

    krzychk2

      Hi.

       

      I am sitting on that problem for a couple of days.

       

      I am a beginer in jsf/ejb technology.

      I have a problem with EJB injection to the JSF managed bean. I have read all the google url's I have found and still nothing.

      I have attached my whole project.

       

      I have a Statless bean called PassManBean with local and remote interfaces. The catch is that EJB bean uses identities to manage access rights to the methods.

       

      Then I have created a ManagedBean called AddObjectManagedBean witch has

       

      @EJB(name="ejb/PassManEJBBean")
      private PassManBeanRemote passManBean;

       

      faces-config.xml

      <managed-bean>

        <managed-bean-name>addObjectManagedBean</managed-bean-name>

        <managed-bean-class>pl.info.kardas.passman.jsf.AddObjectManagedBean</managed-bean-class>

        <managed-bean-scope>request</managed-bean-scope>

      </managed-bean>

       

      web.xml

      <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

       

      <ejb-ref>

        <ejb-ref-name>ejb/PassManEJBBean</ejb-ref-name>

        <ejb-ref-type>Session</ejb-ref-type>

        <home>pl.info.kardas.passman.ejb.PassManBean</home>

        <remote>pl.info.kardas.passman.ejb.PassManBeanRemote</remote>

      </ejb-ref>

       

      jboss-web.xml

      <ejb-ref>

          <ejb-ref-name>ejb/PassManEJBBean</ejb-ref-name>

          <jndi-name>PassMan/PassManBean/remote</jndi-name>

      </ejb-ref>

       

      When I have tryied to run application it gives me:

       

      21:02:05,928 ERROR [STDERR] java.lang.NullPointerException

      21:02:05,929 ERROR [STDERR]     at pl.info.kardas.passman.jsf.AddObjectManagedBean.<init>(AddObjectManagedBean.java:44)

      21:02:05,929 ERROR [STDERR]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

      21:02:05,929 ERROR [STDERR]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

      etc...

       

      I really do not have any idea why this is not working. Please help

        • 1. Re: JBOSS 5 jsf 1.2 and EJB 3.0 injection gives always NullPointerException
          krzychk2

          After some debug and investigation I have found out where is the problem.

           

          The EJB Bean PassManBean is secured. To call this from external bean I have to use org.jboss.security.jndi.LoginInitialContextFactory. In other way I always get Authentication Denided.

           

          For my JSF web aplication I am also using container security, so is there a possibility to propagate the security context from ManagedBean to EJB?