title: Strange exception: "Name must not be null or empty!"
body: <p>I'm experiencing a strange error in a Spring project, which is the following: </p>
  
  <blockquote>
    <p>SEVERE: Servlet.service() for servlet [calzoneServlet] in context with path [/calzone] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Name must not be null or empty!; nested exception is java.lang.IllegalArgumentException: Name must not be null or empty!] with root cause
    java.lang.IllegalArgumentException: Name must not be null or empty!</p>
  </blockquote>
  
  <p>In this project, all models are mapped to the database using hibernate and jpa. The front-end  uses Twitter Bootstrap (with spring form validation, etc)</p>
  
  <p>The error occurs at different parts of the program, one of which is a controller to activate a user account (code below). To me this looks like some sort of validation error, but it isn't an error I have ever defined. Since I can't pinpoint the exact location of the error, I'll only provide the controller below. It is noteworthy that any debug messages (whether it be through the logger or just a plain old sysout) in the <code>activateUser</code> method do not get displayed.</p>
  
  <p>All dependencies (pom.xml) can be found here: <a href="http://pastebin.com/fs7SG0W2" rel="nofollow">http://pastebin.com/fs7SG0W2</a>
  Web.xml here: <a href="http://pastebin.com/vAJh29Aw" rel="nofollow">http://pastebin.com/vAJh29Aw</a>
  The entire stacktrace can be found here: <a href="http://codepad.org/p0Yt5hi2" rel="nofollow">http://codepad.org/p0Yt5hi2</a> (on codepad, because it has horizontal scrolling)</p>
  
  <p>Does anyone have any idea why this error could be happening, or have any clue as to how I can find out why it's happening? </p>
  
  <pre><code>@Controller
  public class ActivateAccountController {
      final Logger logger = LoggerFactory.getLogger(getClass());
      @RequestMapping(value = "/activate/{keyString}", method = RequestMethod.GET)
      public String activateUser(@PathVariable String keyString) {
          ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
          KeyService keyService = (KeyService) context.getBean("keyService");
          UserService userService = (UserService) context.getBean("userService");
          User user;
          try {
              logger.error("DID I GET HERE?");
              user = keyService.findUserByKey(keyString);
          } catch (KeyNotFoundException ex) {
              return "ActivatedNotAccount";
          } finally {
              // Close the application context in every case
              context.close();
          }
          // Activate the in-memory user
          userService.activateUser(user);
          // Delete the key from the database
          keyService.deleteKey(keyString);
          // Finally, update the user in the database
          userService.updateUser(user);
          logger.info("Acticated user with ID \"{}\", First name: \"{}\", Last name: \"{}\" and username: \"{}\"",
                  user.getId(), user.getPerson().getFirstName(), user.getPerson().getLastName(), user.getUsername());
          return "ActivatedAccount";
      }
  }
  </code></pre>