1

I'm trying to print a list in a jsp page, but I'm getting the error java.lang.NumberFormatException.forInputString

however, I'm not using any number or transforming anything to a number, and I really don't know what am I doing wrong, please help me.

I saw a question similar to mine (number Exception) And the accepted answer for him/her was to iterate the list with a 'foreach', but I did it and it still giving me that error.

Can someone help me, please?

this is the jsp

<tr class="odd">
    <th style="width: 25px;" class="border" align="center">#</th>
    <th style="width: 200px;" class="border">Process</th>
    <th style="width: 328px;" class="border">Time Schedule</th>
    <th style="width: 100px;" class="border">Next time running</th>
    <th style="width: 50px;" class="border">Server</th>
    <th style="width: 50px;" class="border">On || Off</th>
    <th style="width: 50px;" class="border">Emails</th>
    <th style="width: 50px;" class="border">Description</th>
 </tr>
 </thead>
 <tbody>
   <c:forEach items="${JobList}" var="job" varStatus="index">
    <td align="center">${index.count}</td>
    <td align="center">${job.process}</td>
    <td align="center">${job.schedTime}</td>
    <td align="center">${job.nextTimeRun}</td>
    <td align="center">${job.server}</td>
    <td align="center">${job.isActive}</td>
    <td align="center">${job.email}</td>
    <td align="center">${job.description}</td>
  </tr>
  </c:forEach>
  <tr><td colspan="6">&nbsp;</td></tr>
  </tbody>

here's the databean

private String process;    
private String schedTime;   
private String nextTimeRun;  
private String runServer;
private String mailOrder;    
private String lookCode;
private String lookName;
private String description;
private String isActive;
/* getter and setter methods */

this is the method in the controller that sets the JobList

    public ModelAndView showAppJobsList(final HttpServletRequest request, final HttpServletResponse response) throws BillerException
{
    final ModelAndView modelAndView = new ModelAndView("admin/showAppJobs");
    List<LookUpJobs> lookUpJobsList =lookupSvc.getJobsList(); 

    modelAndView.addObject("JobList", lookUpJobsList);


    return modelAndView;        
}

and the error is this:

java.lang.NumberFormatException: For input string: "process"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at javax.el.ArrayELResolver.coerce(ArrayELResolver.java:153)
at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:45)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at org.apache.el.parser.AstValue.getValue(AstValue.java:97)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923)
at org.apache.jsp.WEB_002dINF.configureJSP.admin.showAppJobs_jsp._jspx_meth_c_005fforEach_005f1(showAppJobs_jsp.java:789)
at org.apache.jsp.WEB_002dINF.configureJSP.admin.showAppJobs_jsp._jspService(showAppJobs_jsp.java:312)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:142)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:243)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1141)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:878)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:475)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:430)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:662)
Community
  • 1
  • 1
jose
  • 35
  • 1
  • 11
  • Did you mean to use `runServer` instead of `server`? – Jon Skeet Jan 06 '15 at 16:55
  • the problem is not the server, is in all the columns, it marks the same error. – jose Jan 06 '15 at 16:56
  • With the same value? Look at the error - it's trying to parse a string `server` as an integer. – Jon Skeet Jan 06 '15 at 16:56
  • yes, in every column I try to get like {job.anyValue} it gives me the same error, but I don't know why is it giving me an number exception if everything is String – jose Jan 06 '15 at 16:58
  • Looks like you're calling `Interger.parseInt("process")` according to the error. Use Eclipse and debugging to see what you're `get` methods are returning. Also, check for a hard coded value for "process" and breakpoint on all calls to `Interger.parseInt()` – Ascalonian Jan 06 '15 at 16:59
  • I'm not using any Integer.parseInt(); in any method I'm working with, I'm going to debug again to see the get methods return – jose Jan 06 '15 at 17:02
  • It's got to be used somewhere as the error states `java.lang.Integer.parseInt()`. Maybe in an included JAR or something? – Ascalonian Jan 06 '15 at 17:07
  • 1
    Can you show the code where you create and set the JobList. – David Levesque Jan 06 '15 at 17:37
  • @DavidLevesque see the edited question, I added the section of the controller where the JobList is created – jose Jan 06 '15 at 17:50
  • Is LookUpJobs the databean that you describe above (the one that contains the "process" property)? – David Levesque Jan 06 '15 at 17:58
  • yes, LookUpJobs is the databean that contains the process, and the other properties, and I just printed 'job' and 'index' without any other parameter and this is what the jsp prints:for 'job' it prints this: [Ljava.lang.Object;@74b547 and for 'index' it prints this: javax.servlet.jsp.jstl.core.LoopTagSupport$1Status@3c591c' – jose Jan 06 '15 at 18:10
  • What is the output if you print `job.class.name`? – David Levesque Jan 06 '15 at 18:36
  • I got exactly the same error mesage:java.lang.NumberFormatException: For input string: "class"... when I try to print job.class.name – jose Jan 06 '15 at 20:11
  • Your `lookUpJobsList` is array of objects. – Aleksandr M Jan 06 '15 at 20:43
  • Weird... what is the output when you print `JobList.class.name`? And what about `job[index.index].class.name`? – David Levesque Jan 06 '15 at 20:44
  • when I print 'JobList.class.name' I get the same error, and when I print 'job[index.index].class.name' this is the print: java.lang.String – jose Jan 06 '15 at 23:11

1 Answers1

1

I found the answer, the problem was not in the jsp, the problem was in the dao, somehow when it was mapping, hibernate retrieved the list, but couldn't map the values, so I had to add an alias to all the columns and then add Scalar for every column in the query, like this.

public List<LookUpJobs> getJobsList(){
    return (List<LookUpJobs>)
    getSession().createSQLQuery("select "
            + "j.type type,"
            + " j.description process,"
            + " j.value schedTime,"
            + " from tableName j inner join tableName m on j.type = m.value")
        .addScalar("type",Hibernate.STRING)
        .addScalar("process",Hibernate.STRING)
        .addScalar("schedTime",Hibernate.STRING)
        .setResultTransformer(Transformers.aliasToBean(LookUpJobs.class))
        .list();
}
jose
  • 35
  • 1
  • 11