Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

[HIBERNATE] Not binding factory to JNDI, no JNDI name configured  RSS feed

Roberto Lopez Lopez
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there!

I'm configuring a struts project to access a mysql db through hibernate. It's my first time configuring hibernate in a project, so I have some problems.

The more important, and the only I can't solve is this:
  • I have written my hibernate.cfg.xml with the config stuff.
  • I have written some table mappings (and their beans) and introduced them into hibernate.cfg.xml.
  • I have written a plugin to hook hibernate into struts, and declared it into struts-config.xml.

  • I package the whole project (struts + hibernate) and deploy it to my JBoss 4.2.2 server. Then, I get the following output:
    11:39:03,021 INFO [TomcatDeployer] deploy, ctxPath=/XXXXXXX, warUrl=.../tmp/deploy/tmp23130XXXXXXX-exp.war/
    11:39:03,391 INFO [ActionServlet] Loading chain catalog from jndi:/localhost/XXXXXXX/WEB-INF/chain-config.xml
    11:39:03,924 INFO [TilesPlugin] Tiles definition factory loaded for module ''.
    11:39:04,003 INFO [Environment] Hibernate 3.2.6
    11:39:04,010 INFO [Environment] not found
    11:39:04,015 INFO [Environment] Bytecode provider name : javassist
    11:39:04,024 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
    11:39:04,141 INFO [Configuration] configuring from url: file:/opt/jboss-4.2.2.GA/server/default/tmp/deploy/tmp23130XXXXXXX-exp.war/WEB-INF/hibernate.cfg.xml
    11:39:04,151 INFO [Configuration] Reading mappings from resource : /com/encore/XXXXXXX/hibernate/mappings/Paises.hbm.xml
    11:39:05,535 INFO [HbmBinder] Mapping class: com.encore.XXXXXXX.hibernate.beans.Paises -> paises
    11:39:05,570 INFO [Configuration] Reading mappings from resource : /com/encore/XXXXXXX/hibernate/mappings/Subcategorias.hbm.xml
    11:39:06,870 INFO [HbmBinder] Mapping class: com.encore.XXXXXXX.hibernate.beans.Subcategorias -> subcategorias
    11:39:06,874 INFO [Configuration] Reading mappings from resource : /com/encore/XXXXXXX/hibernate/mappings/SubcategoriasUser.hbm.xml
    11:39:08,213 INFO [HbmBinder] Mapping class: com.encore.XXXXXXX.hibernate.beans.SubcategoriasUser -> subcategorias_user
    11:39:08,214 INFO [Configuration] Configured SessionFactory: null
    11:39:08,383 INFO [DriverManagerConnectionProvider] Using Hibernate built-in connection pool (not for production use!)
    11:39:08,383 INFO [DriverManagerConnectionProvider] Hibernate connection pool size: 20
    11:39:08,383 INFO [DriverManagerConnectionProvider] autocommit mode: false
    11:39:08,384 INFO [DriverManagerConnectionProvider] using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/XXXXXXX
    11:39:08,384 INFO [DriverManagerConnectionProvider] connection properties: {user=administrador, password=ubuntur00t}
    11:39:08,397 INFO [SettingsFactory] RDBMS: MySQL, version: 5.0.51a-3ubuntu5.1
    11:39:08,397 INFO [SettingsFactory] JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.5 ( Revision: ${svn.Revision} )
    11:39:08,421 INFO [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
    11:39:08,428 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
    11:39:08,431 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    [...SettingsFactory info...]
    11:39:08,506 INFO [SessionFactoryImpl] building session factory
    11:39:09,058 INFO [DriverManagerConnectionProvider] cleaning up connection pool: jdbc:mysql://localhost:3306/XXXXXXX
    11:39:09,251 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured

    As you can read on the last line, the factory isn't bound to any JNDI uri. Could anyone help me? Bellow are my config files.

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    <property name="connection.url">jdbc:mysql://localhost:3306/NoLlego</property>
    <property name="connection.username">XXX</property>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="connection.password">XXXX</property>
    <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    <!-- thread is the short name for
    and let Hibernate bind the session automatically to the thread
    <property name="current_session_context_class">thread</property>
    <!-- this will show us all sql statements -->
    <property name="hibernate.show_sql">true</property>

    <!-- mapping files -->
    <mapping resource="/com/encore/XXXXXXX/hibernate/mappings/Paises.hbm.xml"/>
    <mapping resource="/com/mmm/XXXXXXX/hibernate/mappings/Subcategorias.hbm.xml"/>
    <mapping resource="/com/mmm/XXXXXXX/hibernate/mappings/SubcategoriasUser.hbm.xml"/>


    <!-- ... -->
    <plug-in className="com.mmm.XXXXXXX.hibernate.plugin.HibernatePlugin">
    <set-property property="path" value="/WEB-INF/hibernate.cfg.xml"/>

    By the way, I don't understand hibernate-service.xml. I have read that I need to introduce the server datasource I want hibernate to use, but in hibernate.cfg.xml I have written the uri of mysql. Isn't it redundant? It's necessary to introduce the datasource in hibernate-service.xml??? Bellow its code:
    <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
    <attribute name="DatasourceName">java:/DefaultDS</attribute>
    <attribute name="Dialect">org.hibernate.dialect.MySQLDialect</attribute>
    <attribute name="SessionFactoryName">java:/hibernate/XXXXXXX</attribute>
    <attribute name="CacheProviderClass">

    <attribute name="Hbm2ddlAuto">create-drop</attribute>
    <attribute name="ShowSqlEnabled">true</attribute>

    The last question: do I need to separately package the hibernate application to access it from my struts webapp? I'm using ant to package and deploy my war, is there any ant task to package a har? I've searched on google and didn't found anything.

    Thank you very much in advance.
    Kris Nuttycombe
    Posts: 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Did you find a solution to this issue? I'm encountering a similar problem using Hibernate with Lift and Glassfish.


    Mahesh Kedari
    Ranch Hand
    Posts: 111
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Are you getting any error because of that?
    As far as i know it just a warning which means Hibernate didn't bind the SessionFactory to JNDI, but that it will use Datasources from JNDI.
    This warning is displayed probably because, either you have not configured the JNDI setting correctly or your server does not support the transaction or you are using the hibernate library in offline environment.
    I am getting this warning for my desktop application, but I am ignoring the same as it is no where impacting my application's functionality.

    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!