Skip to content

Instantly share code, notes, and snippets.

@gotoark
Last active February 20, 2019 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gotoark/ccdd563a1e0e3bfbdf3622ef48fa23b8 to your computer and use it in GitHub Desktop.
Save gotoark/ccdd563a1e0e3bfbdf3622ef48fa23b8 to your computer and use it in GitHub Desktop.
A Collection of Errors and Solutions faced in Spring Development ( Java EE )

😈 SPRING ERRORS and SOLUTIONS πŸ˜‡

Error 😬

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.modelmapper.MappingException: ModelMapper mapping errors:

1) Converter org.modelmapper.internal.converter.CollectionConverter@9b93001 failed to convert java.util.List to java.util.List.

Solution πŸ’š

 set modelMapper.getConfiguration().setAmbiguityIgnored(true);
 
 Ref - [Gist Thread](https://github.com/modelmapper/modelmapper/issues/239) 

Error 😬

java.lang.ClassCastException: org.hibernate.hql.internal.ast.tree.SqlNode cannot be cast to org.hibernate.hql.internal.ast.tree.FromReferenceNode

Solution πŸ’š

 if package name starts with in means change to com(since in is reserved for IN India in Hibernate)

Error 😬

Error creating bean with name 'entityManagerFactory': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.persistence.EntityManagerFactory' available

Solution πŸ’š

  Check weather ypu have defined persistence.xml

Error 😬

Error configuring application listener of class org.springframework.web.context.ContextLoaderListener

Solution πŸ’š

  Add maven dependencies in the projects web deployment assembly 

Error 😬

StateTransferException: java.io.EOFException: Read past end of file 
                              (or)
Could not write method invocation failure for method public abstract XYX on bean named abcBean for appname  due to: java.io.NotSerializableException: xyzVo

Solution πŸ’š

  Please Check xyzVo implements Serializable  

Error 😬

  Unable to locate appropriate constructor on class

Solution πŸ’š

  Please Check for Constructer in the respective class and make sure it is in Public  

Error 😬

 javax.servlet.ServletException: Could not resolve view with name 'common_error' in servlet with name 'appServlet'

Solution πŸ’š

  Please Check weather you have deployed latest war/ear or remove war/ear and redeploy  

Error 😬

java.lang.IllegalArgumentException :org.hibernate.QueryException :NOT ALL named parameters have been SET:[ username ]

Solution πŸ’š

  Please Check for the parameters set for the query
  resultList.setParameter("username",username);  

Error 😬

  entityManager.merge(classname); runs Select instead of Update  
                         (or)
   Transactional Required : update or delete

Solution πŸ’š

  Please Check for the @Transactional Annotation in Service Impl

Error 😬

  Hibernate - Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1

Solution πŸ’š

  It also can happen when you tries to UPDATE a PRIMARY KEY.

Error 😬

  java.sql.SQLException Parameter index out of range (1 > number of parameters, which is 0) 

Solution πŸ’š

  Please Check for Entity Class Weather all the Field names Given Correctly 
   @Column(name=" ' REGISTRATION_NO '") this also cause this error
	private String registrationNo;

Error 😬

  List view Not Sowing Properly in Production But works Perfect in Staging/Local

Solution πŸ’š

  Please Check for the select Query, If it has Cross Joins without Condtions/AND Conditions then it Wont work in Production
  Remove unwanted cross joins or Add Conditions

Error 😬

errors.rejectValue("Class.studentName", "","Enter proper Student Name");  //Displays Error Messages as studentName Instead of  Enter proper Student Name

Solution πŸ’š

 if error code is Empty then it looks for .Property File for the Correspondent field Class.studentName i.e Student Name if no correspondent file  found then it returns the default Message
 So use  errors.rejectValue("Class.studentName", "Class.studentName.errorMessage","Enter proper Student Name");
 In PropertiesFiles
     Class.studentName= studentName
     Class.studentName.errorMessage= Enter proper Student Name   refer interface MessageSource for more details

Error 😬

Not enough space to render crosstab

Solution πŸ’š

 Check the Jasper Report for the CrossTab Table

Error 😬

 javax.persistence.TransactionRequiredException: Executing an update/delete query

Solution πŸ’š

 for Every Add,Delete,Update Add this Annotation in ServivceImpl 
 @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = false)

Error 😬

 Servlet.service() for servlet XYZ threw exception: java.lang.OutOfMemoryError: PermGen space

Solution πŸ’š

 Restart the Server to Clear the memory

Error 😬

Exception.ServiceException: : A different object with the same identifier value was already associated with the session

Solution πŸ’š

 Entity With AutoIncrement Doesent Have a Annotaions @GeneratedValue(strategy = GenerationType.IDENTITY)

Error 😬

File is Out Of Sync.....

Solution πŸ’š

 Clean and Refresh the project Files 

Error 😬

Break points Not Working Properyly.....

Solution πŸ’š

 Check weather the App and Web Servers Runs in Debug Mode or Try CTRL+ALT+B in eclipse

Error 😬

 javax.resource.ResourceException: Could not create connection....
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 

Solution πŸ’š

 Check the Data Base Connection (mostly happens  While Building War/Ear)

Error 😬

 Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'XYZ' at row 1

Solution πŸ’š

 Length of submitted data is larger than the kength of the Field in DataBase.

Error 😬

 Neither BindingResult nor plain target object for bean name 'xyxBo' available as request attribute

Solution πŸ’š

 Data is not available in DB/Data is Deleted for the Requsted Object in DataBase
                                  (or)
  Model View name is Incorrect				  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment