Thanks Mathias, just after I sent the email I got it working using the key
as you suggested.  I tried using the key earlier today and it didn't work,
probably I had some other problem which I accidentally fixed and now I've
confused myself.

Shouldn't it work without the key since I only have the one datasource
and all the docs I've seen don't require the key. My understanding is that
the key is only required when there is more than one datasource. No?

Thanks for your help.

Chris


On Wed, 7 Jan 2004, Matthias Wessendorf wrote:

> hi chris,
>
> have you tried:
>
> getDataSource(req,"dataSource");
>
>
> greetings
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 07, 2004 10:25 AM
> To: [EMAIL PROTECTED]
> Subject: Datasource problem
>
>
> Hi,
>
> I must be missing something here but for the life of me I cannot see
> what it is. I've search the mail archives and can't find anything the
> same, also I checked 3 different books and it looks like I have
> everything configured correctly, I also tried two diffent MySQL drivers.
>
> I have added a datasource to my struts-config and when I run the
> application I can see it initializes ok:
>
> Jan 7, 2004 10:09:48 PM org.apache.struts.legacy.GenericDataSource
> createConnection
> INFO:    createConnection()
> Jan 7, 2004 10:09:49 PM org.apache.struts.legacy.GenericDataSource
> createConnection
> INFO:    createConnection()
>
> If I mess up the password I get an access denied error on the db when
> this runs so that tells me I am getting a connection.
>
> But when I try to access the datasource inside my action using the
> following code:
>
> DataSource dataSource = getDataSource(req);
>
> dataSource returns null which is where I'm stumped.
>
> Anyone get any idea what this might be? I'm using struts 1.1 and tried
> JDK 1.4 and 1.3.
>
> Here's my struts-config:
>
> <data-sources>
>   <data-source key="dataSource">
>     <set-property property="driverClass" value="com.mysql.jdbc.Driver"/>
>     <set-property property="url"
> value="jdbc:mysql://127.0.0.1:3306/ash"/>
>     <set-property property="user" value="myusername" />
>     <set-property property="password" value="mypassword" />
>     <set-property property="minCount" value="2" />
>     <set-property property="maxCount" value="4" />
>   </data-source>
> </data-sources>
>
>
> The exception is java.lang.NullPointerException which results from
> trying to use the null dataSource.
>
> There is one other compiler error I am getting when I build the project
> which I still trying to track down:
>
> Jan 7, 2004 10:09:48 PM org.apache.commons.digester.Digester error
> SEVERE: Parse Error at line 19 column -1: Attribute value for "path" is
> #REQUIRED.
> org.xml.sax.SAXParseException: Attribute value for "path" is #REQUIRED.
>       at org.apache.crimson.parser.Parser2.error(Parser2.java:3317)
>       at
> org.apache.crimson.parser.Parser2.defaultAttributes(Parser2.java:1889)
>       at
> org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1600)
>       at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
>       at
> org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
>       at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
>       at
> org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
>       at
> org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:634)
>       at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
>       at
> org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
>       at
> org.apache.commons.digester.Digester.parse(Digester.java:1548)
>       at
> org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServl
> et.java:1006)
>       at
> org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.ja
> va:955)
>       at
> org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
>       at javax.servlet.GenericServlet.init(GenericServlet.java:256)
>       at
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.jav
> a:918)
>       at
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:810)
>       at
> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.j
> ava:3279)
>       at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:3421
> )
>       at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
>       at
> org.apache.catalina.core.StandardHost.start(StandardHost.java:638)
>       at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
>       at
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:343)
>       at
> org.apache.catalina.core.StandardService.start(StandardService.java:388)
>       at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:506)
>       at org.apache.catalina.startup.Catalina.start(Catalina.java:781)
>       at
> org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
>       at
> org.apache.catalina.startup.Catalina.process(Catalina.java:179)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:324)
>
>
> Thanks for any advice.
>
>
> Chris
>
>
> ---------------------------------------------------------------------
> 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]

Reply via email to