Hi,
i'm devoloping a struts aplication with hibernate, and i have a problem defining hibernate as a datasource. the error it give is this:
Code:
[b]org.hibernate.cfg.SettingsFactory - Could not obtain connection metadata
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'lles'@'localhost' (using password: YES))
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)
at model.dao.HibernateUtil.<clinit>(HibernateUtil.java:17)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at tomcatJndi.HibernateAppListener.contextInitialized(HibernateAppListener.java:17)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:927)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:890)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.sql.SQLException: Access denied for user 'lles'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:911)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3953)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1276)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2048)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
... 33 more[/b]
in my
web.xml i defined the datasource this way:
Code:
<resource-ref>
<res-ref-name>jdbc/proyecte</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<listener>
<listener-class>tomcatJndi.HibernateAppListener</listener-class>
</listener>
an my
hibernate.cfg.xml is:
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>
<!-- Use a Tomcat 5.5 JNDI datasource -->
<property name="connection.datasource">java:comp/env/jdbc/proyecte </property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!--
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
-->
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<mapping resource="model/faseVO.hbm.xml"/>
<mapping resource="model/fluxVO.hbm.xml"/>
<mapping resource="model/rolVO.hbm.xml"/>
<mapping resource="model/notificacioVO.hbm.xml"/>
<mapping resource="model/paginaVO.hbm.xml"/>
<mapping resource="model/campVO.hbm.xml"/>
<mapping resource="model/usuariVO.hbm.xml"/>
</session-factory>
</hibernate-configuration>
and have also a
context.xml like this:
Code:
<Context path="/proyecte" docBase="proyecte"
debug="5" reloadable="true" crossContext="true">
<Resource
name="jdbc/proyecte"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="lles"
password="pokute"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/pfc"
/>
</Context>
i'm running it in a Tomcat 5.5 server with mysql database. And i have created in the mysql db a user with the same name and password that i put in the context.xml with all the privileges, so i don't understant why it tell me "Access denied for user 'lles'@'localhost' (using password: YES)". i'm not sure is the problem is in the hibernate configuration, or is in the mysql db configuration.
hope anybody can give a hint about it, thanks.