Request processing failed; NestedServletException

org.springframework.web.util.NestedServletException
Javadoc
Subclass of {@link ServletException} that properly handles a root cause in terms of message and stacktrace, just like NestedChecked/RuntimeException does.

Note that the plain ServletException doesn't expose its root cause at all, neither in the exception message nor in printed stack traces! While this might be fixed in later Servlet API variants (which even differ per vendor for the same API version), it is not reliably available on Servlet 2.4 (the minimum version required by Spring 3.x), which is why we need to do it ourselves.

The similarity between this class and the NestedChecked/RuntimeException class is unavoidable, as this class needs to derive from ServletException. @author Juergen Hoeller @since 1.2.5 @see #getMessage @see #printStackTrace @see org.springframework.core.NestedCheckedException @see org.springframework.core.NestedRuntimeException

at org.springframework.web.servlet.FrameworkServlet.processRequest
(source)

Typical Exception Messages

  1. Request processing failed; nested exception is java.lang.NullPointerException
  2. Request processing failed; nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress
  3. Request processing failed; nested exception is org.springframework.beans.FatalBeanException: Could not copy properties from source to target; nested exception is java.lang.reflect.InvocationTargetException
  4. Request processing failed; nested exception is java.lang.IllegalStateException: STREAM
  5. Request processing failed; nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  6. Request processing failed; nested exception is org.springframework.dao.DataAccessResourceFailureException: Timed out after 10000 ms while waiting for a server that matches AnyServerSelector{}. Client view of cluster state is {type=Unknown, servers=[{address=mongo:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.net.UnknownHostException: mongo: unknown error}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting for a server that matches AnyServerSelector{}. Client view of cluster state is {type=Unknown, servers=[{address=mongo:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.net.UnknownHostException: mongo: unknown error}}]
  7. Request processing failed; nested exception is java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
  8. Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  9. Request processing failed; nested exception is org.springframework.webflow.conversation.impl.LockTimeoutException: Unable to acquire conversation lock after 30 seconds
  10. Request processing failed; nested exception is java.lang.UnsupportedOperationException: Possible CSRF attack

Specific cases

Solution

KP39, 2 months ago

  • You will get this exception when your controller, service or component class directly instanciates any object (i.e new Object();), so there's no dependency injection happening, which is why the repository isn't wired and NPE is thrown.
  • Use @Autowired annotation OR @Autowired with @Qualifier
    @Autowired
    @Qualifier("object1")`
    

Example:

Service class:
@Resource(name = "singleTransactionsService")
private SingleTransactionsService singleTransactionsService;

Controller class:
@Service("singleTransactionsService")

External results for this pattern (140)

  1. paraitavia GitHub2 weeks ago
    Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; nested excepti on is org.hibernate.exception.DataException: could not execute statement
    Show stack trace
  2. Gregory Gvia Google Groups3 weeks ago
    Request processing failed; nested exception is java.lang.IllegalStateException: getWriter() has already been called for this response
    Show stack trace
  3. saturnismvia GitHub3 weeks ago
    Request processing failed; nested exception is java.lang.IllegalStateException: Signing key was not provided and could not be derived
    Show stack trace
  4. jdinersteinvia GitHub4 weeks ago
    Request processing failed; nested exception is java.lang.NullPointerException
    Show stack trace
  5. grzesiekbvia GitHub1 month ago
    Request processing failed; nested exception is org.springframework.dao.DuplicateKeyException: PreparedStatementCallback; SQL []; Duplicate entry 'PED_287015-7937' for key 'pointEventDetectorsUn1'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'PED_287015-7937' for key 'pointEventDetectorsUn1'
    Show stack trace
  6. Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "error", template might not exist or might not be accessible by any of the configured Template Resolvers
    Show stack trace
  7. Request processing failed; nested exception is java.lang.NullPointerException
    Show stack trace
  8. ludovicmartinvia GitHub2 months ago
    Request processing failed; nested exception is org.jtwig.exceptions.ResolveValueException: classpath:/templates/error.twig (Line: 5, Column: 11) -> Variable 'request' undefined
    Show stack trace
  9. brenuartvia GitHub3 months ago
    Request processing failed; nested exception is java.lang.RuntimeException: boom
    Show stack trace
  10. dennishendriksenvia GitHub3 months ago
    Request processing failed; nested exception is freemarker.core._TemplateModelException: An error has occurred when reading existing sub-variable "items"; see cause exception! The type of the containing value was: extended_hash+string (org.molgenis.ui.security.MolgenisUiMenuPermissionDecorator wrapped into f.e.b.StringModel) ---- FTL stack trace ("~" means nesting-related): - Failed at: #list menu.items as item [in template "molgenis-header.ftl" in macro "topmenu" at line 203, column 17] - Reached through: @topmenu molgenis_ui.getMenu(), plugi... [in template "molgenis-header.ftl" in macro "header" at line 111, column 13] - Reached through: @header [in template "view-staticcontent.ftl" at line 3, column 1] ----
    Show stack trace