2 Replies Latest reply on Oct 10, 2006 6:31 AM by Wolfgang Knauf

    NullPointerException  in jboss calculator example

    ra ra Newbie

      i'm trying to run the following example and i'm getting NullPointerException

      http://trailblazer.demo.jboss.com/EJB3Trail/serviceobjects/sfsb/





      HTTP Status 500 -

      --------------------------------------------------------------------------------

      type Exception report

      message

      description The server encountered an internal error () that prevented it from fulfilling this request.

      exception

      org.apache.jasper.JasperException: Exception in JSP: /my-apps/calculator.jsp:70

      67:
      68: Past results
      69: <%
      70: int entries = cal.getStarts().size();
      71: %>
      72:
      73:


      Stacktrace:
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:585)
      org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
      java.security.AccessController.doPrivileged(Native Method)
      javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
      org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
      org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:161)
      java.security.AccessController.doPrivileged(Native Method)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:585)
      org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
      java.security.AccessController.doPrivileged(Native Method)
      javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
      org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
      org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:217)


      root cause

      java.lang.NullPointerException
      org.apache.jsp.my_002dapps.calculator_jsp._jspService(calculator_jsp.java:127)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:585)
      org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
      java.security.AccessController.doPrivileged(Native Method)
      javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
      org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
      org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:161)
      java.security.AccessController.doPrivileged(Native Method)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:585)
      org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
      java.security.AccessController.doPrivileged(Native Method)
      javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
      org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
      org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:217)


      note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.


      --------------------------------------------------------------------------------

      Apache Tomcat/5.5.17

        • 1. Re: NullPointerException  in jboss calculator example
          ra ra Newbie

          i manage to isolate the problem
          when i'm trying to run my jsp jboss says



          18:06:37,901 ERROR [STDERR] javax.naming.NameNotFoundException: EJB3Trail not bound
          18:06:37,903 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
          18:06:37,904 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
          18:06:37,905 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
          18:06:37,907 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
          18:06:37,908 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
          18:06:37,909 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
          18:06:37,911 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:351)
          18:06:37,912 ERROR [STDERR] at org.apache.jsp.my_002dapps.C_jsp._jspService(C_jsp.java:67)
          18:06:37,913 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
          18:06:37,915 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
          18:06:37,916 ERROR [STDERR] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
          18:06:37,917 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
          18:06:37,919 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
          18:06:37,920 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
          18:06:37,921 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          18:06:37,921 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          18:06:37,922 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          18:06:37,923 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
          18:06:37,924 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
          18:06:37,924 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
          18:06:37,926 ERROR [STDERR] at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
          18:06:37,926 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
          18:06:37,927 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:161)
          18:06:37,928 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:245)
          18:06:37,929 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:50)
          18:06:37,929 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:156)
          18:06:37,929 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
          18:06:37,931 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:152)
          18:06:37,932 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          18:06:37,932 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          18:06:37,932 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          18:06:37,933 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          18:06:37,935 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
          18:06:37,935 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
          18:06:37,935 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
          18:06:37,936 ERROR [STDERR] at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
          18:06:37,936 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
          18:06:37,936 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:217)
          18:06:37,938 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:197)
          18:06:37,939 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:50)
          18:06:37,939 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:156)
          18:06:37,939 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
          18:06:37,940 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:152)
          18:06:37,940 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
          18:06:37,940 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
          18:06:37,943 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
          18:06:37,943 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
          18:06:37,943 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
          18:06:37,944 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
          18:06:37,944 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
          18:06:37,944 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
          18:06:37,947 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
          18:06:37,947 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
          18:06:37,947 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
          18:06:37,948 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
          18:06:37,948 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)


          im not crazy jboss deploy EJB3Trail

          -------------------------------------------------
          18:04:27,103 INFO [EARDeployer] Init J2EE application: file:/usr/jboss-4.0.4.GA/server/default/deploy/EJB3Trail.ear
          18:04:28,422 INFO [TomcatDeployer] deploy, ctxPath=/EJB3Trail, warUrl=.../tmp/deploy/tmp5401EJB3Trail.ear-contents/web-exp.war/
          18:04:29,659 INFO [EARDeployer] Started J2EE application: file:/usr/jboss-4.0.4.GA/server/default/deploy/EJB3Trail.ear
          --------------------------------------------------------------------------



          my jsp code is
          -----------------------
          <%@ page import="trail.sfsb.*,
          javax.naming.*,
          java.text.*,
          java.util.ArrayList"%>

          <%!
          private NumberFormat nf = null;

          public void jspInit () {
          nf = NumberFormat.getInstance();
          nf.setMaximumFractionDigits(2);
          }
          %>

          <%
          Calculator cal =
          (Calculator) session.getAttribute("sfsb_cal");
          if (cal == null) {
          System.out.println(cal);
          try {
          InitialContext ctx = new InitialContext();
          cal = (Calculator) ctx.lookup("EJB3Trail/StatefulCalculator/local");
          session.setAttribute ("sfsb_cal", cal);


          } catch (Exception e) {
          e.printStackTrace ();
          }
          }
          %>


          • 2. Re: NullPointerException  in jboss calculator example
            Wolfgang Knauf Master

            Hi,

            in the trailblazer html it seems the interface from the trailblazer lacks the "@javax.ejb.Local" annotation:

            @Local
            public interface Calculator {
            ...
            }

            So the server does not bind the ejb to a jndi name and if your deployment does not contain any other bean no context "EJB3Trail" will be created.

            Hope this guess is right ;-)

            Wolfgang