0

i had created my J2EE application with appfuse , i want to save some data to database but the problem in hibernante configuration ,this is the exception:

WARN [http-8080-1] ConnectionProviderInitiator.initiateService(143) | HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections juin 07, 2013 5:16:05 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet faces threw exception org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set

and this is database configuration in pom.xml :

<dbunit.dataTypeFactoryName>org.dbunit.ext.mysql.MySqlDataTypeFactory</dbunit.dataTypeFactoryName>
<dbunit.operation.type>CLEAN_INSERT</dbunit.operation.type>
<hibernate.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</hibernate.dialect>
<jdbc.groupId>mysql</jdbc.groupId>
<jdbc.artifactId>mysql-connector-java</jdbc.artifactId>
<jdbc.version>5.1.22</jdbc.version>
<jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
<!-- <jdbc.url>jdbc:mysql://localhost/${db.name}?createDatabaseIfNotExist=true&amp;amp;useUnicode=true&amp;amp;characterEncoding=utf-8&amp;amp;autoReconnect=true</jdbc.url> -->
<jdbc.url>jdbc:mysql://localhost/castor</jdbc.url>
<jdbc.username>root</jdbc.username>
<jdbc.password></jdbc.password>         

and if i configure the file hibernate.cfg.xml the server can't start:

<hibernate-configuration>
    <session-factory>
     <mapping class="org.appfuse.model.Role"/>
         <mapping class="com.geviteam.castor.webapp.model.TrajetModel"/>
    </session-factory>
</hibernate-configuration>
UdayKiran Pulipati
  • 6,579
  • 7
  • 67
  • 92
asma
  • 75
  • 1
  • 10

2 Answers2

0

What do you have in jdbc.properties? It should have the properties from your pom.xml and be in your target/classes directory (after it copies it from src/main/resources).

Matt Raible
  • 8,187
  • 9
  • 61
  • 120
  • in my jdbc.properties : jdbc.driverClassName=${jdbc.driverClassName} jdbc.url=${jdbc.url} jdbc.username=${jdbc.username} jdbc.password=${jdbc.password} hibernate.dialect=${hibernate.dialect} # Needed by Hibernate3 Maven Plugin defined in pom.xml hibernate.connection.username=${jdbc.username} hibernate.connection.password=${jdbc.password} hibernate.connection.url=${jdbc.url} hibernate.connection.driver_class=${jdbc.driverClassName} – asma Jun 10 '13 at 08:32
  • i think the problem caused by hibernate.cfg.xml when i add properties of the hibernate connection the server stop working – asma Jun 10 '13 at 08:33
  • If you run "mvn resources:resources", does the hibernate.properties in target/classes have the correct values in it? – Matt Raible Jun 11 '13 at 15:53
  • in hibernate.properties i find a default configuration for hibernate search :app.search.index.basedir=${user.home}/castor-0.0.1/index # hibernate.search.default.directory_provider=filesystem hibernate.search.default.locking_strategy=simple hibernate.search.default.exclusive_index_use=true hibernate.search.lucene_version=LUCENE_35 hibernate.search.analyzer=org.apache.lucene.analysis.en.EnglishAnalyzer hibernate.search.worker.batch_size=100 – asma Jun 12 '13 at 09:09
  • Removing the hibernate.connection.username and hibernate.connection.password might help. – Matt Raible Jun 13 '13 at 15:23
0

You didn't mention the database connection in hibernate.cfg.xml file:

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/databasename?autoReconnect=true</property>
        <property name="hibernate.connection.username">username</property>
        <property name="hibernate.connection.password">password</property>
        <property name="hibernate.connection.pool_size">20</property>
        <property name="hibernate.connection.autocommit">false</property>
        <property name="hibernate.c3p0.acquire_increment">1</property>
        <property name="hibernate.c3p0.idle_test_period">100</property>
        <property name="hibernate.c3p0.max_size">10</property>
        <property name="hibernate.c3p0.max_statements">10</property>
        <property name="hibernate.c3p0.min_size">10</property>
        <property name="hibernate.c3p0.timeout">100</property>
        <property name="hibernate.show_sql">false</property>
        <property name="hibernate.hbm2ddl.auto">none</property>
        <property name="hibernate.cache.use_query_cache">false</property>
        <property name="hibernate.connection.zeroDateTimeBehavior">convertToNull</property>
        <property name="hibernate.connection.release_mode">auto</property>

    <mapping resource="com/data/users.hbm.xml" />

</session-factory>

required jars: mysql-connector-java-5.1.6-bin.jar, hibernate-commons-annotations-4.0.1.Final, hibernate-core-4.0.0.Final

UdayKiran Pulipati
  • 6,579
  • 7
  • 67
  • 92