Errors And Solutions - AnkitaKak/Project GitHub Wiki
- Error- Data not getting retrieved from implementation
Solution: Adding <%@ page isELIgnored=”false”%>
- SEVERE: Servlet.service() for servlet [spring-dispatcher] in context with path [/Project] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/google/gson/Gson] with root cause java.lang.ClassNotFoundException: com.google.gson.Gson
Solution- I changed the gson dependency version.
- SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested exception is java.lang.UnsupportedClassVersionError: org/hibernate/cfg/Configuration : Unsupported major.minor version 52.0 (unable to load class org.hibernate.cfg.Configuration)
Solution- Change base-package and rename packages as com.niit
- SEVERE: Servlet.service() for servlet [spring-dispatcher] in context with path [/Project] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Optional int parameter 'productId' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.] with root cause java.lang.IllegalStateException: Optional int parameter 'productId' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.
Solution- Giving @GeneratedValue(strategy=GenerationType.IDENTITY) above productId variable inside Product model class.
- SEVERE: Servlet.service() for servlet [spring-dispatcher] in context with path [/Project] threw exception [An exception occurred processing JSP page /WEB-INF/views/viewProduct.jsp at line 43
40:
41:
Stacktrace:] with root cause java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'product' available as request attribute at org.springframework.web.servlet.support.BindStatus.(BindStatus.java:144)
Solution- Give attributes name, id and path for form input.
- SEVERE: Servlet.service() for servlet [spring-dispatcher] in context with path [/Project] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause java.lang.NullPointerException
Solution- Change inside CartController ItemDAO itemDAO; to ItemDAO itemDAO = new ItemDAOImpl();
And give @Autowired annotation above
private SessionFactory sessionFactory;
- org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException WARN: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement Caused by: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "FK8PCETWJMI37OB0VIC6HB1T3EX: PUBLIC.USERS FOREIGN KEY(CARTID) REFERENCES PUBLIC.CART(CARTID)"; SQL statement: alter table users add constraint FK8pcetwjmi37ob0vic6hb1t3ex foreign key (cartId) references Cart [23506-192]
Solution- When I deleted table cart to make changes, the joined columns in user table and shipping address table were still there. That caused the error. So, dropping both the tables and recreating them, solved the error.