Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    authenticating hibernate datasource

    Hi,

    I'm using hibernate in a datasource, I'm getting the following error when loaded:
    Code:
    javax.servlet.ServletException: org.postgresql.util.PSQLException: Conexión rechazada: FATAL: no PostgreSQL user name specified in startup packet.
    	at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:275)
    	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:94)
    	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
    	at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:117)
    	at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
    	at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
    	at org.postgresql.Driver.connect(Driver.java:235)
    	at java.sql.DriverManager.getConnection(DriverManager.java:582)
    	at java.sql.DriverManager.getConnection(DriverManager.java:207)
    	at com.isomorphic.sql.PoolableSQLConnectionFactory.makeUnpooledObject(PoolableSQLConnectionFactory.java:242)
    	at com.isomorphic.sql.PoolableSQLConnectionFactory.makeObject(PoolableSQLConnectionFactory.java:339)
    	at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:974)
    	at com.isomorphic.pool.PoolManager.borrowObject(PoolManager.java:74)
    	at com.isomorphic.sql.SQLConnectionManager.getConnection(SQLConnectionManager.java:150)
    my hibernate.cfg.xml, placed on the classpath, is as followed:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
    	<session-factory>
    		<property name="hibernate.c3p0.max_size">20</property>
    		<property name="hibernate.c3p0.max_statements">50</property>
    		<property name="hibernate.c3p0.min_size">5</property>
    		<property name="hibernate.c3p0.timeout">1800</property>
    		<property name="hibernate.cache.provider_class">
    			org.hibernate.cache.HashtableCacheProvider
    		</property>
    		<property name="hibernate.cglib.use_reflection_optimizer">
    			true
    		</property>
    		<property name="hibernate.connection.driver_class">
    			org.postgresql.Driver
    		</property>
    		<property name="hibernate.connection.password">
    			secret
    		</property>
    		<property name="hibernate.connection.url">
    			jdbc:postgresql://localhost/myapp?CharSet=LATIN1
    		</property>
    		<property name="hibernate.connection.username">
    			postgres
    		</property>
    		<property name="hibernate.default_schema">public</property>
    		<property name="hibernate.dialect">
    			org.hibernate.dialect.PostgreSQLDialect
    		</property>
    		<property name="hibernate.show_sql">true</property>
    		<property name="hibernate.transaction.factory_class">
    			org.hibernate.transaction.JDBCTransactionFactory
    		</property>
    		<property name="myeclipse.connection.profile">
    			MyApp
    		</property>
    		<property name="connection.url">
    			jdbc:postgresql://localhost:5432/myapp
    		</property>
    		<property name="connection.username">postgres</property>
    		<property name="connection.password">secret</property>
    		<property name="connection.driver_class">
    			org.postgresql.Driver
    		</property>
    		<property name="dialect">
    			org.hibernate.dialect.PostgreSQLDialect
    		</property>
    
    		<mapping resource="es/myapp/om/Tema.hbm.xml" />
    		<mapping resource="es/myapp/om/Noticia.hbm.xml" />
    		<mapping resource="es/myapp/om/Canal.hbm.xml" /> 
    	</session-factory>
    </hibernate-configuration>
    the datasource is as followed:
    Code:
    <DataSource ID="noticias" serverType="hibernate" tableName="noticia"
    	autoDeriveSchema="true" >
    
    	<fields>
    		<field name="idnoticia" hidden="true" />
    		<field name="titulo" type="text"/>
    		<field name="idtema" title="Tema" type="integer" foreignKey="temas.idtema"  />
    		<field name="idcanal" title="Canal" type="integer" valueXPath="tema/idcanal"  />
    		<field name="campo1" type="text" hidden="true"/>
    		<field name="campo2" type="text" hidden="true"/>
    	</fields>
    
    </DataSource>
    Hibernate.cfg.xml contains database user and password, but somehow it doesn't get through.

    Any ideas what's missing?

    Cheers, Bo

    #2
    Probably your hibernate.cfg.xml is not being read or contains some kind of typo. Showing the complete server log for the request might help (and you should always do this rather than just providing part of the stack trace).

    Another approach is to try a test case using Hibernate directly (not through SmartGWT) and make sure that actually works before trying SmartGWT.

    Comment

    Working...
    X