Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 18th, 2003, 12:03 AM
DSteenburg DSteenburg is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Woodstock, Ontario
Posts: 7 DSteenburg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Code works anywhere else but not on my machine

I have been working on someone else's program (writing a tutorial) and have successfully installed the program on 4 other computers. But when I install it on mine, it won't run.

I am running Tomcat, and can access other javascripts in the webapps directory (e.g., admin, webdav) but when I try to run this particular program, I get the following error message:

StandardWrapperValve[BudgetServlet]: Servlet.service() for servlet BudgetServlet threw exception
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:377)
at java.lang.Integer.parseInt(Integer.java:458)
at budget.MARSBudget.doPost(MARSBudget.java:284)
at budget.MARSBudget.doGet(MARSBudget.java:1019)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.jav a:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:479)

As far as I can tell, I have installed the program exactly as I have on the other machines--same files in the same directories. Can someone step me through troubleshooting this error?

Thanks.
Dave

Reply With Quote
  #2  
Old April 18th, 2003, 12:26 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
Post the code for the MARSBudget.java file

Reply With Quote
  #3  
Old April 18th, 2003, 05:11 PM
DSteenburg DSteenburg is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Woodstock, Ontario
Posts: 7 DSteenburg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
MARSBudget code

This is rather longish, and being very new to all this I have probably included more than necessary. If I have missed something you would find helpful, let me know.

The same code has worked on other machines I have installed this on, and I suspect it is something in the environment causing the problem rather than the code itself.

Thanks for your help.

Dave




package budget;

import java.util.Vector;
import java.util.StringTokenizer;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.text.DateFormat;
import java.text.ParseException;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.File;
import java.io.FilenameFilter;
import java.awt.Color;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;

import inventory.*;
import common.*;

public final class MARSBudget extends HttpServlet {

private Budget budgetObj = null;
private Inventory inventoryObj = null;
private boolean[][] isAllowed = null;

public void init()
throws ServletException{
budgetObj = BudgetFactory.getInstance();
inventoryObj = InventoryFactory.getInstance();

isAllowed = new boolean[7][CONSTANTS.NUM_OF_CONSTANTS];
for (int i = 0; i < 7; i++){
for (int j = 0; j < CONSTANTS.NUM_OF_CONSTANTS; j++){
isAllowed[i][j] = true;
}
}
//project user
isAllowed[1][CONSTANTS.DISPLAY_BLANK_INSTITUTE] = false;
isAllowed[1][CONSTANTS.SAVE_NEW_INSTITUTE] = false;
isAllowed[1][CONSTANTS.EDIT_INSTITUTE] = false;
isAllowed[1][CONSTANTS.SAVE_UPDATED_INSTITUTE] = false;

******* abbreviating code setting up user permissions ************

isAllowed[5][CONSTANTS.POST_SAVE_NEW_INSTITUTE] = false;

}

private boolean isLoggedIn(HttpSession s){
Account accountObj = (Account)s.getAttribute("user");
if (accountObj == null || accountObj.userId == null || accountObj.userId.length() == 0){
return false;
}
else{
return true;
}
}

private int getUserRole(HttpSession s){
Account accountObj = (Account)s.getAttribute("user");
if (accountObj == null || accountObj.userId == null || accountObj.userId.length() == 0){
return Constants.UNKNOWN_USER;
}
else{
return accountObj.role;
}
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
//Setup object session
HttpSession session = request.getSession(true);

String actionStr = request.getParameter("action");
String servlet = request.getServletPath();
if (actionStr == null || actionStr.length()==0){
if (isLoggedIn(session)){
if (servlet.equals("/budget")){
getServletConfig().getServletContext().getRequestDispatcher("/Template.jsp?action="+ CONSTANTS.DISPLAY_BUDGET_START_PAGE).forward(request, response);
}
else{
getServletConfig().getServletContext().getRequestDispatcher("/ExecutionTemplate.jsp?action="+ CONSTANTS.DISPLAY_EXECUTION_START_PAGE).forward(request, response);
}
}
else{
request.setAttribute("target", String.valueOf(CONSTANTS.LOGIN));
if (servlet.equals("/budget")){
request.setAttribute("targetServlet", "budget");
getServletConfig().getServletContext().getRequestDispatcher("/Template.jsp?action="+ CONSTANTS.DISPLAY_LOGIN_FORM).forward(request, response);
}
else{
request.setAttribute("targetServlet", "execution");
getServletConfig().getServletContext().getRequestDispatcher("/ExecutionTemplate.jsp?action="+ CONSTANTS.DISPLAY_LOGIN_FORM).forward(request, response);
}
}
}

int action = Integer.parseInt(actionStr);

if (!isLoggedIn(session) && action != CONSTANTS.LOGIN && action != CONSTANTS.LOGOUT){
request.setAttribute("target", String.valueOf(CONSTANTS.LOGIN));


********** snipping rest of doPost code *******

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
doPost(request, response);
}

//Login Account
private void loginAccount(HttpServletRequest request, HttpServletResponse response, HttpSession session, boolean invalidateFirst)
throws IOException, ServletException{

if (invalidateFirst){
session.invalidate();
}


Reply With Quote
  #4  
Old April 18th, 2003, 09:48 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
I had a long reply typed out and lost it when I accidentally hit the back button, SO - here is the short version. You are getting a numberformatexception at line 284 of the doPost in this servlet. at budget.MARSBudget.doPost(MARSBudget.java:284)

The only parseInt I can see is for the action variable. There is no error checking code for this variable, so if the wrong type is sent from the calling page then this is going to happen. This may merely be a symptom of the other page being wrong, but the NumberFormatException should be caught anyway in case this happens again.

Look into what the action variable really is and why it is that and you should be on your way to figuring out the problem.

Reply With Quote
  #5  
Old April 19th, 2003, 09:42 AM
DSteenburg DSteenburg is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Woodstock, Ontario
Posts: 7 DSteenburg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, Nemi.

I'll look into it. The really curious thing for me, though, is why this would happen on my installation and nobody elses. Seems to me that wherever the action parameter is being set is unreachable. I'll continue to explore.

Dave

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Code works anywhere else but not on my machine


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT