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.IndexOutOfBoundsException: Index: 0, Size: 0
  5. 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}}]
  6. Request processing failed; nested exception is java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
  7. Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  8. Request processing failed; nested exception is java.lang.IllegalStateException: STREAM
  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, 4 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 (141)

  1. OrangeDogvia GitHub4 weeks ago
    Request processing failed; nested exception is java.lang.IllegalStateException: STREAM
    Show stack trace
  2. Willie Slepeckivia Google Groups1 month ago
    Request processing failed; nested exception is com.mongodb.MongoCommandException: Command failed with error 40324: 'Unrecognized pipeline stage name: '0'' on server localhost:27017. The full response is { "ok" : 0.0, "errmsg" : "Unrecognized pipeline stage name: '0'", "code" : 40324, "codeName" : "Location40324" }
    Show stack trace
  3. jakubklimekvia GitHub1 month ago
    Request processing failed; nested exception is java.lang.NullPointerException
    Show stack trace
  4. paraitavia GitHub2 months 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
  5. Gregory Gvia Google Groups2 months ago
    Request processing failed; nested exception is java.lang.IllegalStateException: getWriter() has already been called for this response
    Show stack trace
  6. saturnismvia GitHub2 months ago
    Request processing failed; nested exception is java.lang.IllegalStateException: Signing key was not provided and could not be derived
    Show stack trace
  7. jdinersteinvia GitHub2 months ago
    Request processing failed; nested exception is java.lang.NullPointerException
    Show stack trace
  8. grzesiekbvia GitHub3 months 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
  9. 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
  10. Sam Jonesvia Stack Overflow3 months ago
    Request processing failed; nested exception is java.lang.NullPointerException
    Show stack trace