tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: NullPointerException on Struts Action
Date Fri, 18 Sep 2009 16:04:11 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Julio,

On 9/18/2009 9:44 AM, Julio César Chaves Fernández wrote:
> Hi, i've been having a strange behavior with some struts apps deployed on Oracle portal.

Given that this is Struts running on Oracle, why not ask your question
on the Struts list or ask someone at Oracle? This is a forum for Apache
Tomcat users. :(

> 09/09/17 16:10:19 java.lang.NullPointerException
> 09/09/17 16:10:19     at org.apache.struts.action.Action.getDataSource(Action.java:532)
> 09/09/17 16:10:19     at co.edu.icesi.notas.action.InicioAction.execute(InicioAction.java:46)

[snip]

Wow, you're using Action.getDataSource? Wasn't that deprecated like 5
years ago?

> InicioAction is the init action that sets some data in the user
> session and makes some validations. The code in Action.java at line 532 is:
> 
> protected DataSource getDataSource(HttpServletRequest request, String key)
>   {
>     ServletContext context = getServlet().getServletContext();  ------------------------->
line 532
>     ModuleConfig moduleConfig = RequestUtils.getModuleConfig(request, context);
> 
>     return ((DataSource)context.getAttribute(key + moduleConfig.getPrefix()));
>   }

Are you sure you're looking at the right version of the code?

Are you doing something silly like trying to use this Action before it
has been properly brought into service? If that's the case, then
getServlet() would return null.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqzr3sACgkQ9CaO5/Lv0PA5UACdG+1Bhn2dhBuIHqF0E/gIKCWJ
lxYAnjcN1rTlDXhEcf3+F1x0f3xiTqBV
=PB58
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message