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..
-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 datasource 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..
-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 Context element in server.xml. I think I will has a try to setup in default-context, or should I manually all a context 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..
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 default-context element and nest a resource 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..
Good point. I've done the same, ie setup a DefaultContext within the Host 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: ?xml version='1.0' encoding='utf-8'? Context docBase=/webapps/isurvey path=/isurvey reloadable=true swallowOutput=true Logger className=org.apache.catalina.logger.FileLogger prefix=isurvey_log. suffix=.txt timestamp=true/ /Context Just to make it clear what this is all about, you don't need to define a Context in your server.xml. In my case, my app is called 'isurvey', so I defined a file called 'isurvey.xml' containing the Context 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 default-context element and nest a resource 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..
-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: Context path=/TDX docBase=TDX debug=0 reloadable=true crossContext=true Resource name=jdbc/tdxDB auth=Container type=javax.sql.DataSource / ResourceParams name=jdbc/tdxDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter nameserverName/name valuelocalhost/value /parameter parameter nameusername/name valueTheUserName/value /parameter parameter namepassword/name valueThePassword/value /parameter parameter namedriverClassName/name valuecom.sybase.jdbc2.jdbc.SybDriver/value /parameter parameter nameurl/name valuejdbc:sybase:Tds:MyServername:portname?servicename=MyServiceName/value /parameter parameter namevalidationQuery/name valueselect count(*) from a tablename where something/value /parameter parameter namemaxActive/name value1/value /parameter parameter namemaxIdle/name value1/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value60/value /parameter /ResourceParams /Context 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]
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: data-sources data-source type=org.apache.commons.dbcp.BasicDataSource set-property property=driverClassName value=org.gjt.mm.mysql.Driver / set-property property=url value=jdbc:mysql://localhost/kiss_web_news / set-property property=username value=root / set-property property=password value=1234567 / /data-source /data-sources 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..
I tried using the datasources 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: Context path=/wrap docBase=C:\tomcat5\webapps\wrap reloadable=true Resource name=jdbc/WrapDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/WrapDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter !-- Maximum number of dB connections in pool. Make sure you configure your mysqld max_connections large enough to handle all of your db connections. Set to 0 for no limit. -- parameter namemaxActive/name value200/value /parameter !-- Maximum number of idle dB connections to retain in pool. Set to 0 for no limit. -- parameter namemaxIdle/name value10/value /parameter !-- Maximum time to wait for a dB connection to become available in ms, in this example 10 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely. -- parameter namemaxWait/name value20/value /parameter !-- dB username and password for dB connections -- parameter nameusername/name value(*place your username here) /value /parameter parameter namepassword/name value(*place your password here)/value /parameter !-- Class name for oracle JDBC driver -- parameter namedriverClassName/name valuecom.microsoft.jdbc.sqlserver.SQLServerDriver/value /parameter parameter nameurl/name valuejdbc:microsoft:sqlserver://(***place your URL here)/value /parameter /ResourceParams /Context 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: data-sources data-source type=org.apache.commons.dbcp.BasicDataSource set-property property=driverClassName value=org.gjt.mm.mysql.Driver / set-property property=url value=jdbc:mysql://localhost/kiss_web_news / set-property property=username value=root / set-property property=password value=1234567 / /data-source /data-sources 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..
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 datasource 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 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 datasource 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..
Thx ! Since I am using Tomct 5 with auto-depoly, my Webapp DOESN'T has a Context element in server.xml. I think I will has a try to setup in default-context, or should I manually all a context 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..
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: Context docBase=/webapps/isurvey path=/isurvey reloadable=true Resource name=jdbc/as400 auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/as400 parameter namemaxWait/name value5000/value /parameter parameter namemaxActive/name value4/value /parameter parameter namepassword/name value**/value /parameter parameter nameurl/name valuejdbc:as400://localhost;naming=system/value /parameter parameter namedriverClassName/name valuecom.ibm.as400.access.AS400JDBCDriver/value /parameter parameter namemaxIdle/name value2/value /parameter parameter nameusername/name value**/value /parameter /ResourceParams /Context 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 Context element in server.xml. I think I will has a try to setup in default-context, or should I manually all a context 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..
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..
thanks for the help ! I will give it a try - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]