-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JNDI Configuration in Tomcat 5.5 for use in Hibernate
PostPosted: Tue Apr 20, 2010 10:41 am 
Newbie

Joined: Tue Apr 20, 2010 10:30 am
Posts: 2
Hi All,
I am not sure whether the same problem has been discussed before or not.
I am facing one problem in configuring JNDI entry in a sinple Web Apps which is using Tomcat 5.5

Specification i am using: Hibernate 3.0
Tomcat 5.5

Problem Description:

I have following entries in Tomcat's server.xml:

<Resource driverClassName="oracle.jdbc.driver.OracleDriver" logAbandoned="true" maxActive="4" maxIdle="2" maxWait="5000" name="jdbc/DB2DataSource" password="password" removeAbandoned="true" removeAbandonedTimeout="55" type="javax.sql.DataSource" url="jdbc:oracle:thin:@x.x.x.x:1521:dbname" username="user"/>


Entries in hibernate.cfg.xml is:

<hibernate-configuration>
<session-factory name="java:hibernate/SessionFactory">
<property name="connection.datasource">jdbc/DB2DataSource</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<!-- Mapping files -->
<mapping resource="sample.hbm.xml"/>
</session-factory>
</hibernate-configuration>

When I am running my application i am getting the following exception:

SEVERE: Could not find datasource: jdbc/DB2DataSource
Throwable occurred: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:366)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1859)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1152)
at com.safmarine.fact.servlet.CheckVendorDetail.doPost(CheckVendorDetail.java:35)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)



I googled a lot and found that I need to use java:/comp/env/jdbc/DB2DataSource as connection.datasource in hibernate.cfg file. That means it looks like :

<hibernate-configuration>
<session-factory name="java:hibernate/SessionFactory">
<property name="connection.datasource">jdbc/DB2DataSource</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<!-- Mapping files -->
<mapping resource="sample.hbm.xml"/>
</session-factory>
</hibernate-configuration>

And still I am getting the exception like below:

SEVERE: Could not find datasource: java:/comp/env/jdbc/DB2DataSource
Throwable occurred: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:366)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1859)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1152)





Can somebody please help me. How can i define the JNDI entry and run mmy application? Its very urgent. Please respond. I will be highly obliged.

Thanks in advance.

Cheers,
Swarup


Top
 Profile  
 
 Post subject: Re: JNDI Configuration in Tomcat 5.5 for use in Hibernate
PostPosted: Tue Apr 20, 2010 11:00 am 
Regular
Regular

Joined: Thu May 07, 2009 5:56 am
Posts: 94
Location: Toulouse, France
are you sure that your datasource is set and active in tomcat? you can see it? have you taken a look at http://tomcat.apache.org/tomcat-5.5-doc ... howto.html?

_________________
everything should be made as simple as possible, but not simpler (AE)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.