<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shikha Verma</title>
    <description>The latest articles on DEV Community by Shikha Verma (@shikha_verma_1896).</description>
    <link>https://dev.to/shikha_verma_1896</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2895538%2F87b8889d-1e12-4ac8-9603-5c21ea2e4108.jpg</url>
      <title>DEV Community: Shikha Verma</title>
      <link>https://dev.to/shikha_verma_1896</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shikha_verma_1896"/>
    <language>en</language>
    <item>
      <title>Common Exceptions In Spring Core and SpringMVC</title>
      <dc:creator>Shikha Verma</dc:creator>
      <pubDate>Sun, 23 Feb 2025 15:01:12 +0000</pubDate>
      <link>https://dev.to/shikha_verma_1896/common-exceptions-in-spring-core-and-springmvc-3l69</link>
      <guid>https://dev.to/shikha_verma_1896/common-exceptions-in-spring-core-and-springmvc-3l69</guid>
      <description>&lt;p&gt;Spring Core and Spring MVC throw various exceptions based on different scenarios. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Exceptions in Spring Core&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Spring Core mainly deals with dependency injection, bean management, and context configuration. The following are common exceptions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Bean Creation &amp;amp; Configuration Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;BeanCreationException – Thrown when a bean cannot be created due to issues like circular dependencies or missing dependencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;BeanDefinitionStoreException – Raised when there is an issue with bean definition parsing (e.g., incorrect XML config).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;NoSuchBeanDefinitionException – Thrown when requesting a bean that is not found in the Spring container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;BeanInitializationException – Occurs when a bean fails to initialize (e.g., @PostConstruct method throws an exception).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;UnsatisfiedDependencyException – Raised when a required dependency is missing in the Spring container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ScopeNotActiveException – Occurs when a bean is requested in an inactive scope (e.g., requesting a session-scoped bean in a non-web context).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;b. Application Context &amp;amp; Dependency Injection Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;ApplicationContextException – Generic exception related to application context issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ConversionNotSupportedException – Raised when Spring fails to convert a bean property to the required type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TypeMismatchException – Occurs when a bean property type does not match the expected type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;MethodInvocationException – Thrown when a method invocation on a bean fails.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;c. Transaction Management Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;DataAccessException – Parent class for all exceptions in Spring JDBC and ORM modules.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CannotCreateTransactionException – Thrown when a transaction cannot be started.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TransactionSystemException – Occurs due to unexpected failures in transaction processing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TransactionUsageException – Raised when a transaction is misused (e.g., trying to commit a rolled-back transaction).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;d. AOP &amp;amp; Proxy-related Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;AopInvocationException – Thrown when an aspect method fails.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AspectJWeavingException – Occurs due to issues in AspectJ weaving (e.g., incorrect pointcut expressions).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ProxyInstantiationException – Raised when Spring fails to create a proxy for a bean.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;2. Exceptions in Spring MVC&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Spring MVC handles web-based request processing, controllers, and view rendering. The following are common exceptions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. HTTP Request &amp;amp; Response Handling Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;HttpRequestMethodNotSupportedException – Raised when a requested HTTP method (e.g., POST) is not supported by the controller.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HttpMediaTypeNotSupportedException – Occurs when the request contains an unsupported Content-Type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HttpMediaTypeNotAcceptableException – Raised when the requested media type in Accept header is not supported.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;MissingServletRequestParameterException – Thrown when a required request parameter is missing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ServletRequestBindingException – Occurs when Spring cannot bind request parameters to method arguments.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;b. Path &amp;amp; Handler Mapping Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;NoHandlerFoundException – Raised when no handler (controller) is found for a request URI.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HandlerMappingIntrospectorException – Occurs due to issues in handler mapping introspection.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;NoSuchRequestHandlingMethodException – Thrown when no matching handler method is found for the request.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;c. Data Binding &amp;amp; Validation Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;BindException – Raised when binding request parameters to a model object fails.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;MethodArgumentNotValidException – Thrown when validation fails on &lt;a class="mentioned-user" href="https://dev.to/valid"&gt;@valid&lt;/a&gt; annotated request body or parameters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TypeMismatchException – Occurs when request parameter conversion fails (e.g., trying to convert abc to an integer).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;d. Controller Advice &amp;amp; Exception Handling&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;ResponseStatusException – Generic exception that allows setting an HTTP status code along with a message.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ConversionFailedException – Thrown when a type conversion fails during request processing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;MissingPathVariableException – Raised when a path variable required in a controller method is missing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;MissingServletRequestPartException – Occurs when a required @RequestPart (e.g., file upload) is missing.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;e. Session &amp;amp; Security-related Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;SessionRequiredException – Raised when an operation requires an active session, but none exists.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AuthenticationException – Parent class for all authentication-related exceptions in Spring Security.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AccessDeniedException – Thrown when a user tries to access a resource they do not have permission for.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;.................&lt;br&gt;
This is a broad categorization of exceptions in Spring Core and Spring MVC. Let me know if you need detailed explanations for any specific ones!&lt;/p&gt;

&lt;p&gt;Do Follow!! ❤️&lt;/p&gt;

</description>
      <category>spring</category>
      <category>exceptions</category>
      <category>webdev</category>
      <category>developer</category>
    </item>
  </channel>
</rss>
