I have Spring
+ Hibernate
application.
I use PostgreSQL as data store.
application compiles good but when I deployed it to Tomcat
and launch it I see following stacktrace:
INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
WARN : org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 28P01
ERROR: org.hibernate.util.JDBCExceptionReporter - ?????: ???????????? "my_db" ?? ?????? ???????? ??????????? (?? ??????)
WARN : org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 28P01
ERROR: org.hibernate.util.JDBCExceptionReporter - ?????: ???????????? "my_db" ?? ?????? ???????? ??????????? (?? ??????)
ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:597)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:372)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:417)
.....
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
....
at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:556)
... 57 more
Caused by: org.postgresql.util.PSQLException: ?????: ???????????? "my_db" ?? ?????? ???????? ??????????? (?? ??????)
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:291)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:393)
...
... 62 more
On another PC this application launch good. Difference: locale. Working PC has English language but another - not.
Please help to find cause of the problem.
update
Looks like database doesn't understand password:
28P01 INVALID PASSWORD invalid_password
update
I didn't know the cause of the problem but problem disappear after database recreation.
This is a known issue with the PostgreSQL version 3 protocol, where the client doesn't know the encoding to decode error messages sent by the server early in the protocol handshake.
It will be fixed when the version 4 protocol is produced, but that's a long way off yet.
In the mean time the only real workaround is to make sure that the client's default encoding is compatible with the server's. The easiest way to do that is to set
LC_MESSAGES
to something likeen_US.UTF-8
, perhaps via thelc_messages
option inpostgresql.conf
.