需要帮助修复“ArrayIndexOutOfBoundsException”

发布于 2025-01-17 16:05:11 字数 3313 浏览 1 评论 0 原文

如标题中所述,当我以Netbeans 8.2启动tomcat 7时,我将获得 arayindexoutofBoundSexception

我尝试使用这两个线程进行故障排除而没有任何成功:

例外似乎是由 org.springframework.asm.classreader.readclass 引起的 或 dienststercontroller.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

当我使用这四行评论的项目运行时,它像符合魅力一样,没有任何例外:

@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;
}

进行控制器方法

@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;
}

从DAO类

@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页面

    <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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文