Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException with JSP accessing SLSB in JBoss 4.2.1

 
Armin Benz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone in the JavaRanch-Team!

I'm using JBoss 4.2.1 and successfully deployed my POJOs and Facade Beans
(Stateless session bean) basically following the EJB3Trail from Jboss.com
I am using the hibernate persistence and as jboss's logs suggest I am successfully connecting to my oracle DB. In the JSP I would like to be able
to see all current entries and also add a new record (i.e. a pool length) to a table. I can access the facade bean via InitialContext, but as soon as I try to get the collection of all records in the table I get this NullPointerException:

org.apache.jasper.JasperException: An exception occurred processing JSP page /addpool.jsp at line 36

33:<INPUT type="button" value="Close Window" onKlick="window.close()">
34:</form><br/>
35:
36: <% Collection p = (Collection) sb.getPools(); %>
37:
38:
39: There are <b> <% p.size(); %></b> poollengths in the database.<br/>


Stacktracerg.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:518)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:429)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

root cause
java.lang.NullPointerException
org.apache.jsp.addpool_jsp._jspService(addpool_jsp.java:91)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

Here is the relevant info concerning this app:

swimbook.java (interface)



FacadeBean


Here's the JSP


Help in getting the JSP to run properly would be greatly appreciated!!
Thanks kindly in advance!
abenz
 
Armin Benz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out myself. There were basically 2 mistakes:
1) In the JSP: When getting the swimbook by JNDI-InitialContext I did this:



correct:



2) In the Stateless Bean when creating the query for the EntityManager use
the classname i.e. the name of your entity bean or POJO NOT the actual
database table name.

SInce I did not post my entity beans here, I guess no one could have helped me. Hope this was of some use for someone else out there.

bye!
Armin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic