Friday 13 May 2016

SQL Error: 0, SQLState: null, Cannot create PoolableConnectionFactory (Communications link failure)



2016-05-12 20:37:03,434 [http-bio-8080-exec-3] WARN  (SqlExceptionHelper.java:144) - SQL Error: 0, SQLState: null
2016-05-12 20:37:03,435 [http-bio-8080-exec-3] ERROR (SqlExceptionHelper.java:146) - Cannot create PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
2016-05-12 20:37:03,445 [http-bio-8080-exec-3] ERROR (BaseService.java:41) - org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection
at org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:544)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:457)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:276)
Here is solution worked for me. provide relevant/correct db credentials and ip address. ex :
DB URL : jdbc:mysql://127.0.0.1:3306/voicedb
username : voice
password : voice

Thursday 12 May 2016

fatal: remote origin already exists.

fatal: remote origin already exists.

git remote add origin https://github.com/voice/voiceApp.git

solution :

1.First remove origin
cmd :  git remote rm origin

2. now add the origin
cmd : git remote add origin https://github.com/voice/voiceApp.git

or

1.set the new git  origin/remote URL
.set the new origin
cmd : git remote set-url origin https://github.com/voice/voiceApp.git


2. Now check origin.

cmd : git remote show origin





Write operations are not allowed in read-only mode (FlushMode.MANUAL)


org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
at org.springframework.orm.hibernate4.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1135)
at org.springframework.orm.hibernate4.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:620)
at org.springframework.orm.hibernate4.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:617)
Below of the piece of code worked for me. Added @Transactional annotation where i was performing insert operation
@Transactional
public void sendVoice(VoiceUser voiceUser) {
                    feedSendVoice.save(voiceUser)
 }

Wednesday 11 May 2016

Can not construct instance of java.util.Date from String value

Can not construct instance of java.util.Date from String value

SEVERE: Servlet.service() for servlet [Jersey Rest Service] in context with path [/voice] threw exception [com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct instance of java.util.Date from String value '12-01-2016': not a valid representation (error: Failed to parse Date value '12-01-2016': Can not parse date "12-01-2016": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))
 at [Source: org.apache.catalina.connector.CoyoteInputStream@aca01d2; line: 6, column: 22] (through reference chain: com.voice.dto.VoiceSurveyRequestDto["feedbackAt"])] with root cause
com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct instance of java.util.Date from String value '12-01-2016': not a valid representation (error: Failed to parse Date value '12-01-2016': Can not parse date "12-01-2016": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))

From the error stack provide date in following format.
1. yyyy-MM-dd'T'HH:mm:ss.SSSZ"
ex : 2016-10-01T09:45:00.000

2."yyyy-MM-dd'T'HH:mm:ss.SSS'Z'".
ex : 2016-10-01T09:45:00.000

3. "EEE, dd MMM yyyy HH:mm:ss zzz"
ex : 2016-10-01T09:45:00.000

4."yyyy-MM-dd"
ex : 2016-10-01