Article View: borland.public.jbuilder.database
Article #424Re: Help with JNDI Datasource in JBuilder 2006
From: Tom
Date: Mon, 05 Dec 2005 01:45
Date: Mon, 05 Dec 2005 01:45
116 lines
5956 bytes
5956 bytes
Paul Furbacher [TeamB] wrote: > Tom Butler wrote: > >> Need help getting JNDI MySQL database source setup correctly within >> JBuilder >> 2006 to support a JSF application. I am able to access the database >> using >> a non-JNDI based approach, and, I was also able to get JNDI to work >> outside >> of JBuilder 2006 using the configuration described below. >> >> I am using the following tomcat documentation as a guide: >> http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html >> >> I have looked through a number of posts and examples, but at this point >> (after many non-frutile hours) need someone with experience to help me to >> get the configuration correct. >> >> 1. Install JDBC Driver >> * have 'mysql-connector-java-3.1.11-bin.jar' installed to >> /myapp/webmodule/WEB-INF/lib > > > No, you don't manage this; JBuilder does. As noted five > gazillion times in these newsgroups, you create a JBuilder > library (see JBuilder Help if you don't know how to do this) > and add it to your project. You configure your Web Module to > copy all resources. Read the JBuilder Help on developing > Web apps and all about Web Module configuration. Note the > Content > Dependencies page in the Web Module properties > dialog. (By default, your "required libraries" are set to > "Include all" which is what you want.) Use the samples/jsf/ > Tomcat/bookstore.jpx Web module as a learning tool. > >> * also have JDBC driver installed to >> /JBuilder2006/thirdparty/jakarta-tomcat-5.5.9/common/lib (this was >> done as a >> troubleshooting step though; prefer to only install this within the >> project >> directory) > > > No, don't put the driver lib in the thirdparty dirs. > >> >> 2. Declare your Resource Requirements >> * following code included in web.xml within project: >> /myapp/webmodule/WEB-INF/web.xml >> <resource-ref> >> <description>MySQL DB Connection</description> >> <res-ref-name>jdbc/mysql</res-ref-name> >> <res-type>javax.sql.DataSource</res-type> >> <res-auth>Container</res-auth> >> </resource-ref> > > > This is correct. > >> [...] >> 4. Configure Tomcat's Resource Factory >> * context.xml contents located at: >> /JBuilder2006/thirdparty/jakarta-tomcat-5.5.9/conf/context.xml > > > [...] > > JBuilder manages Tomcat runs, so I doubt that monkeying > with the thirdparty directory XML files will get you where > you want to go. In general, don't touch those. > >> [...] ANY SUGGESTIONS? >> * Do I need anything specified in the server.xml file? > > > Yes, isn't that the place where you generally place the > resource definition? I just opened up the JBuilder/samples/ > jsf/Tomcat/bookstore.jpx and tested using Tomcat 5.5. Do > this yourself, and run the "Server" runtime config. Then > while the Web app is running, do a "File open" in JBuilder, > navigate to the "Project" dir via the "Favorites" panel > on the left. Click on the "Tomcat/conf" dir, and open > the server8080.xml file. From here on in, I'll ask you > to do some research: following the generously available > instructions in the newsgroup archives on editing "server8080.xml" > (search keywords "edit server8080 tomcat"), edit the file, adding > your <Resource ...> definition. > > No luck still - note I'm working on this issue now as a separate thread 'JNDI Connection Problem Thread' (in this newsgroup), however, I wanted to mention that I took a look at the Bookstore code and saw that it does not use JNDI / Connection Pooling: from bookstore dbaccess.java Class.forName(driverClassName); Connection con = DriverManager.getConnection(url, user, password); So this is not a good representative example. I think one reason why others have stumbled on this issue is that in TomCat 5.5, the JNDI context information is suppose to be located in /META-INF/context.xml. I have searched through the archives - found lots of posts with questions on this topic, but no answers (can reference all of the articles if needed.) It would be good if there was a detailed step-by-step how to for setting up a JNDI datasource resource to support database connection pooling for JBuilder 2006, or, if Borland would set up the TomCat configuration files using the Tomcat standards (reference http://tomcat.apache.org/tomcat-5.0-doc/jndi-resources-howto.html)- this way, when users who understand TomCat have an issue, they will no which files to look in to troubleshoot - with Jbuilder, its a real mystery since within the IDE the TomCat configuration file standards are not followed (i.e., placing JNDI context information in /META-INF/context.xml.) Any help that can be provided is still appreciated, though reference the 'JNDI Connection Problem Thread' as it contains details for my config. thanks
Technical Details
Message-ID:
<43939b56$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out.superfeed.net!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<438a4e03$1@newsgroups.borland.com> <438be2d7$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1073da,634e789a0dc75d45 X-Google-Attributes: gid1073da,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Sun, 04 Dec 2005 20:45:08 -0500 From: Tom <tom.butler@adephia.net> User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.database Subject: Re: Help with JNDI Datasource in JBuilder 2006 References: <438a4e03$1@newsgroups.borland.com> <438be2d7$1@newsgroups.borland.com> In-Reply-To: <438be2d7$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 68.235.63.81 Message-ID: <43939b56$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1133747030 68.235.63.81 (4 Dec 2005 17:43:50 -0700) Lines: 116 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out.superfeed.net!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail