3 Replies Latest reply on Nov 16, 2015 9:29 AM by rareddy

    connect vdb by jndi name from hibernate

    prashanthi1

      Hi,

      i am able to connect to a VDB from hibernate by giving the vdb connection details in hibernate.config file.

      I am trying to connect by JNDI name, but i get  "org.hibernate.engine.jndi.JndiException: Error parsing JNDI name" and " javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial" errors.

       

      below is my config file

                        <property name="hibernate.hbm2ddl.auto">update</property> 

                        <property name="hibernate.dialect">org.teiid.dialect.TeiidDialect</property>

                        <property name="hibernate.connection.datasource">java:comp/env/jdbc/userDS</property>  

                        <property name="hibernate.connection.driver_class">org.teiid.jdbc.TeiidDriver</property>

                        <property name="hibernate.order_updates">true</property>

       

      My datasource in standalone.xml file is as below:

      <datasource jndi-name="java:/userDS" pool-name="userDS" enabled="true">

                  <connection-url>jdbc:teiid:userVDB@mm://localhost:8080;user=user;password=user</connection-url>

                          <driver>teiid</driver>

                          <security>

                              <user-name>user</user-name>

                              <password>user</password>

                          </security>

                      </datasource>

             

      Do i need to make any settings changes to make a successfull connection?

       

      thanks in advance,

      Prashanthi

        • 1. Re: connect vdb by jndi name from hibernate
          rareddy

          Use the JNDI name in the config file as defined in the data source, which is "java:/UserDS"

          • 2. Re: connect vdb by jndi name from hibernate
            prashanthi1

            I have tried giving the same name as in standlone.xml Ramesh, i get the same error.

            • 3. Re: connect vdb by jndi name from hibernate
              rareddy

              Ok, where is your Hibernate application deployed? inside an application server? standalone JVM? What the exception saying is, wherever your application is residing it can not initialize the "naming services". Typically inside an application server, a default initial context factory  is already set. If you are working in any other host environments, you need to make sure what is what this factory class is and define it at initialization of the naming service. A JNDI name is reference to an object/proxy inside a JVM, how a JNDI resolves to that object is based on that naming service.