[jboss-user] [EJB3] - ERROR [STDERR] java.lang.NullPointerException - can't solve

stefano bertozzi do-not-reply at jboss.com
Mon Apr 18 13:11:38 EDT 2011


stefano bertozzi [http://community.jboss.org/people/bertoz84] created the discussion

"ERROR [STDERR] java.lang.NullPointerException - can't solve"

To view the discussion, visit: http://community.jboss.org/message/600753#600753

--------------------------------------------------------------
Hi all, i really need help to overcome this error.
I'm going to paste the interesting parts of my code:

*TEST BEAN ( we are inside a method called by the java test client ):*
*     .*
*     .*
*     .
*
      try {
                                        System.out.println("lowering the amount of the selected book");
                                        Book abook = (Book) bookop.findByISBN(80002).get(0);  // Book is an entity bean --- bookop is the istance of a session bean that performs                                                                                                 // operations on Book
 *bookop.updateMin*(abook.getISBN(), 2); // tot - 2

             // OPERATION updateMin *DONE* SUCCESSFULLY

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


      Users an_user = (Users) user.findByUser("mouse").get(0);  // Users is an entity bean --- user is the istance of a session bean that performs                                                                                                   // operations on Users
*cart.checkoutCart*(an_user); // cart is the istance of a session statefull bean that performs classic operations like in a web site ( bookshop )
                                                 // to see what this method go down

-end


*CART BEAN ( the called method ):*
*
*
     public void *checkoutCart*(Users customer) {
            for (int i = 0; i < books.size(); i++)   // where books is: private List<CartBook> books , a simple class made up of a Book and the quantity                                                                    // to purchase of that book
                              {
                                             Book abook = books.get(i).getBook();
                                             Integer quantity = books.get(i).getQuantity();

                 try {
                         System.out.println("lowering the amount of the selected book");
 *DBOperation.updateMin*(abook.getISBN(), quantity); // DBOperation is the same as bookop seen before

                         // ERROR [STDERR] java.lang.NullPointerException

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

-end


so basically the code is the same; the difference is that going through the cart bean i can lower the quantity of a list of books ( that are the books that a customer puts in his cart: when he performs a checkout operation the method updateMin lowers the amount of every books purchased in the store ) instead of only one.

the problem is that through the cart i get always the ERROR [STDERR] java.lang.NullPointerException in the *DBOperation.updateMin* methods that is exactly the same of  *bookop.updateMin*.
Every cicle of the for( ) command i get this error.
I can assure that my list is not empty and abook & quantity are not null.



I really don't get the problem!

Thank you in advance!!
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/600753#600753]

Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110418/1ef81962/attachment-0001.html 


More information about the jboss-user mailing list