java.lang.NullPointerException

Sonatype JIRA | Peter Lynch | 3 years ago
  1. 0

    Configure Nexus 2.7 with a jetty.xml similar to this: {noformat} <?xml version="1.0"?> <!-- Sonatype Nexus (TM) Open Source Version Copyright (c) 2007-2013 Sonatype, Inc. All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the Eclipse Foundation. All other trademarks are the property of their respective owners. --> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> <!-- ============================================================ --> <!-- --> <!-- For help using this configuration, see: --> <!-- --> <!-- http://links.sonatype.com/products/nexus/oss/docs-jetty --> <!-- --> <!-- ============================================================ --> <Configure id="Server" class="org.eclipse.jetty.server.Server"> <Set name="threadPool"> <New class="com.yammer.metrics.jetty.InstrumentedQueuedThreadPool"/> </Set> <Call name="addConnector"> <Arg> <New class="org.sonatype.nexus.bootstrap.jetty.InstrumentedSslSelectChannelConnector"> <Arg> <New class="org.eclipse.jetty.util.ssl.SslContextFactory"> <Set name="keyStore">/home/rseddon/nexus-ssl/keystore</Set> <Set name="trustStore">/home/rseddon/nexus-ssl/keystore</Set> <Set name="keyStorePassword">foobar</Set> <Set name="keyManagerPassword">foobar</Set> <Set name="trustStorePassword">foobar</Set> </New> </Arg> <Set name="host">${application-host}</Set> <Set name="port">${application-port-ssl}</Set> <Set name="forwarded">true</Set> </New> </Arg> </Call> <New id="NexusHandler" class="com.yammer.metrics.jetty.InstrumentedHandler"> <Arg> <New id="NexusWebAppContext" class="org.eclipse.jetty.webapp.WebAppContext"> <Arg>${nexus-webapp}</Arg> <Arg>${nexus-webapp-context-path}</Arg> <Set name="extractWAR">false</Set> <Set name="throwUnavailableOnStartupException">true</Set> </New> </Arg> </New> <Set name="handler"> <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"> <Call name="addHandler"> <Arg> <Ref id="NexusHandler"/> </Arg> </Call> </New> </Set> <Set name="stopAtShutdown">true</Set> <Set name="sendServerVersion">true</Set> <Set name="sendDateHeader">true</Set> <Set name="gracefulShutdown">1000</Set> </Configure> {noformat} Now access https://localhost:8443/nexus/content/groups/public/. You get a NPE and 500 status. {noformat} HTTP ERROR 500Problem accessing /nexus/content/groups/public/. Reason: Server ErrorCaused by:java.lang.NullPointerException at java.util.Arrays$ArrayList.<init>(Arrays.java:2842) at java.util.Arrays.asList(Arrays.java:2828) at org.sonatype.nexus.web.content.NexusContentServlet.getResourceStoreRequest(NexusContentServlet.java:176) at org.sonatype.nexus.web.content.NexusContentServlet.doGet(NexusContentServlet.java:330) at javax.servlet.http.HttpServlet.service(HttpServlet.java:735) at org.sonatype.nexus.web.content.NexusContentServlet.service(NexusContentServlet.java:321) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:278) at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:268) at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:180) at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:93) at com.yammer.metrics.web.WebappMetricsFilter.doFilter(WebappMetricsFilter.java:76) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120) at org.sonatype.nexus.web.NexusGuiceFilter$MultiFilterChain.doFilter(NexusGuiceFilter.java:83) at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120) {noformat} The problem is the NexusContentServlet ( now ContentServlet in 2.8-SNAPSHOT ) expects that the request attribute "javax.servlet.request.X509Certificate" is populated if an incoming request is https. There is no guarantee this will be true. In fact the default is this is not the case. You would have to configure jetty SslContextFactory with needClientAuth(true) and be using SSL client certificates in order to make this work. Bad code: {code:java} if (request.isSecure()) { result.getRequestContext().put(AccessManager.REQUEST_CONFIDENTIAL, Boolean.TRUE); final List<X509Certificate> certs = Arrays.asList((X509Certificate[]) request .getAttribute("javax.servlet.request.X509Certificate")); // <==== NPE HERE if (certs != null && !certs.isEmpty()) { result.getRequestContext().put(AccessManager.REQUEST_CERTIFICATES, certs); } } {code}

    Sonatype JIRA | 3 years ago | Peter Lynch
    java.lang.NullPointerException
  2. 0

    empty list of recipients crashes Postman

    GitHub | 2 years ago | yegor256
    java.lang.NullPointerException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    OrientDB 2.0 - create index with COLLATE

    GitHub | 2 years ago | johndavids
    com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.CREATE INDEX Class.name on Class (name COLLATE CI) NOTUNIQUE_HASH_INDEX

  1. bluebunnty 4 times, last 2 weeks ago
  2. serious2monkeys 6 times, last 3 months ago
  3. mukky 2 times, last 4 months ago
  4. emmanuelstroem 95 times, last 6 months ago
  5. sriharshakiran 1 times, last 7 months ago
9 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.NullPointerException

    No message provided

    at java.util.Arrays$ArrayList.<init>()
  2. Java RT
    Arrays.asList
    1. java.util.Arrays$ArrayList.<init>(Arrays.java:2842)
    2. java.util.Arrays.asList(Arrays.java:2828)
    2 frames
  3. org.sonatype.nexus
    NexusContentServlet.doGet
    1. org.sonatype.nexus.web.content.NexusContentServlet.getResourceStoreRequest(NexusContentServlet.java:176)
    2. org.sonatype.nexus.web.content.NexusContentServlet.doGet(NexusContentServlet.java:330)
    2 frames
  4. JavaServlet
    HttpServlet.service
    1. javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
    1 frame
  5. org.sonatype.nexus
    NexusContentServlet.service
    1. org.sonatype.nexus.web.content.NexusContentServlet.service(NexusContentServlet.java:321)
    1 frame
  6. JavaServlet
    HttpServlet.service
    1. javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    1 frame
  7. Guice - Servlet
    ManagedServletPipeline.service
    1. com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:278)
    2. com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:268)
    3. com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:180)
    4. com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:93)
    4 frames
  8. com.yammer.metrics
    WebappMetricsFilter.doFilter
    1. com.yammer.metrics.web.WebappMetricsFilter.doFilter(WebappMetricsFilter.java:76)
    1 frame
  9. Shiro
    OncePerRequestFilter.doFilter
    1. org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
    2. org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
    3. org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
    4. org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    5. org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
    6. org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
    7. org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
    8. org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    9. org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
    10. org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
    11. org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
    12. org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    13. org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
    14. org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
    15. org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
    16. org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
    17. org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
    18. org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
    19. org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
    20. org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    20 frames
  10. Guice - Servlet
    ManagedFilterPipeline.dispatch
    1. com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120)
    1 frame
  11. ${project.groupId}:${project.artifactId}
    NexusGuiceFilter$MultiFilterChain.doFilter
    1. org.sonatype.nexus.web.NexusGuiceFilter$MultiFilterChain.doFilter(NexusGuiceFilter.java:83)
    1 frame
  12. Guice - Servlet
    ManagedFilterPipeline.dispatch
    1. com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120)
    1 frame