0

As described in the title i get ArrayIndexOutOfBoundsException when i start my Tomcat 7 with NetBeans 8.2.

I've tried troubleshooting with those two threads without any success:

ArrayOutOfBoundsException: asm.ClassReader.readClass(Unknown Source)

Failed to load ApplicationContext caused by ArrayIndexOutOfBoundsException in ClassReader

The exception seems to be caused by org.springframework.asm.ClassReader.readClass or DienststellenController.class

Caused by: java.lang.ArrayIndexOutOfBoundsException: 52264
at org.springframework.asm.ClassReader.readClass(Unknown Source)
at org.springframework.asm.ClassReader.accept(Unknown Source)
at org.springframework.asm.ClassReader.accept(Unknown Source)

[Path\DienststellenController.class]; nested exception is 
java.lang.ArrayIndexOutOfBoundsException: 52264

When i run my project with those four lines commented out, it works like a charm without any exceptions:

@RequestMapping(value = "/query", method = RequestMethod.GET)
public ModelAndView queryGet(HttpServletRequest request) {
    logger.debug("Received request to show a input form page");
    List<Person> personListe = personDao.getPersonalStamm();
    //List<String> ls = new ArrayList<>();
    Dienststelle d = (Dienststelle) request.getSession().getAttribute("dienststelle");
        if (d == null) {
        d = new Dienststelle();
    }
    ModelAndView mv = new ModelAndView("phonebook/dienststelle/query", "dienststelle", d);
    //personListe.forEach((p) -> {
    //    ls.add(p.getAnzeige());
    //});
    mv.addObject("person", personListe);
    return mv;
}

Controller

@RequestMapping(value = "/query", method = RequestMethod.GET)
public ModelAndView queryGet(HttpServletRequest request) {
    logger.debug("Received request to show a input form page");
    List<Person> personListe = personDao.getPersonalStamm();
    List<String> ls = new ArrayList<>();
    Dienststelle d = (Dienststelle) request.getSession().getAttribute("dienststelle");
        if (d == null) {
        d = new Dienststelle();
    }
    ModelAndView mv = new ModelAndView("phonebook/dienststelle/query", "dienststelle", d);
    personListe.forEach((p) -> {
        ls.add(p.getAnzeige());
    });
    mv.addObject("person", ls);
    return mv;
}

Method from dao class

@Override
public List<Person> getPersonalStamm() {
    String sql = "SELECT * FROM personalDB.personalstamm";
    RowMapper<Person> rm = ParameterizedBeanPropertyRowMapper.newInstance(Person.class);
    List<Person> personen = (List<Person>) getJdbcTemplate().query(sql, rm);
    return personen;
}

jsp page

    <tr>
        <td><label>Vorgesetzter</label></td>
        <td>
            <form:select path="verantwortlich" maxlength="11" >
                <form:option value="0" label="-"/>
                <form:options items='${person}' itemValue='name' itemLabel='name' />
            </form:select>                
        </td>
    </tr>
dbuergi
  • 21
  • 1
  • 5
  • 1
    where do you get ArrayIndexOutOfBoundsException? – Shridutt Kothari Mar 29 '22 at 14:06
  • `personListe.forEach((p) -> { ls.add(p.getAnzeige()); });` This line of code is what causes the exception. It takes first name and last name out of the object p via getter and puts it into the ArrayList ls. I just cant see what i'm doing wrong here. – dbuergi Mar 29 '22 at 14:09
  • Is it possible that JSP accesses the ArrayList at index 1 instead of 0? – dbuergi Mar 29 '22 at 14:22
  • 1
    can you show the full stack? you have no direct interaction with an array. – Taylor Mar 29 '22 at 14:30
  • ArrayIndexOutOfBoundsException happens when i start Tomcat 7. I've added a pastebin containing the log. – dbuergi Mar 29 '22 at 14:44
  • @Taylor Adding entries into an Array doesn't count as interaction? Please excuse me if this sounds like a stupid question. – dbuergi Mar 29 '22 at 14:54
  • As far as I can tell, you're adding to an `ArrayList`, which is very different from an array. – Taylor Mar 29 '22 at 19:44
  • After reading your pastebin, this has nothing to do with the code you indicated. The exception is rooted in `org.springframework.asm.ClassReader.readClass`. This probably answers your question: https://stackoverflow.com/questions/35046404/arrayoutofboundsexception-asm-classreader-readclassunknown-source – Taylor Mar 29 '22 at 19:47
  • 1
    Does this answer your question? [Failed to load ApplicationContext caused by ArrayIndexOutOfBoundsException in ClassReader](https://stackoverflow.com/questions/17563149/failed-to-load-applicationcontext-caused-by-arrayindexoutofboundsexception-in-cl) – Taylor Mar 29 '22 at 19:49
  • I've edited the question to match moderation guidelines. Sadly, those two threads didn't answer my questions. @Taylor – dbuergi Mar 31 '22 at 15:16
  • Your problem is you're using a dependency that doesn't align with your jdk version. – Taylor Mar 31 '22 at 15:25

0 Answers0