Article View: borland.public.jbuilder.database
Article #430Re: Help with JNDI Datasource in JBuilder 2006
From: willhiker
Date: Thu, 08 Dec 2005 14:05
Date: Thu, 08 Dec 2005 14:05
121 lines
5469 bytes
5469 bytes
mybe you can just put <Resource> to the config/server.xml and add
<resource-ref> to the WEB-INF/web.xml
"Paul Furbacher [TeamB]" <pfurbacher@mac.com>
??????:439696f1@newsgroups.borland.com...
> Tom wrote:
>
> > Paul - thanks for all of your help and responses.
>
> Well, I'm learning things as we go along. Today
> I just migrated a large Web app from Tomcat 4.1.x
> to Tomcat 5.5.12 and it took time and didn't go smoothly.
> One thing which caught me off-guard was the change
> from using <ResourceParameters> to <Resource> attributes.
> Anyway, back to the matter at hand.
>
> > I think I have the server8080.xml file set up correctly and took your
> > advice to move the project to a directory structure that does not
> > contain embedded spaces.
> >
> > You mention "I placed the resource def
> > in <Context> element in the server8080.xml, and referenced
> > it from the Spring app context xml file."
>
> Yes, this was just to prove that the resource (the datasource)
> was being instantiated correctly. But configuring for Spring
> is different from that of a non-Spring Web app.
>
> > This may be the piece I am missing. Does this only apply to Spring
> > applications (app context file)? I am using JSF (not Spring)and am
> > placing the reference within the application web.xml file? Is this
> > correct?
>
> As you pointed out in your first message in this thread,
> you initially put the <res-ref> definition in the web.xml
> file where it should be. Quoting you:
>
> > 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>
>
> I went back to the Bookstore JSF example Web app and did the
> following:
>
> 1. The server is already set to Tomcat 5.5.
>
> 2. In the server8080.xml, I did the following:
>
> - removed the comment line
> - expanded the <Context .../> to read
> <Context ...>
> </Context>
> - nested in the <Context></Context>
> the dataSource <Resource> definition
> (I'll use the one from your first post here,
> I've broken lines for readability only)
>
> <Context debug="6"
> docBase=
> "d:\<path_to_samples>\samples\jsf\Tomcat\Tomcat\bookstore"
> path="/bookstore"
> reloadable="true"
> workDir="... just lazy to type it ... >
>
> <Resource name="jdbc/mysql"
> auth="Container"
> type="javax.sql.DataSource"
> maxActive="10" maxIdle="30" maxWait="10000"
> username="root" password="pat"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost:3306/test" />
> </Context>
>
>
> 3. In the class DBAccess.java, I modified the constructor:
>
> public DbAccess() {
> currentUser = null;
>
> // PF added this to test getting dataSource from JNDI
> try {
> InitialContext ctx = new InitialContext();
> DataSource ds =
> (DataSource)ctx.lookup("java:comp/env/jdbc/mysql");
> }
> catch ( Exception ex ) {
> ex.printStackTrace();
> }
> }
>
> I don't do anything with the dataSource, but the fact that the
> Web app starts up successfully and no stacktraces are shown in
> the Message Pane shows that this way of configuring a JNDI
> dataSource works for Tomcat 5.5.9 being managed by JBuilder
> 2006. However, from my experience today with a stand-alone
> Tomcat 5.5.12, this way of configuring in server.xml is
> frowned upon, and should be done in a META-INF/context.xml
> file, as you noted earlier in the discussion.
>
>
> --
>
>
> Paul Furbacher (TeamB)
>
> Save time, search the archives:
> http://info.borland.com/newsgroups/ngsearch.html
>
> Is it in Joi Ellis's Faq-O-Matic?
> http://www.visi.com/~gyles19/fom-serve/cache/1.html
>
> Finally, please send responses to the newsgroup only.
> That means, do not send email directly to me.
> Thank you.
Technical Details
Message-ID:
<43983d7f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!pd7cy1no!shaw.ca!news-out.newsgroups.com!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> <43939b56$1@newsgroups.borland.com> <4394a216$1@newsgroups.borland.com> <439662f1$1@newsgroups.borland.com> <439696f1@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 From: "willhiker" <willhiker@hotmail.com.cn> Newsgroups: borland.public.jbuilder.database References: <438a4e03$1@newsgroups.borland.com> <438be2d7$1@newsgroups.borland.com> <43939b56$1@newsgroups.borland.com> <4394a216$1@newsgroups.borland.com> <439662f1$1@newsgroups.borland.com> <439696f1@newsgroups.borland.com> Subject: Re: Help with JNDI Datasource in JBuilder 2006 Date: Thu, 8 Dec 2005 22:05:52 +0800 Lines: 123 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 61.183.91.0 Message-ID: <43983d7f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1134050687 61.183.91.0 (8 Dec 2005 06:04:47 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!pd7cy1no!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail