Dear Markus,
Sorry for posting in an inappropriate place. many thanks for your help. I
should to use ant to compile this application and I found that "-g" is not a
switch for ant. After checking the options for ant I could not realize what
to do.
Thank you
Arash
Markus KARG-3 wrote:
>
> First of all, this is a forum for the GlassFish product but not for the
> Tomcat product. So chance is low that Tomcat specific questions will get
> answered in the same quality and quantity than it would be in a
> dedicated Tomcat forum.
>
> Second, please compile your code with "-g" (currently you instead seem
> to have used "-g:none") and retry your test. Then, send the stack trace
> again.
> "edu.rice.rubis.servlets.ServletPrinter.printItemDescription(Unknown
> Source)" will then be changed from "Unknown Source" to a file name and
> line number. All you need to do then is to look at that line in that
> file to found the cause. The cause is that in that line you are using
> the dot operator ("."). In that line look at the word left of the dot.
> That variable is null (uninitialized) in that moment (i. e. "item" or
> "user" is null).
>
> HTH
> Markus
>
>> -----Original Message-----
>> From: arash_ [mailto:rezaei.arash_at_gmail.com]
>> Sent: Sonntag, 27. September 2009 11:06
>> To: users_at_glassfish.dev.java.net
>> Subject: NullPointerException error
>>
>>
>> Dear All, I am a totally newbie in java and trying to use an
>> application. I
>> had received the following error as the output of tomcat, could
> someone
>> please help me find out the origin of the error, I also presented here
>> the
>> code for "ServletPrinter.printItemDescription" and "PutBid.doGet"
> after
>> the
>> error.
>>
>> -bash-3.2# 08:29:52,942 ERROR [PutBid]:260 - Servlet.service() for
>> servlet
>> PutBid threw exception
>> java.lang.NullPointerException
>> at
>> edu.rice.rubis.servlets.ServletPrinter.printItemDescription(Unknown
>> Source)
>> at edu.rice.rubis.servlets.PutBid.doGet(Unknown Source)
>> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
>> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
>> at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown
> Source)
>> at
>>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso
>> rImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:585)
>> at
>> org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
> javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
>> at
>>
> org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276
>> )
>> at
>>
> org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.ja
>> va:162)
>> at
>>
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic
>> ationFilterChain.java:262)
>> at
>>
> org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationF
>> ilterChain.java:52)
>> at
>>
> org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilter
>> Chain.java:171)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>>
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil
>> terChain.java:167)
>> at
>>
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal
>> ve.java:213)
>> at
>>
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextVal
>> ve.java:172)
>> at
>>
> org.objectweb.jonas.web.catalina55.ResetAuthenticationValve.invoke(Rese
>> tAuthenticationValve.java:107)
>> at
>>
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav
>> a:127)
>> at
>>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav
>> a:117)
>> at
>>
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve
>> .java:108)
>> at
>>
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
>> 174)
>> at
>>
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:8
>> 75)
>> at
>>
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.pro
>> cessConnection(Http11BaseProtocol
>> .java:665)
>> at
>>
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoin
>> t.java:528)
>> at
>>
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollo
>> werWorkerThread.java:81)
>> at
>>
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPoo
>> l.java:689)
>> at java.lang.Thread.run(Thread.java:595)
>> ------------------
>> "ServletPrinter.printItemDescription":
>> void printItemDescriptionToBuyNow(Item item, User user)
>> {
>> try
>> {
>> printHTMLheader("RUBiS: Buy Now");
>> printHTMLHighlighted("You are ready to buy this item: " +
>> item.getName());
>>
>> out.println(
>> "<TABLE>\n"
>> + "<TR><TD>Quantity<TD><BIG>"
>> + item.getQuantity()
>> + "</BIG>\n"
>> + "<TR><TD>Seller<TD> \"/rubis/servlet/ViewUserInfo?userId="
>> "
>> + item.getSeller().getNickname()
>> + " ( \"/rubis/servlet/PutCommentAuth?to=" Leave a comment
>> on
>> this user )\n"
>> + "<TR><TD>Started<TD>"
>> + item.getStartDate()
>> + "\n"
>> + "<TR><TD>Ends<TD>"
>> + item.getEndDate()
>> + "\n"
>> + "</TABLE>");
>>
>> printHTMLHighlighted("Item description");
>> out.println(item.getDescription());
>> out.println("<br><p>\n");
>>
>> printHTMLHighlighted("Buy Now");
>> printHTML(
>> "<form action=\"/rubis/servlet/StoreBuyNow\" method=POST>\n"
>> + "<input type=hidden name=userId value="
>> + user.getId()
>> + ">\n"
>> + "<input type=hidden name=itemId value="
>> + item.getId()
>> + ">\n"
>> + "<input type=hidden name=maxQty value="
>> + item.getQuantity()
>> + ">\n");
>> if (item.getQuantity().intValue() > 1)
>> printHTML(
>> "<center><table><tr><td>Quantity:</td>\n"
>> + "<td><input type=text size=5
>> name=qty></td></tr></table></center>\n");
>> else
>> printHTML("<input type=hidden name=qty value=1>\n");
>> printHTML("<p><center><input type=submit value=\"Buy
>> now!\"></center><p>\n");
>> }
>> catch (Exception e)
>> {
>> out.println(
>> "Unable to print Item description (exception: " + e +
>> ")<br>\n");
>> }
>> }
>> -----------------
>> "PutBid.doGet"
>> public void doGet(HttpServletRequest request, HttpServletResponse
>> response)
>> throws IOException, ServletException
>> {
>> ServletPrinter sp = null;
>> Session sess = null;
>> User user = null;
>> Item item = null;
>> Float maxBid = null;
>> Integer nbOfBids = null;
>>
>> String itemStr = request.getParameter("itemId");
>> String nick = request.getParameter("nickname");
>> String pass = request.getParameter("password");
>> sp = new ServletPrinter(response, "PutBid");
>>
>> if ((itemStr == null)
>> || (itemStr.equals(""))
>> || (nick == null)
>> || (nick.equals(""))
>> || (pass == null)
>> || (pass.equals("")))
>> {
>> printError("Item id, name and password are required - Cannot
>> process
>> the request<br>", sp);
>> return;
>> }
>>
>> // Authenticate the user who want to bid
>> sess = getSession();
>> Auth auth = new Auth(sess, sp);
>> user = auth.authenticate(nick, pass);
>> if (user == null)
>> {
>> printError(" You don't have an account on RUBiS!<br>You have to
>> register first.<br>", sp);
>> releaseSession(sess);
>> return;
>> }
>>
>> // Try to find the Item corresponding to the Item ID
>> Integer itemId = new Integer(itemStr);
>>
>> try
>> {
>> item = (Item) sess.get(Item.class, itemId);
>> }
>> catch (HibernateException he)
>> {
>> printError("Failed to execute Query for item: " + he, sp);
>> releaseSession(sess);
>> return;
>> }
>> if (item == null)
>> {
>> printError("<h2>This item does not exist!</h2>", sp);
>> releaseSession(sess);
>> return;
>> }
>>
>> try
>> {
>> Query q = sess.createFilter(item.getBids(), "select
>> max(this.bid)");
>> List lst = q.list();
>> Iterator it = lst.iterator();
>>
>> // Get the current price (max bid)
>> if (it.hasNext())
>> maxBid = (Float) it.next();
>> else
>> maxBid = item.getInitialPrice();
>> }
>> catch (HibernateException he)
>> {
>> printError("Failed to executeQuery for max bid: " + he, sp);
>> releaseSession(sess);
>> return;
>> }
>>
>> try
>> {
>> Query q = sess.createFilter(item.getBids(), "select count(*)");
>> List lst = q.list();
>> Iterator it = lst.iterator();
>>
>> if (it.hasNext())
>> nbOfBids = (Integer) it.next();
>> }
>> catch (HibernateException he)
>> {
>> printError("Failed to executeQuery for number of bids: " + he,
>> sp);
>> releaseSession(sess);
>> return;
>> }
>>
>> sp.printItemDescription(item, maxBid, nbOfBids, user, sess);
>>
>> releaseSession(sess);
>>
>> sp.printHTMLfooter();
>> }
>> --------------------
>> Thank you in advance for your help and attention
>> Arash
>> --
>> View this message in context:
>> http://www.nabble.com/NullPointerException-error-
>> tp25631989p25631989.html
>> Sent from the java.net - glassfish users mailing list archive at
>> Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>
--
View this message in context: http://www.nabble.com/NullPointerException-error-tp25631989p25632812.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.