Hi, For background info... I'm running 5.3.7 tapestry release. I'm trying to get a handle to a SSO from inside a service class... (warning...code failure ensues.)
I have an SSO "Visit" here's the SSO's "injection" from my service class "UserServiceImpl"... private Visit getVisit() { Request request = this.request; assert(request!=null); // boolean visitExists = applicationStateManager.exists(Visit.class); Visit visit = applicationStateManager.getIfExists(Visit.class); return visit; } This works fine in the context of runtime in a servlet container. My problem is with my service layer Unit tests. When I'm testing my UserService the services getVisit() method is being exercised. and then when invoking in that method... this next line of code causes the request related NPE (see below)... applicationStateManager.getIfExists(Visit.class); ...java.lang.NullPointerException: Unable to delegate method invocation to property 'request' of <Proxy for RequestGlobals(org.apache.tapestry5.services.RequestGlobals)>, because the property is null. As you can see the assert in my method proves the Request exits . it's the SSO handling in ApplicationStateManager's getIfExists, exist, & get SSO methods that is kicking off (included below) exceptions in Unit test only. It makes sense to me that with my testing app context for service layer might (maybe should) not include a proper Request. But just prior to failure i have an assert that checks the Request is not null. my assertion seems to indicate the existence of a proper Request. ?? (or maybe it's just a whacked-out proxy?) I've thought about it a bit, poked around and found no useful links searching the interwebs. Am I doing something I'm not supposed to do? Any advice/insight appreciated. thanks Jon ========================================= java.lang.NullPointerException: Unable to delegate method invocation to property 'request' of <Proxy for RequestGlobals(org.apache.tapestry5.services.RequestGlobals)>, because the property is null. at $Request_130b64ff5f4b56f0.readProperty(Unknown Source) at $Request_130b64ff5f4b56f0.getSession(Unknown Source) at $Request_130b64ff5f4b56e1.getSession(Unknown Source) at org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.exists(SessionApplicationStatePersistenceStrategy.java:80) at $ApplicationStatePersistenceStrategy_130b64ff5f4b56ef.exists(Unknown Source) at org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$ApplicationStateAdapter.exists(ApplicationStateManagerImpl.java:60) at org.apache.tapestry5.internal.services.ApplicationStateManagerImpl.getIfExists(ApplicationStateManagerImpl.java:140) at $ApplicationStateManager_130b64ff5f4b56e2.getIfExists(Unknown Source) at info.ncapsuld.services.domain.UserServiceImpl.getVisit(UserServiceImpl.java:82) at info.ncapsuld.services.domain.UserServiceImpl.save(UserServiceImpl.java:46) at $UserService_130b64ff5f4b56d5.save(Unknown Source) at $UserService_130b64ff5f4b56d7.advised$save_130b64ff5f4b56dd(Unknown Source) at $UserService_130b64ff5f4b56d7$Invocation_save_130b64ff5f4b56dc.proceedToAdvisedMethod(Unknown Source) at org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:84) at org.apache.tapestry5.ioc.internal.util.InternalUtils$21$1.proceed(InternalUtils.java:1386) at org.apache.tapestry5.internal.hibernate.HibernateTransactionAdvisorImpl$1.advise(HibernateTransactionAdvisorImpl.java:40) at org.apache.tapestry5.ioc.internal.util.InternalUtils$21.advise(InternalUtils.java:1455) at org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:86) at $UserService_130b64ff5f4b56d7.save(Unknown Source) at $UserService_130b64ff5f4b56d3.save(Unknown Source) at info.ncapsuld.services.UserServiceTest.createInstance(UserServiceTest.java:34) at info.ncapsuld.services.UserServiceTest.testCreateSaveRetrieveUser(UserServiceTest.java:45) ===========================