当前位置: 首页 » 资讯 » 机械 » 正文

spring – 奇怪的异常:“名称不能为null或为空!”

发布日期:2023-05-28 20:03:12     浏览次数:6
核心提示:我在 Spring项目中遇到一个奇怪的错误,如下所示: SEVERE: () for servlet [calzoneServlet] in context with path [/calzone] threw excep
我在 Spring项目中遇到一个奇怪的错误,如下所示:

SEVERE: () for servlet [calzoneServlet] in context with path [/calzone] threw exception [Request processing failed; nested exception is .InvalidDataAccessApiUsageException: Name must not be null or empty!; nested exception is : Name must not be null or empty!] with root cause
: Name must not be null or empty!

在这个项目中,所有模型都使用hibernate和jpa映射到数据库.前端使用Twitter Bootstrap(带弹簧形式验证等)

错误发生在程序的不同部分,其中一个是激活用户帐户的控制器(下面的代码).对我来说,这看起来像某种验证错误,但它不是我曾经定义的错误.由于我无法确定错误的确切位置,因此我将仅提供下面的控制器.值得注意的是,activateUser方法中的任何调试消息(无论是通过记录器还是仅仅是一个普通的旧sysout)都不会显示.

所有依赖项()都可以在这里找到:/fs7SG0W2
:/vAJh29Aw
整个堆栈跟踪可以在这里找到:/p0Yt5hi2(在键盘上,因为它有水平滚动)

有没有人知道为什么会发生这种错误,或者有任何线索可以找出为什么会发生这种错误?

@Controllerpublic class ActivateAccountController { final Logger logger = (getClass()); @RequestMapping(value = "/activate/{keyString}", method = ) public String activateUser(@PathVariable String keyString) { ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(""); KeyService keyService = (KeyService) ("keyService"); UserService userService = (UserService) ("userService"); User user; try { ("DID I GET HERE?"); user = (keyString); } catch (KeyNotFoundException ex) { return "ActivatedNotAccount"; } finally { // Close the application context in every case (); } // Activate the in-memory user (user); // Delete the key from the database (keyString); // Finally, update the user in the database (user); ("Acticated user with ID "{}", First name: "{}", Last name: "{}" and username: "{}"", (), ().getFirstName(), ().getLastName(), ()); return "ActivatedAccount"; }} 您的KeyService使用方法findKeyByKeyString()方法调用一些Spring Data JPA存储库.该方法导致Spring Data JPA爆炸,因为缺少某些查询参数.

在..(:104)上放置一个条件断点,匹配if!(name)以查看正在发生的事情,或查看findKeyByKeyString()方法.

头条分类

免责声明:本站所有信息由各公司自行发布,请在交易前确认真实合法性,本站不承担任何交易及此类作品侵权行为的直接责任及连带责任!