0 Replies Latest reply on May 21, 2010 7:22 AM by adireddi.aswin

    EJB and JBOSS AS 5.0: Null Pointer Exception in StatelessSessionContainer

      Hi,

       

      I'm having an issue during the invocation of method in the ejb. Need some help

      Details:

      I have deployed an stateless EJB (myejb.jar) and a Client(ejbwar.war) in JBOSS AS5.0GA.

       

      The contents of myejb.jar are as follows-

       

      Home Intf: MyBeanHome

      RemoteIntf: MyBeanRemote

      Bean Class: MyBean (has a method called noop(String arg) apart from default methods)

       

      My ejb-jar.xml contains the following-

          <enterprise-beans>
              <session>
                  <ejb-name>MyBean</ejb-name>
                  <home>com.my.MyBeanHome</home>
                  <remote>com.my.MyBeanRemote</remote>
                  <ejb-class>com.my.MyBean</ejb-class>
                  <session-type>Stateless</session-type>
                  <transaction-type>Container</transaction-type>                      
              </session>
          </enterprise-beans>   
          <assembly-descriptor>     
              <security-role>
                  <role-name>EJBAdmin</role-name>
              </security-role>
             
              <method-permission>
                  <role-name>EJBAdmin</role-name>
                  <method>
                      <ejb-name>MyBean</ejb-name>
                      <method-name>*</method-name>
                  </method>
              </method-permission>
              <method-permission>
                  <role-name>EJBAdmin</role-name>
                  <method>
                      <ejb-name>MyBean</ejb-name>
                      <method-name>create</method-name>
                  </method>
                  <method>
                      <ejb-name>MyBean</ejb-name>
                      <method-name>remove</method-name>
                  </method>

              </method-permission>       
          </assembly-descriptor>

       

      My jboss.xml contains the following-

       

      <security-domain>java:/jaas/jacc-test</security-domain>   
          <enterprise-beans>
              <session>
                  <ejb-name>MyBean</ejb-name>
                  <jndi-name>jacc-test/MyBean</jndi-name>           
              </session>       
          </enterprise-beans>       
          <container-configurations>
          <!-- Override the role mapping function from that of the
              security-domain setting for stateless session beans -->
              <container-configuration>
              <!-- Use the standardjboss.xml container-name so we only have
                  to specify the elements we want to override -->
                  <container-name>Standard Stateless SessionBean</container-name>
                  <role-mapping-manager>java:/jaas/session-roles</role-mapping-manager>
              </container-configuration>
          </container-configurations>

       

      The contents of ejbwar.war are as follows-

       

      2 jsps: index (Submit button to invoke the noop method in the ejb) and response.

      Servlet: EJBClient.java

      Code:

      InitialContext ctx = new InitialContext();

      com.my.MyBeanHome myHome =(com.my.MyBeanHome)ctx.lookup("java:comp/env/ejb/MyBean");

      com.my.MyBeanRemote myEjb=myHome.create();

      String ejbMsg=myEjb.noop(""); << Getting an error here

       


      web.xml:

      <servlet>
              <servlet-name>dummy</servlet-name>
              <servlet-class>EjbClient</servlet-class>
          </servlet>
          <servlet-mapping>
              <servlet-name>dummy</servlet-name>
              <url-pattern>/servlet/*</url-pattern>
          </servlet-mapping>
         
          <welcome-file-list>
              <welcome-file>index.jsp</welcome-file>
          </welcome-file-list>
           
          <security-constraint>
              <web-resource-collection>
                  <web-resource-name>All Resources</web-resource-name>
                  <description>Declarative security tests</description>
                  <url-pattern>/servlet/*</url-pattern>           
                  <http-method>GET</http-method>
                  <http-method>POST</http-method>
              </web-resource-collection>
              <auth-constraint>
                  <role-name>EJBAdmin</role-name>
              </auth-constraint>
          </security-constraint>

       

          <login-config>
              <auth-method>BASIC</auth-method>
              <realm-name>Sample EJB Realm</realm-name>
          </login-config>

       

          <security-role>
              <role-name>EJBAdmin</role-name>
          </security-role>     
          <ejb-ref>
              <ejb-ref-name>ejb/MyBean</ejb-ref-name>
              <ejb-ref-type>Session</ejb-ref-type>
              <home>com.rsa.MyBeanHome</home>
              <remote>com.rsa.MyBeanRemote</remote>
          </ejb-ref>

       

      jboss-web.xml:

       

      <security-domain>java:/jaas/jacc-test</security-domain>
            <ejb-ref>
                   <ejb-ref-name>ejb/MyBean</ejb-ref-name>
                   <jndi-name>jacc-test/MyBean</jndi-name>
           </ejb-ref>

       

      I have configured by security domain in login-config.xml under the name jacc-test, where i have a custom login module for authentication. The authentication succeeds, but while invoking the noop(""), server throws the following error-

       

      ERROR [STDERR] java.lang.NullPointerException

      ERROR [STDERR]     at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:187)
      ERROR [STDERR]     at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:650)
      ERROR [STDERR]     at org.jboss.ejb.Container.invoke(Container.java:1029)
      ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:597)
      ERROR [STDERR]     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
      ERROR [STDERR]     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
      ERROR [STDERR]     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      ERROR [STDERR]     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      ERROR [STDERR]     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
      ERROR [STDERR]     at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
      ERROR [STDERR]     at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
      ERROR [STDERR]     at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:209)
      ERROR [STDERR]     at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:195)
      ERROR [STDERR]     at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
      ERROR [STDERR]     at org.jboss.proxy.ejb.SecurityContextInterceptor.invoke(SecurityContextInterceptor.java:64)
      ERROR [STDERR]     at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:68)
      ERROR [STDERR]     at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:112)
      ERROR [STDERR]     at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:101)
      ERROR [STDERR]     at $Proxy99.noop(Unknown Source)
      ERROR [STDERR]     at EjbClient.processRequest(EjbClient.java:58)
      ERROR [STDERR]     at EjbClient.doGet(EjbClient.java:16)
      ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
      ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      ERROR [STDERR]     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      ERROR [STDERR]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      ERROR [STDERR]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
      ERROR [STDERR]     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
      ERROR [STDERR]     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
      ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      ERROR [STDERR]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      ERROR [STDERR]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      ERROR [STDERR]     at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      ERROR [STDERR]     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567)
      ERROR [STDERR]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      ERROR [STDERR]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      ERROR [STDERR]     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
      ERROR [STDERR]     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
      ERROR [STDERR]     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      ERROR [STDERR]     at java.lang.Thread.run(Thread.java:619)

       

      Question:

      Am I missing some configurations or is my approach incorrect?

      Whats the reason for Null Pointer Exception?

      I have looked up regarding this issue and couldnt find much help.

      Any help would be appreciated.

      Thanks in advance!