Re: Datasource problem again..
yes, clearly a context file for each web app is a better / wiser choice, thanks for the advice ! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource problem again..
Good point. I've done the same, ie setup a within the of server.xml, and defined my data-source there. I've still got a context.xml, but it's now down to just a couple of lines ie to specify docBase, path and a logger. It looks like this now: Just to make it clear what this is all about, you don't need to define a in your server.xml. In my case, my app is called 'isurvey', so I defined a file called 'isurvey.xml' containing the above. I placed this file in {tomcat home}/conf/Catalina/localhost/ , and tomcat was able to automatically detect the app. Regards, John [EMAIL PROTECTED] Ph (09) 372-5010 |-+> | | Peng Tuck Kwok | | | <[EMAIL PROTECTED]| | | om> | | || | | 21/07/2004 05:09 | | | PM | | | Please respond to| | | "Struts Users| | | Mailing List"| | || |-+> >--| | | | To: Struts Users Mailing List <[EMAIL PROTECTED]> | | cc: | | Subject: Re: Datasource problem again.. | >--| Great, that's always good to hear. Also consider providing your own context xml for each app with the war file, might save you some time in server restarts. Unless you changed server.xml through the administrative interface. On Wed, 21 Jul 2004 10:24:21 +0800, Koon Yue Lam <[EMAIL PROTECTED]> wrote: > Tthanks for the help for all of u ! > Finally I get it done, I create a element and nest a > with details of MySql in server.xml and it just work > smoothly~~~ > > Regards > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource problem again..
Great, that's always good to hear. Also consider providing your own context xml for each app with the war file, might save you some time in server restarts. Unless you changed server.xml through the administrative interface. On Wed, 21 Jul 2004 10:24:21 +0800, Koon Yue Lam <[EMAIL PROTECTED]> wrote: > Tthanks for the help for all of u ! > Finally I get it done, I create a element and nest a > with details of MySql in server.xml and it just work > smoothly~~~ > > Regards > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource problem again..
Tthanks for the help for all of u ! Finally I get it done, I create a element and nest a with details of MySql in server.xml and it just work smoothly~~~ Regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource problem again..
> -Original Message- > From: Koon Yue Lam [mailto:[EMAIL PROTECTED] > Sent: Monday, July 19, 2004 7:46 PM > To: Struts Users Mailing List > Subject: Re: Datasource problem again.. > > > Thx ! > Since I am using Tomct 5 with auto-depoly, my Webapp DOESN'T has a > element in server.xml. I think I will has a try to setup in > , or should I manually all a element of my > Webapp in server.xml?? You can provide an xml file with your aut-deploy. See the manual, or appfuse source code for details. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource problem again..
> -Original Message- > From: Koon Yue Lam [mailto:[EMAIL PROTECTED] > Sent: Monday, July 19, 2004 6:54 PM > To: Struts Users Mailing List; Asif Rahman > Subject: Re: Datasource problem again.. > > > Yes, it helps and I know I can get it done if I set the context > element in server.xml, > but if I set the datasource in server.xml, do I need to set the > in struts-config.xml again?? > > If I am right, I think if datasource is setup in server.xml, it has > the scope of entire Tomcat, that means all webapps can use that > datasource. Also it can be retrieved by JNDI. Nope.. not right... read the tomcat documentation here: http://jakarta.apache.org/tomcat/index.html You will find that the data source can be scoped to your application, or to the server. > > If the datasource is setup in struts-config.xml, the scope becomes > struts only and is specific to only one webapp, and it can't be > retrieved by JNDI. > > So I can setup datasource in both ways, setup in server.xml has much > more flexibilty and benifit from JNDI, why do I need to setup in > struts-config.xml?? rtfm. > > once again, thanks, ^^ > > Regards > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource problem again..
thanks for the help ! I will give it a try - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource problem again..
You can still have a context regardless of whether you auto deploy or not. See that snippet that jthopmson sent? You can deploy that with your war file, I think the name of the xml has to match the war file name if I'm not mistaken. Then you will have a context properly setup with the datasource. On Tue, 20 Jul 2004 11:24:17 +0800, Koon Yue Lam <[EMAIL PROTECTED]> wrote: > Thx !! I will try it out tonight after work !! > and let u know if I sucess or not, ^^ > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource problem again..
Thx !! I will try it out tonight after work !! and let u know if I sucess or not, ^^ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource problem again..
If you're auto-deploying and can get the DefaultContext to work for you, then that's what I'd do. (I'm not auto-deploying, so my case isn't so straight-forward). You always have the fall-back of configuring Context datasources if you run into trouble. There's an example of configuring a DefaultContext with a datasource here: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/defaultcontext.html This is how I've configured my data-source: maxWait 5000 maxActive 4 password ** url jdbc:as400://localhost;naming=system driverClassName com.ibm.as400.access.AS400JDBCDriver maxIdle 2 username ** And this is how I use the data-source in java: Context ctx = new InitialContext(); Context envCtx = (Context) ctx.lookup("java:comp/env"); DataSource ds = (DataSource) envCtx.lookup("jdbc/as400"); I'd be interested to know how you get on with this. Regards, John [EMAIL PROTECTED] Ph (09) 372-5010 |-+> | | Koon Yue Lam | | | <[EMAIL PROTECTED]| | | om> | | || | | 20/07/2004 02:45 | | | PM | | | Please respond to| | | "Struts Users| | | Mailing List"| | || |-+> >--| | | | To: Struts Users Mailing List <[EMAIL PROTECTED]> | | cc: | | Subject: Re: Datasource problem again.. | >--| Thx ! Since I am using Tomct 5 with auto-depoly, my Webapp DOESN'T has a element in server.xml. I think I will has a try to setup in , or should I manually all a element of my Webapp in server.xml?? Regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource problem again..
Thx ! Since I am using Tomct 5 with auto-depoly, my Webapp DOESN'T has a element in server.xml. I think I will has a try to setup in , or should I manually all a element of my Webapp in server.xml?? Regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource problem again..
I recall reading about a month ago that setting up of data-sources in struts-config was purely for some backwards-compatability issue, and was no longer advised. I haven't bothered to do it. I set up my data source in a server.xml context, and it works fine. Like you I'd prefer to have server-wide scope on the data-source rather than context scope, but I haven't spent any time on it yet. One option may be to configure the data-source as part of the DefaultContext. I believe all other contexts inherit from a DefaultContext if one is configured - but like I said, I haven't tried it yet. Regards, John [EMAIL PROTECTED] Ph (09) 372-5010 |-+> | | Koon Yue Lam | | | <[EMAIL PROTECTED]| | | om> | | || | | 20/07/2004 01:54 | | | PM | | | Please respond to| | | "Struts Users| | | Mailing List"| | || |-+> >--| | | | To: Struts Users Mailing List <[EMAIL PROTECTED]>, Asif Rahman <[EMAIL PROTECTED]> | | cc: | | Subject: Re: Datasource problem again.. | >--| Yes, it helps and I know I can get it done if I set the context element in server.xml, but if I set the datasource in server.xml, do I need to set the in struts-config.xml again?? If I am right, I think if datasource is setup in server.xml, it has the scope of entire Tomcat, that means all webapps can use that datasource. Also it can be retrieved by JNDI. If the datasource is setup in struts-config.xml, the scope becomes struts only and is specific to only one webapp, and it can't be retrieved by JNDI. So I can setup datasource in both ways, setup in server.xml has much more flexibilty and benifit from JNDI, why do I need to setup in struts-config.xml?? once again, thanks, ^^ Regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource problem again..
Yes, it helps and I know I can get it done if I set the context element in server.xml, but if I set the datasource in server.xml, do I need to set the in struts-config.xml again?? If I am right, I think if datasource is setup in server.xml, it has the scope of entire Tomcat, that means all webapps can use that datasource. Also it can be retrieved by JNDI. If the datasource is setup in struts-config.xml, the scope becomes struts only and is specific to only one webapp, and it can't be retrieved by JNDI. So I can setup datasource in both ways, setup in server.xml has much more flexibilty and benifit from JNDI, why do I need to setup in struts-config.xml?? once again, thanks, ^^ Regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource problem again..
I tried using the tags in struts-config.xml, couldnt get it work so I modified the server.xml in tomcat/conf directly. Just add a context element as follows in your server.xml This is my configuration: factory org.apache.commons.dbcp.BasicDataSourceFactory maxActive 200 maxIdle 10 maxWait 20 username (*place your username here) password (*place your password here) driverClassName com.microsoft.jdbc.sqlserver.SQLServerDriver url jdbc:microsoft:sqlserver://(***place your URL here) Hope this helps. -Asif - Original Message - From: "Koon Yue Lam" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, July 19, 2004 12:46 PM Subject: Datasource problem again.. > Hi ! > I have try the follow to retrieve a datasource from Struts using JNDI: > > Context initCtx = new InitialContext(); > Context envCtx = (Context) initCtx.lookup("java:comp/env"); > DataSource ds = (DataSource) envCtx.lookup("jdbc/kiss_web_news"); > > but it doesn't work > > it is my struts-config,xml: > > >property="driverClassName" > value="org.gjt.mm.mysql.Driver" /> >property="url" > value="jdbc:mysql://localhost/kiss_web_news" /> >property="username" > value="root" /> >property="password" > value="1234567" /> > > > > Do I need to modify the web.xml under $Tomcat/conf ?? It seems that > Stucts doesn't registry the datasource to JNDI and I always get a null > pointer of datasource. > > any help? > > Regards > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource problem again..
P.S. here you go: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-resources-howto.html Enjoy! :) Geeta > -Original Message- > From: Koon Yue Lam [mailto:[EMAIL PROTECTED] > Sent: Monday, July 19, 2004 12:46 PM > To: Struts Users Mailing List > Subject: Datasource problem again.. > > > Hi ! > I have try the follow to retrieve a datasource from Struts using JNDI: > > Context initCtx = new InitialContext(); > Context envCtx = (Context) initCtx.lookup("java:comp/env"); > DataSource ds = (DataSource) envCtx.lookup("jdbc/kiss_web_news"); > > but it doesn't work > > it is my struts-config,xml: > > >property="driverClassName" > value="org.gjt.mm.mysql.Driver" /> >property="url" > value="jdbc:mysql://localhost/kiss_web_news" /> >property="username" > value="root" /> >property="password" > value="1234567" /> > > > > Do I need to modify the web.xml under $Tomcat/conf ?? It seems that > Stucts doesn't registry the datasource to JNDI and I always get a null > pointer of datasource. > > any help? > > Regards > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource problem again..
> -Original Message- > From: Koon Yue Lam [mailto:[EMAIL PROTECTED] > Sent: Monday, July 19, 2004 12:46 PM > To: Struts Users Mailing List > Subject: Datasource problem again.. > > > > Do I need to modify the web.xml under $Tomcat/conf ?? You have to add a "Resource" element in your context in server.xml. Here's the sort of thing that works for us: factory org.apache.commons.dbcp.BasicDataSourceFactory serverName localhost username TheUserName password ThePassword driverClassName com.sybase.jdbc2.jdbc.SybDriver url jdbc:sybase:Tds:MyServername:portname?servicename=MyServiceName validationQuery select count(*) from a tablename where something maxActive 1 maxIdle 1 removeAbandoned true removeAbandonedTimeout 60 > > Regards Let me know if you need additional info and I can send you a link where I read up on these details: in a rush now for a meeting..(:( Geeta - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]