You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Inge Solvoll <in...@gmail.com> on 2009/08/31 08:58:48 UTC

Re: NPE when trying to contribute ServletContextSymbolProvider to SymbolSource (WAS: Re: Page pool hard limit and page instance usage)

Actually, it didn't work. Still getting the Alias recursion error when
injecting ServletContextProvider spring bean into my SymbolProvider. Isn't
that a bit strange?? Also, server startup success including my
SymbolProvider seems pretty random.

When I remove references to ServletContext through my Spring bean and use
MyClass.class.getResourceAsStream, it seems to work. But I can't be sure, it
seems to crash randomly so far...

On Fri, Aug 28, 2009 at 2:00 PM, Inge Solvoll <in...@gmail.com>wrote:

> That actually did the trick. Just create the simple spring bean listed
> below, and inject it instead of ApplicationGlobals into your SymbolSource.
>
> import javax.servlet.ServletContext;
>
> import org.springframework.web.context.ServletContextAware;
>
> public class ServletContextProvider implements ServletContextAware {
>
>   private ServletContext servletContext;
>
>
>   public ServletContext getServletContext() {
>     return servletContext;
>   }
>
>
>   public void setServletContext(ServletContext servletContext) {
>     this.servletContext = servletContext;
>
>   }
> }
>
>
> On Fri, Aug 28, 2009 at 1:45 PM, Inge Solvoll <in...@gmail.com>wrote:
>
>> This last post didn't help in my attempt at trying to use
>> ApplicationGlobals.getServletContext() in my SymbolSource implementation.
>> But could this help? I will try it out
>>
>> http://forum.springsource.org/showthread.php?t=39927
>>
>>
>> On Tue, Oct 7, 2008 at 4:54 PM, Francois Armand <fa...@linagora.com>wrote:
>>
>>> Ville Virtanen wrote:
>>>
>>>> I have no new info on this, and I think we should add ticket to get this
>>>> sorted. (If it is something we do wrong -> correct the documentation or
>>>> then
>>>> it is a bug that needs a fix anyway.)
>>>>
>>>>
>>> I search forward and find a solution that works for me, I hope it may
>>> help you too :
>>>
>>> http://markmail.org/search/?q=list%3Aorg.apache.tapestry.users+problem+injecting#query:list%3Aorg.apache.tapestry.usersproblem injecting+page:1+mid:lnvawscuxr44aasv+state:results
>>>
>>> So, basically, the problem is that the Tapestry Request and Response
>>> object are saved in RequestGlobal object only in the Terminator of the
>>> RequestHandler pipeline. But the ApplicationStateManager, and perhaps other
>>> services, tries to access to the (T5) Request thanks to
>>> RequestGlobal#getRequest(), which is null : we did not reach the terminator
>>> yet.
>>>
>>> So, I just created a RequestHandler that does the same thing that the
>>> terminator (requestGlobals.storeRequestResponse(request, response)) and
>>> contribute it before all other RequestHandler.
>>>
>>> I believe that we may have the same problem with HttpRequestHandler, as
>>> the RequestGlobal#storeServletRequestResponse is called in theterminator of
>>>  HttpRequestHandler pipeline.
>>>
>>> Hope it will help you.
>>>
>>> ============
>>> The code (copy&paste from the other email (save you a click) :
>>>
>>>  public static RequestFilter buildSetRequestResponse(final RequestGlobals
>>> requestGlobals) {
>>>      return new RequestFilter(){
>>>          public boolean service(Request request, Response response,
>>> RequestHandler handler) throws IOException {
>>>              requestGlobals.storeRequestResponse(request, response);
>>>              return handler.service(request, response);
>>>          }
>>>      };
>>>  }
>>>
>>>  public static void
>>> contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
>>>          @InjectService("setRequestResponse") RequestFilter
>>> setRequestResponse,
>>>         .... (other handlers)) {
>>>      configuration.add("setRequestResponse", setRequestResponse,
>>> "before:*");
>>>      ...
>>>
>>>  }
>>>
>>>
>>>
>>>
>>> --
>>> Francois Armand
>>> Etudes & Développements J2EE
>>> Groupe Linagora - http://www.linagora.com
>>> Tél.: +33 (0)1 58 18 68 28
>>> -----------
>>> InterLDAP - http://interldap.org FederID - http://www.federid.org/
>>> Open Source identities management and federation
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>