Well it can't be wired by Spring because a new one is created every time getBean is called since it is a prototype and not a singleton. (have I ever mentioned how much I HATE code that mixes logic and data?)

-I'm assuming you can't reproduce this reliably yet.
-Since this appears to be happening in production I'm thinking that turning up Spring's logging would be bad for both performance and log sizes. Thought it might be interesting to turn logging up to debug, set a breakpoint at in UserLayoutManagerFactory.getUserLayoutManager where getBean is called and capture what exactly spring is doing when that method is called.

You could also try removing @Autowired from DistributedLayoutManager and explicitly wire all of its dependencies in XML and see if that has any effect.

-Eric

On 3/1/12 10:10 AM, Drew Wills wrote:
I have a loose theory about this issue coming together...

  - The userLayoutManager bean is a prototype
  - It has several dependencies @Autowired
  - Most of them seem to be working fine, always
  - The one that isn't is portalEventFactory
  - Which has implementation class PortalEventFactoryImpl
- Which, (perhaps) unlike the working dependencies, is instantiated by @Service and <component-scan>
  - Which means it's not declared explicitly in context XML

Could it be that the app context is occasionally prepping the prototype _before_ scanning for beans declared by annotations? And for some reason not complaining about a dependency it can't find?

I also wonder if the fact that the userLayoutManager bean is fetched explicitly by BeanFactory.getBean (rather than wired by Spring) contributes to the issue.

drew



On 3/1/2012 8:43 AM, Drew Wills wrote:
We would get stack traces referring here...

https://github.com/Jasig/uPortal/blob/master/uportal-war/src/main/java/org/jasig/portal/layout/dlm/DistributedLayoutManager.java#L461


and here...

https://github.com/Jasig/uPortal/blob/master/uportal-war/src/main/java/org/jasig/portal/layout/dlm/DistributedLayoutManager.java#L464


drew

On 3/1/2012 8:31 AM, Eric Dalquist wrote:
Drew could you correlate your line 455 with a linenumber on github, ex:
https://github.com/Jasig/uPortal/blob/master/uportal-war/src/main/java/org/jasig/portal/layout/dlm/DistributedLayoutManager.java#L455



-Eric

On 2/29/12 3:48 PM, Drew Wills wrote:
Hey folks,

I just encountered some behavior in a running instance of uPortal 4
that I can't explain -- is there someone who can help me understand
how this is possible? also maybe how to prevent it in the future?

User-facing behavior...

- User clicks on something to personalize the layout: add tab, remove
tab, add portlet, etc.
- Nothing happens in the browser, but the requested change is there
when the portal page is refreshed
- Using a tool like firebug, we can see that the ajax call to
/uPortal/api/layout is coming back with an HTTP 400 (bad request) or
500 (internal error) -- which one you get depends on which operation
you invoke
- So that explains the initial behavior in the browser: the change
isn't applied by JavaScript because the jQuery success function is
never called
- Looking in the logs we discover an NPE in DistributedLayoutManager
(pasted at bottom)
- Looking at the code, this error explains the server-side behavior:
the issue that caused the HTTP 400/500 happened *after* the layout
change was applied, so the user sees the change when he refreshes the
page
- The line that caused the error is this one...

this.portalEventFactory.publishFolderAddedToLayoutPortalEvent(this,
this.owner, layoutId, node.getId());

- The portalEventFactory member variable is null
- That member variable is wired to the layoutManager by Spring as
follows

@Autowired
public void setPortalEventFactory(IPortalEventFactory
portalEventFactory) {
this.portalEventFactory = portalEventFactory;
}

- The UpdatePreferencesServlet (after several nested methods) gets
it's reference to the layoutManager as follows

final IUserLayoutManager userLayoutManager =
(IUserLayoutManager)this.beanFactory.getBean(USER_LAYOUT_MANAGER_PROTOTYPE_BEAN_NAME,

person, profile);

So, I don't understand how the portalEventFactory could be null -- I
would think the app context would fail to come up at all.

This issue effected only 1 of 2 server nodes, and a restart cleared it
up.

Any thoughts?

drew


** STACK TRACE **

SEVERE: Servlet.service() for servlet MVCDispatcherServlet threw
exception
java.lang.NullPointerException
at
org.jasig.portal.layout.dlm.DistributedLayoutManager.addNode(DistributedLayoutManager.java:455)


at
org.jasig.portal.layout.TransientUserLayoutManagerWrapper.addNode(TransientUserLayoutManagerWrapper.java:158)


at
org.jasig.portal.layout.dlm.remoting.UpdatePreferencesServlet.addPortlet(UpdatePreferencesServlet.java:576)


at sun.reflect.GeneratedMethodAccessor544.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)


at
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)


at
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)


at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)


at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)


at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)


at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)


at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)


at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)


at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)


at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)


at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)


at
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)


at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)


at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)


at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)


at
org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:58)


at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)


at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)


at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)


at
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)


at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)


at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)


at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:369)


at
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)


at
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:91)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter.doFilter(AbstractPreAuthenticatedProcessingFilter.java:89)


at
org.jasig.portal.spring.security.preauth.PortalPreAuthenticatedProcessingFilter.doFilter(PortalPreAuthenticatedProcessingFilter.java:106)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)


at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)


at
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:168)


at
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)


at
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)


at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)


at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)


at
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)


at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)


at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)


at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)


at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)


at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)


at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)


at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)


at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)


at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)


at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)


at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)


at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)





Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to