RE: Datasource problem

2004-01-07 Thread Matthias Wessendorf
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 

RE: Datasource problem

2004-01-07 Thread cnd
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 

RE: Datasource problem

2004-01-07 Thread Matthias Wessendorf
hi Chris!

only one can be defined without a key 

it is stored under default:
Globals.DATA_SOURCE_KEY

and of cource
in struts 1.2 you must!!! specify a type

in 1.1 it is a legacy-class
GenericDataSource (by default)
this is to remove...

you must say then type=org.apache.commons.dbcp.BasicDataSource

for that you must
add two jars
-the DBCP-commons from http://jakarta.apache.org/commons/dbcp/
-the pool-jar from: http://jakarta.apache.org/commons/pool/

for more read:
http://jakarta.apache.org/struts/faqs/database.html

regards,



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 07, 2004 10:44 AM
To: Struts Users Mailing List
Subject: RE: Datasource problem


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(ActionSer
 vl
 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

RE: Datasource problem

2004-01-07 Thread cnd
Hi Matthias,

Thanks for all the info.

As you said that only one can be defined without a key hence if I use
getDataSource(req);  then it should use the default datasource without
me having to specify the Globals.DATA_SOURCE_KEY as the second parameter.
So looking at my struts-config.xml there is only one datasource hence my
reading is that the second parameter is redundant. Also
Globals.DATA_SOURCE_KEY is showing as deprecated so I was avoiding using
it.

Looking at it further I see that part of my problem was that I am using
JBuilder X which adds a key by default, once that key is added
DATA_SOURCE_KEY doesn't work, so obviously the key is the
problem. Once I remove the key I can use the single parameter.

Thanks for your help!

Chris

On Wed, 7 Jan 2004, Matthias Wessendorf wrote:

 hi Chris!

 only one can be defined without a key

 it is stored under default:
 Globals.DATA_SOURCE_KEY

 and of cource
 in struts 1.2 you must!!! specify a type

 in 1.1 it is a legacy-class
 GenericDataSource (by default)
 this is to remove...A

 you must say then type=org.apache.commons.dbcp.BasicDataSource

 for that you must
 add two jars
 -the DBCP-commons from http://jakarta.apache.org/commons/dbcp/
 -the pool-jar from: http://jakarta.apache.org/commons/pool/

 for more read:
 http://jakarta.apache.org/struts/faqs/database.html

 regards,



 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, January 07, 2004 10:44 AM
 To: Struts Users Mailing List
 Subject: RE: Datasource problem


 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

Re: DataSource problem

2003-06-15 Thread Joe @ Team345
Just a guess on my part, but the connection is probably in the JNDI 
namespace, not the COMP namespace.  
To test this you can try either java:/env or just /env (sorry, can't 
recall which off the top of my head) where you have: java:comp/env

As a side point, you should probably put all such logic into a session 
bean(s) that your action classes can call.   Aside from this being a 
more 3-tier architecture it should allow you query your container (for 
instance, using the jmx-console in JBoss) to find out exactly what 
namespace(s) your beans are available in.

hth,

Joe

rainer juenger wrote:

Hi Maarten,

join the club! There are some more guys having exactliy the same problem as
you.
To me your configuration looks all right. I saw some samples :
parameter  namedriverName/name
valuejdbc:mysql://localhost/test/value /parameter
where the parameter name is not driverName but url. I tried both without
luck.
Are you using Tomcat 4.x without DBCP from the Jakarta Commons to get the
JNDI DB Connection?
Please follow the thread Connection pooling dowsn't work for me ... Help
!!
Hopefully there is someone arround giving us a tip how to get it run
Good luck to all of us ;)
Rainer
- Original Message -
From: Maarten Roosendaal [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, June 14, 2002 3:42 PM
Subject: DataSource problem
Hi,

I'm trying to create a simple DataBase app. using Struts. Right now i have a
problem with getting the DataSource out of the InitialContext and i'm not
sure what i'm doing wrong or maybe it has something to do with the Struts
Servlet.
In configured the server.xml as follows:
Resource name=test auth=CONTAINER
 type=javax.sql.DataSource/
ResourceParams name=test
  parameter  nameuser/name
valueroot/value  /parameter
  parameter  namepassword/namevalue/value
/parameter
  parameter  namedriverClassName/name
valueorg.gjt.mm.mysql.Driver/value /parameter
  parameter  namedriverName/name
valuejdbc:mysql://localhost/test/value /parameter
 /ResourceParams
and my web.xml includes the following:
   resource-ref
   res-ref-nametest/res-ref-name
   res-typejavax.sql.DataSource/res-type
   res-authCONTAINER/res-auth
   /resource-ref
In an Action-class i do this:
   Context env = (Context) new
InitialContext().lookup(java:comp/env);
   DataSource ds = (DataSource) env.lookup(test);
Here the DataSource keeps ending up as NULL. When i do this:
   Connection con = DriverManager.getConnection(Commands.DB_TEST_URL,
Commands.DB_TEST_USERNAME, );
   things are working fine but i have no idea where to look. The Context
does seem to have a reference to the 'test' reference but nothing more.
Does this have something to do with Struts or did i forget something? I
don't want to use the struts.xml for a database-connection. One of the
reasons is that i keep getting the message that it can't find the driver,
while it is included in the CLASSPATH.
Hope someone can help,
Maarten


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: DataSource problem

2003-06-15 Thread Adam Hardy
Maarten,
do you declare the JNDI resource within the context tags for your webapp 
in server.xml, or within the global-naming-resources tags? I'm using the 
same setup  as you with my JNDI declared in the globalnamingresources 
and it wouldn't work until I put a resource-link tag in the context tags.

Adam

Joe @ Team345 wrote:
Just a guess on my part, but the connection is probably in the JNDI 
namespace, not the COMP namespace.  To test this you can try either 
java:/env or just /env (sorry, can't recall which off the top of my 
head) where you have: java:comp/env

As a side point, you should probably put all such logic into a session 
bean(s) that your action classes can call.   Aside from this being a 
more 3-tier architecture it should allow you query your container (for 
instance, using the jmx-console in JBoss) to find out exactly what 
namespace(s) your beans are available in.

hth,

Joe

rainer juenger wrote:

Hi Maarten,

join the club! There are some more guys having exactliy the same 
problem as
you.
To me your configuration looks all right. I saw some samples :

parameter  namedriverName/name
valuejdbc:mysql://localhost/test/value /parameter
where the parameter name is not driverName but url. I tried both without
luck.
Are you using Tomcat 4.x without DBCP from the Jakarta Commons to get the
JNDI DB Connection?
Please follow the thread Connection pooling dowsn't work for me ... Help
!!
Hopefully there is someone arround giving us a tip how to get it run
Good luck to all of us ;)
Rainer
- Original Message -
From: Maarten Roosendaal [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, June 14, 2002 3:42 PM
Subject: DataSource problem
Hi,

I'm trying to create a simple DataBase app. using Struts. Right now i 
have a
problem with getting the DataSource out of the InitialContext and i'm not
sure what i'm doing wrong or maybe it has something to do with the Struts
Servlet.

In configured the server.xml as follows:
Resource name=test auth=CONTAINER
 type=javax.sql.DataSource/
ResourceParams name=test
  parameter  nameuser/name
valueroot/value  /parameter
  parameter  namepassword/namevalue/value
/parameter
  parameter  namedriverClassName/name
valueorg.gjt.mm.mysql.Driver/value /parameter
  parameter  namedriverName/name
valuejdbc:mysql://localhost/test/value /parameter
 /ResourceParams
and my web.xml includes the following:
   resource-ref
   res-ref-nametest/res-ref-name
   res-typejavax.sql.DataSource/res-type
   res-authCONTAINER/res-auth
   /resource-ref
In an Action-class i do this:
   Context env = (Context) new
InitialContext().lookup(java:comp/env);
   DataSource ds = (DataSource) env.lookup(test);
Here the DataSource keeps ending up as NULL. When i do this:
   Connection con = DriverManager.getConnection(Commands.DB_TEST_URL,
Commands.DB_TEST_USERNAME, );
   things are working fine but i have no idea where to look. The Context
does seem to have a reference to the 'test' reference but nothing more.
Does this have something to do with Struts or did i forget something? I
don't want to use the struts.xml for a database-connection. One of the
reasons is that i keep getting the message that it can't find the driver,
while it is included in the CLASSPATH.
Hope someone can help,
Maarten


--
To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail: 
mailto:[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

2003-01-02 Thread David M. Karr
 Steven == Steven Dahlin [EMAIL PROTECTED] writes:

Steven I am a little unclear what you mean by using modules?

If you don't know what they are, then you probably aren't using them :) .

It's a mechanism that allows you to subdivide your Struts application into
pieces, each with their own config file.

If you're not using modules, then I don't know what the problem could be.
Perhaps you could use your debugger to trace the loading of your
struts-config.xml file, especially when it stores the data-soure configuration?

David - Original Message -
David From: David M. Karr [EMAIL PROTECTED]

  Steven == Steven Dahlin [EMAIL PROTECTED] writes:
 
Steven When I try to get a datasource which has been defined in the
Steven struts-config.xml no matter what I do the datasource returns back null.  My
Steven struts-config.xml for data-sources is:
Steven data-sources
 
Steven data-source key= conPool
 
Steven set-property  property  = autoCommit
Steven value = false/
Steven set-property  property  = description
Steven value = database source/
Steven set-property  property  = driverClass
Steven value =
Steven oracle.jdbc.driver.OracleDriver/
Steven set-property  property  = user
Steven value = theuser/
Steven set-property  property  = password
Steven value = thepassword/
Steven set-property  property  = url
Steven value =
Steven jdbc:oracle:thin:@192.192.192.192:1675:inst/
Steven /data-source
 
Steven /data-sources
 
Steven In the section of code used for initialization of the
Steven datasource there is the following:
 
Steven ServletContext context =
Steven actSrv.getServletContext();
Steven dsSrc= ( DataSource ) context.getAttribute(
Steven ConPool );
 
Steven The context is captured but the datasource remains null.
 
 Are you using modules?  The data-source is put into the ServletContext
David with a
 key that is constructed by appending the module prefix to the given key.


-- 
===
David M. Karr  ; Java/J2EE/XML/Unix/C++
[EMAIL PROTECTED]   ; SCJP



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




conPool -- ConPool / Re: datasource problem

2003-01-01 Thread Liu Jian
Will the data-source key case-sensitive? conPool -- ConPool

Try

dsSrc= ( DataSource ) context.getAttribute( conPool );

Good luck !



- Original Message -
From: Steven Dahlin [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, January 01, 2003 3:42 PM
Subject: datasource problem


When I try to get a datasource which has been defined in the
struts-config.xml no matter what I do the datasource returns back null.  My
struts-config.xml for data-sources is:

data-sources

data-source key= conPool

set-property  property  = autoCommit
   value = false/
set-property  property  = description
   value = database source/
set-property  property  = driverClass
   value = oracle.jdbc.driver.OracleDriver/
set-property  property  = user
   value = theuser/
set-property  property  = password
   value = thepassword/
set-property  property  = url
   value =
jdbc:oracle:thin:@192.192.192.192:1675:inst/
 /data-source

  /data-sources

In the section of code used for initialization of the datasource there is
the following:

ServletContext context = actSrv.getServletContext();
dsSrc= ( DataSource ) context.getAttribute( ConPool );

The context is captured but the datasource remains null.

Any suggestions?

Thanks,
Steve





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: conPool -- ConPool / Re: datasource problem

2003-01-01 Thread Steven Dahlin
That was a misttype on my part.  In the code both have conPool.

- Original Message -
From: Liu Jian [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Wednesday, January 01, 2003 2:25 PM
Subject: conPool -- ConPool / Re: datasource problem


 Will the data-source key case-sensitive? conPool -- ConPool

 Try

 dsSrc= ( DataSource ) context.getAttribute( conPool );

 Good luck !



 - Original Message -
 From: Steven Dahlin [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, January 01, 2003 3:42 PM
 Subject: datasource problem


 When I try to get a datasource which has been defined in the
 struts-config.xml no matter what I do the datasource returns back null.
My
 struts-config.xml for data-sources is:

 data-sources

 data-source key= conPool

 set-property  property  = autoCommit
value = false/
 set-property  property  = description
value = database source/
 set-property  property  = driverClass
value = oracle.jdbc.driver.OracleDriver/
 set-property  property  = user
value = theuser/
 set-property  property  = password
value = thepassword/
 set-property  property  = url
value =
 jdbc:oracle:thin:@192.192.192.192:1675:inst/
  /data-source

   /data-sources

 In the section of code used for initialization of the datasource there is
 the following:

 ServletContext context = actSrv.getServletContext();
 dsSrc= ( DataSource ) context.getAttribute( ConPool );

 The context is captured but the datasource remains null.

 Any suggestions?

 Thanks,
 Steve





 --
 To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
mailto:[EMAIL PROTECTED]





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: datasource problem

2003-01-01 Thread David M. Karr
 Steven == Steven Dahlin [EMAIL PROTECTED] writes:

Steven When I try to get a datasource which has been defined in the 
struts-config.xml no matter what I do the datasource returns back null.  My 
struts-config.xml for data-sources is:
Steven data-sources

Steven data-source key= conPool

Steven set-property  property  = autoCommit
Stevenvalue = false/
Steven set-property  property  = description
Stevenvalue = database source/
Steven set-property  property  = driverClass
Stevenvalue = oracle.jdbc.driver.OracleDriver/
Steven set-property  property  = user
Stevenvalue = theuser/
Steven set-property  property  = password
Stevenvalue = thepassword/
Steven set-property  property  = url
Stevenvalue = 
jdbc:oracle:thin:@192.192.192.192:1675:inst/
Steven  /data-source

Steven   /data-sources

Steven In the section of code used for initialization of the datasource there is 
the following:

Steven ServletContext context = actSrv.getServletContext();
Steven dsSrc= ( DataSource ) context.getAttribute( ConPool );

Steven The context is captured but the datasource remains null.

Are you using modules?  The data-source is put into the ServletContext with a
key that is constructed by appending the module prefix to the given key.

-- 
===
David M. Karr  ; Java/J2EE/XML/Unix/C++
[EMAIL PROTECTED]   ; SCJP



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: datasource problem

2003-01-01 Thread Steven Dahlin
I am a little unclear what you mean by using modules?

Steve

- Original Message -
From: David M. Karr [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, January 01, 2003 3:45 PM
Subject: Re: datasource problem


  Steven == Steven Dahlin [EMAIL PROTECTED] writes:

 Steven When I try to get a datasource which has been defined in the
struts-config.xml no matter what I do the datasource returns back null.  My
struts-config.xml for data-sources is:
 Steven data-sources

 Steven data-source key= conPool

 Steven set-property  property  = autoCommit
 Stevenvalue = false/
 Steven set-property  property  = description
 Stevenvalue = database source/
 Steven set-property  property  = driverClass
 Stevenvalue =
oracle.jdbc.driver.OracleDriver/
 Steven set-property  property  = user
 Stevenvalue = theuser/
 Steven set-property  property  = password
 Stevenvalue = thepassword/
 Steven set-property  property  = url
 Stevenvalue =
jdbc:oracle:thin:@192.192.192.192:1675:inst/
 Steven  /data-source

 Steven   /data-sources

 Steven In the section of code used for initialization of the
datasource there is the following:

 Steven ServletContext context =
actSrv.getServletContext();
 Steven dsSrc= ( DataSource ) context.getAttribute(
ConPool );

 Steven The context is captured but the datasource remains null.

 Are you using modules?  The data-source is put into the ServletContext
with a
 key that is constructed by appending the module prefix to the given key.

 --
 ===
 David M. Karr  ; Java/J2EE/XML/Unix/C++
 [EMAIL PROTECTED]   ; SCJP



 --
 To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
mailto:[EMAIL PROTECTED]





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: DataSource problem

2002-06-14 Thread rainer juenger

Hi Maarten,

join the club! There are some more guys having exactliy the same problem as
you.
To me your configuration looks all right. I saw some samples :

parameter  namedriverName/name
valuejdbc:mysql://localhost/test/value /parameter

where the parameter name is not driverName but url. I tried both without
luck.

Are you using Tomcat 4.x without DBCP from the Jakarta Commons to get the
JNDI DB Connection?

Please follow the thread Connection pooling dowsn't work for me ... Help
!!
Hopefully there is someone arround giving us a tip how to get it run

Good luck to all of us ;)
Rainer

- Original Message -
From: Maarten Roosendaal [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, June 14, 2002 3:42 PM
Subject: DataSource problem


Hi,

I'm trying to create a simple DataBase app. using Struts. Right now i have a
problem with getting the DataSource out of the InitialContext and i'm not
sure what i'm doing wrong or maybe it has something to do with the Struts
Servlet.

In configured the server.xml as follows:
 Resource name=test auth=CONTAINER
  type=javax.sql.DataSource/

 ResourceParams name=test
   parameter  nameuser/name
valueroot/value  /parameter
   parameter  namepassword/namevalue/value
/parameter
   parameter  namedriverClassName/name
valueorg.gjt.mm.mysql.Driver/value /parameter
   parameter  namedriverName/name
valuejdbc:mysql://localhost/test/value /parameter
  /ResourceParams

and my web.xml includes the following:
resource-ref
res-ref-nametest/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authCONTAINER/res-auth
/resource-ref

In an Action-class i do this:
Context env = (Context) new
InitialContext().lookup(java:comp/env);
DataSource ds = (DataSource) env.lookup(test);
Here the DataSource keeps ending up as NULL. When i do this:
Connection con = DriverManager.getConnection(Commands.DB_TEST_URL,
Commands.DB_TEST_USERNAME, );
things are working fine but i have no idea where to look. The Context
does seem to have a reference to the 'test' reference but nothing more.
Does this have something to do with Struts or did i forget something? I
don't want to use the struts.xml for a database-connection. One of the
reasons is that i keep getting the message that it can't find the driver,
while it is included in the CLASSPATH.

Hope someone can help,
Maarten




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]