<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ceres Logic :: Blog &#187; glassfish</title>
	<atom:link href="http://www.cereslogic.com/pages/tag/glassfish/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cereslogic.com/pages</link>
	<description>Mobile and Web App Development</description>
	<lastBuildDate>Tue, 23 Aug 2011 14:45:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Glassfish to Tomcat w/ JDBC Connection Pooling</title>
		<link>http://www.cereslogic.com/pages/2008/01/21/glassfish-to-tomcat-w-jdbc-connection/</link>
		<comments>http://www.cereslogic.com/pages/2008/01/21/glassfish-to-tomcat-w-jdbc-connection/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 18:31:00 +0000</pubDate>
		<dc:creator>mdesjardins</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mikedesjardins.us/wordpress/2008/01/glassfish-to-tomcat-w-jdbc-connection-pooling/</guid>
		<description><![CDATA[Here&#8217;s your don&#8217;t-waste-hours-on-something-silly-that-I-did tip for the day. I recently had the opportunity to change an existing in-house web application from running under Tomcat 5.5, to Glassfish v2. The application uses JDBC connection pooling in the application server, and uses JNDI to find the pool. The only stumbling block I encountered was that, immediately after deploying [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s your don&#8217;t-waste-hours-on-something-silly-that-I-did tip for the day.</p>
<p>I recently had the opportunity to change an existing in-house web application from running under Tomcat 5.5, to Glassfish v2.    The application uses JDBC connection pooling in the application server, and uses JNDI to find the pool.  The only stumbling block I encountered was that, immediately after deploying the application, Hibernate would always complain that it couldn&#8217;t find the connection:</p>
<p><span style="font-size:78%;"><span style="font-family:courier new;">org.hibernate.HibernateException: Could not find datasource</span><br /><span style="font-family:courier new;">        at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)</span><br /><span style="font-family:courier new;">        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)</span><br /><span style="font-family:courier new;">        at </span><span style="font-family:courier new;"></span><br /><span style="font-family:courier new;">.</span><br /><span style="font-family:courier new;">.</span><br /><span style="font-family:courier new;">(yadda yadda)</span><br /><span style="font-family:courier new;">.</span><br /><span style="font-family:courier new;">Caused by: javax.naming.NameNotFoundException: No object bound to name java:/comp/env/jdbc/MyDB<br />.<br />.<br /></span></span><br />As it turns out, the datasource that I was using in hibernate.cfg.xml was perfectly fine for Tomcat, but not for Glassfish.  I had put the fully qualified JNDI file in my config file:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;connection.datasource&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>java:/comp/env/jdbc/ApptrackDB<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Glassfish doesn&#8217;t like that.   Once I changed it to:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;connection.datasource&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>jdbc/ApptrackDB<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Everything worked swimmingly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cereslogic.com/pages/2008/01/21/glassfish-to-tomcat-w-jdbc-connection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

