aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes NullPointerException with JSP accessing SLSB in JBoss 4.2.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "NullPointerException with JSP accessing SLSB in JBoss 4.2.1" Watch "NullPointerException with JSP accessing SLSB in JBoss 4.2.1" New topic
Author

NullPointerException with JSP accessing SLSB in JBoss 4.2.1

Armin Benz
Greenhorn

Joined: Oct 19, 2007
Posts: 2
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

Joined: Oct 19, 2007
Posts: 2
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointerException with JSP accessing SLSB in JBoss 4.2.1
 
Similar Threads
Session management problem
Problem with logic:iterate tag
Array Index Out Of Bounds
how check javabean giving to other component correct data
javabean problem