You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Steven Citron-Pousty <St...@yale.edu> on 2002/11/20 22:45:56 UTC

How to access the Struts ConnectionPool from an ActionForm

Greetings all:
I am trying to populate the options for a select list from a DB call. 
And I am getting a null pointer exception from this line in the 
ActionForm (I copied it from my Action, where it works):

DataSource dataSource = (DataSource) 
servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY);

What I am trying to do is use the ConnectionPool provided by Struts. 
This call works great in my Action but doesn't work in my ActionForm.
On the IRC channel (irc.freenode.net #struts) we have been discussing 
the merits of putting a DB call in an ActionForm.

SOoo, my main question is,
How do I ask the context for the connection pool in an ActionForm?

But I would also love to see discussion about the merits of putting a DB 
call in an ActionForm at all. If I didn't put the call in the ActionForm 
how would I get the data from the DB call into the actionForm?

Thanks in advance for all your help,
Steve

BTW it appears as if posting from the basebeans nntp doesn't get posted 
to the list.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Intermittent parsing error processing struts-config.xml

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Sat, 23 Nov 2002, Jagdish Arora wrote:

> Date: Sat, 23 Nov 2002 15:54:38 -0500
> From: Jagdish Arora <ja...@hotmail.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: Intermittent parsing error processing struts-config.xml
>
>
> Any known issues with Struts 1.1 Beta 2?  Any way to look at the Bugzilla
> logs generated against that?

http://nagoya.apache.org/bugzilla/

Just enter the query critera you want:

Status:  clear them all
Program:  Struts
Version:  1.1 beta 2

Note that a significant number of bugs in 1.1b2 have been fixed in
subsequent nightly builds already.

>
> thanks,
>
> jagdish.
>

Craig


> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Intermittent parsing error processing struts-config.xml

Posted by Jagdish Arora <ja...@hotmail.com>.
Any known issues with Struts 1.1 Beta 2?  Any way to look at the Bugzilla
logs generated against that?

thanks,

jagdish.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Intermittent parsing error processing struts-config.xml

Posted by Jagdish Arora <ja...@hotmail.com>.
Greetings all.

I am using Struts (v 1.1 Beta), with JBoss 3.0.0_tomcat4.0.3,  and unable to upgrade *exactly* at this point.

I intermittently get a parser exception 
javax.servlet.UnavailableException: Parsing error processing resource path /WEB-INF/struts-config.xml
	at org.apache.struts.action.ActionServlet.initApplicationConfig(ActionServlet.java:866)
	at org.apache.struts.action.ActionServlet.init(ActionServlet.java:455)
	at javax.servlet.GenericServlet.init(GenericServlet.java:258)
 
The problem usually goes away if I deploy again.
If the problem is a bug in Struts, or something outside my domain, its ok, I will wait for Dec 15 when we upgrade.  
Just want to check if there is a problem with my file/setting.

regards,
jagdish


Re: How to access the Struts ConnectionPool from an ActionForm

Posted by Steven Citron-Pousty <St...@yale.edu>.
I think thats kinda it. I think whats happening is that the jsp was 
being called before the webapp had ever "touched" the servlet (i.e. the 
user could go straight to the jsp). Therefore maybe the form doesn't 
know which servlet its talking to.
Is there a way to get the context attribute without asking the servlet?
Thanks,
Steve
Jagdish Arora wrote:

>Steven,
>
>Is your form defined to be in session scope, or is it in request scope?  The
>reason I ask is that the servlet is declared to be transient in the
>ActionForm.  Depending on where you are in the lifecycle, it may have
>"evaporated".
>
>
>amrinder
>
>----- Original Message -----
>From: "Steven Citron-Pousty" <St...@yale.edu>
>To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>Cc: "Jagdish Arora" <ja...@hotmail.com>
>Sent: Thursday, November 21, 2002 11:04 AM
>Subject: Re: How to access the Struts ConnectionPool from an ActionForm
>
>
>  
>
>>The servlet is null. So then how and what do I tell the actionform is
>>its servlet.
>>
>>Thanks,
>>Steve
>>
>>PS I still am interested in ppls view on whether all DB calls are model
>>or there is a case when you could consider the DB call view
>>
>>Jagdish Arora wrote:
>>    
>>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to access the Struts ConnectionPool from an ActionForm

Posted by Steven Citron-Pousty <St...@yale.edu>.
The servlet is null. So then how and what do I tell the actionform is 
its servlet.

Thanks,
Steve

PS I still am interested in ppls view on whether all DB calls are model 
or there is a case when you could consider the DB call view

Jagdish Arora wrote:

>Steven, since you are getting a NPE, could you tell us if is it the servlet
>that is null, or is servlet.getServletContext() that is null?
>
>amrinder
>
>----- Original Message -----
>From: "Steven Citron-Pousty" <St...@yale.edu>
>To: "struts-user" <st...@jakarta.apache.org>
>Subject: How to access the Struts ConnectionPool from an ActionForm
>
>
>  
>
>>DataSource dataSource = (DataSource)
>>servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY);
>>
>>    
>>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to access the Struts ConnectionPool from an ActionForm

Posted by Jagdish Arora <ja...@hotmail.com>.
Steven, since you are getting a NPE, could you tell us if is it the servlet
that is null, or is servlet.getServletContext() that is null?

amrinder

----- Original Message -----
From: "Steven Citron-Pousty" <St...@yale.edu>
To: "struts-user" <st...@jakarta.apache.org>
Subject: How to access the Struts ConnectionPool from an ActionForm


>
> DataSource dataSource = (DataSource)
> servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY);
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>