Issue with maven snapshot repository and NullPointerException

353 views
Skip to first unread message

Mariska

unread,
Mar 2, 2021, 8:45:03 AM3/2/21
to Nexus Users
Hi,
In the period May 2020 until Sep 2021 (NXRM releases: 3.24.0-02 and 3.27.0-03) the cleaning tasks of our maven snapshot repository didn't run well. I've got two tasks configured:
- Maven - Delete unused SNAPSHOT, which should clean all snapshots not used in 7 days.
- Maven - Delete SNAPSHOT, Minimum snapshot count = 1, Snapshot retention days = 7, grace period = 1

In this particular snapshot repository, there are a lot of empty snapshot versions with only metadata inside all created within above period, and thus partially cleaned. The artifacts (except the maven-metadata) are cleaned, the "<VERSION>-SNAPSHOT" folder with the metadata is still there. Due to the amount of these folders, it is not possible to remove these manually (several thousands or more), so I'm searching for a way to automate this via a groovy script, which is quite a struggle to get the query builder correct.

However, upon searching for a solution, I found one SNAPSHOT folder that doesn't contain any artifacts (so no metadata as well) and I'm also unable to delete this empty folder via the UI. When I start HTML View and browse to this component, I also get a NullPointerException:

2021-03-02 13:37:14,139+0100 WARN  [qtp2002264051-222]  MariskaHoogenboom org.sonatype.nexus.siesta.internal.UnexpectedExceptionMapper - (ID c795ec78-064b-4c50-a888-183ee81dc287) Unexpected exception: java.lang.NullPo
interException
java.lang.NullPointerException: null
       at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:878)
       at org.sonatype.nexus.repository.storage.StorageTxImpl.findAsset(StorageTxImpl.java:362)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.sonatype.nexus.common.stateguard.SimpleMethodInvocation.proceed(SimpleMethodInvocation.java:53)
       at org.sonatype.nexus.common.stateguard.MethodInvocationAction.run(MethodInvocationAction.java:39)
       at org.sonatype.nexus.common.stateguard.StateGuard$GuardImpl.run(StateGuard.java:272)
       at org.sonatype.nexus.common.stateguard.GuardedInterceptor.invoke(GuardedInterceptor.java:54)
       at org.sonatype.nexus.common.stateguard.StateGuardAspect$1.invoke(StateGuardAspect.java:63)
       at com.sun.proxy.$Proxy218.findAsset(Unknown Source)
interException
java.lang.NullPointerException: null
       at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:878)

Restarting Nexus didn't solve the NullPointerException and the empty folder is still there. Hope someone can help me fix this and maybe have some idea's how to automate the removal of the empty snapshot folders, only containing metadata. I'm on my way by using a query builder to find out if the maven-metadata.xml has any other snapshot versions, but still unable to get the components, the query builder only returns components when the version is equal to the exact snapshot version, I can't get it to use the wildcard:

    static Query findComponentsFromAssetParentQuery(String assetName) {
       // special action to cleanup leftovers/empty maven-metadata snapshot versions
       def groupIdList = assetName.tokenize('/')
       String version = ''
       String name = ''
       String parentGroup = ''
       if (groupIdList.size() > 2) {
           name = groupIdList.pop()
           //if (name != 'maven-metadata.xml') return null  
           version = groupIdList.pop()
           name = groupIdList.pop()
           parentGroup = groupIdList.join('.')
       }
       if (parentGroup == '') return null
                
       Query.Builder builder = Query.builder()
               .where('group = ')
               .param(parentGroup)
               .and('name =')
               .param(name)
               .and('version MATCHES ')
               .param(version.minus("-SNAPSHOT")+'*')
                        
       return builder.build()
Example of a builder:

asset : nl/ccv/cctp/acceptance-agreement-export.version/106932-SNAPSHOT/maven-metadata.xml.
Builder : group = :p0 AND name =:p1 AND version MATCHES :p2 [p0:nl.ccv.cctp, p1:acceptance-agreement-export.version, p2:106932*].
==> findComponents(builder, repo): [].
which is incorrect.

When I fix the version to "106932-20210206.012445-1" instead of the "106932*", I do get components. But that doesn't help me.

Any help or suggestions are appreciated.

Thanks, Mariska.

Matthew Piggott

unread,
Mar 2, 2021, 9:29:52 AM3/2/21
to Nexus Users, Mariska
For the empty folder it depends on whether its a folder or a component. If its an empty folder you could try rebuilding the browse tree.

The NPE appears to be a null asset id but the stack trace is incomplete so I can't offer suggestions.

Mariska

unread,
Mar 2, 2021, 9:36:41 AM3/2/21
to Nexus Users, Matthew Piggott, Mariska
2021-03-02 13:37:14,139+0100 WARN  [qtp2002264051-222]  MariskaHoogenboom org.sonatype.nexus.siesta.internal.UnexpectedExceptionMapper - (ID c795ec78-064b-4c50-a888-183ee81dc287) Unexpected exception: java.lang.NullPo
interException
java.lang.NullPointerException: null
       at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:878)
       at org.sonatype.nexus.repository.storage.StorageTxImpl.findAsset(StorageTxImpl.java:362)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.sonatype.nexus.common.stateguard.SimpleMethodInvocation.proceed(SimpleMethodInvocation.java:53)
       at org.sonatype.nexus.common.stateguard.MethodInvocationAction.run(MethodInvocationAction.java:39)
       at org.sonatype.nexus.common.stateguard.StateGuard$GuardImpl.run(StateGuard.java:272)
       at org.sonatype.nexus.common.stateguard.GuardedInterceptor.invoke(GuardedInterceptor.java:54)
       at org.sonatype.nexus.common.stateguard.StateGuardAspect$1.invoke(StateGuardAspect.java:63)
       at com.sun.proxy.$Proxy218.findAsset(Unknown Source)
       at org.sonatype.nexus.repository.browse.internal.orient.OrientBrowseNodeStore.lambda$17(OrientBrowseNodeStore.java:418)
       at org.sonatype.nexus.transaction.OperationPoint.proceed(OperationPoint.java:64)
       at org.sonatype.nexus.transaction.TransactionalWrapper.proceedWithTransaction(TransactionalWrapper.java:57)
       at org.sonatype.nexus.transaction.Operations.proceedWithTransaction(Operations.java:232)
       at org.sonatype.nexus.transaction.Operations.transactional(Operations.java:223)
       at org.sonatype.nexus.transaction.Operations.call(Operations.java:166)
       at org.sonatype.nexus.repository.browse.internal.orient.OrientBrowseNodeStore.getAssetById(OrientBrowseNodeStore.java:416)
       at org.sonatype.nexus.repository.browse.internal.orient.OrientBrowseNodeStore.toListItems(OrientBrowseNodeStore.java:384)
       at org.sonatype.nexus.repository.rest.internal.resources.RepositoryBrowseResource.getHtml(RepositoryBrowseResource.java:132)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:138)
       at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:543)
       at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:432)
       at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:393)
       at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
       at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:395)
       at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:364)
       at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:337)
       at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440)
       at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229)
       at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135)
       at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
       at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138)
       at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215)
       at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:245)
       at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:61)
       at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
       at org.sonatype.nexus.siesta.internal.resteasy.ComponentContainerImpl.service(ComponentContainerImpl.java:111)
       at org.sonatype.nexus.siesta.SiestaServlet.service(SiestaServlet.java:137)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
       at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:290)
       at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:280)
       at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:184)
        at com.google.inject.servlet.DynamicServletPipeline.service(DynamicServletPipeline.java:71)
       at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:85)
       at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:112)
       at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
       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:450)
       at org.sonatype.nexus.security.SecurityFilter.executeChain(SecurityFilter.java:96)
       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:387)
       at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
       at org.sonatype.nexus.security.SecurityFilter.doFilterInternal(SecurityFilter.java:112)
       at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
       at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
       at com.sonatype.nexus.licensing.internal.LicensingRedirectFilter.doFilter(LicensingRedirectFilter.java:116)
       at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
       at com.codahale.metrics.servlet.AbstractInstrumentedFilter.doFilter(AbstractInstrumentedFilter.java:112)
       at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
       at org.sonatype.nexus.internal.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:79)
       at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
       at org.sonatype.nexus.internal.web.EnvironmentFilter.doFilter(EnvironmentFilter.java:101)
       at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
       at org.sonatype.nexus.internal.web.HeaderPatternFilter.doFilter(HeaderPatternFilter.java:98)
       at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
       at com.google.inject.servlet.DynamicFilterPipeline.dispatch(DynamicFilterPipeline.java:104)
       at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133)
       at org.sonatype.nexus.bootstrap.osgi.DelegatingFilter.doFilter(DelegatingFilter.java:73)
       at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:201)
       at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1609)
       at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:561)
       at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
       at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:602)
       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
       at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1612)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
       at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1434)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
       at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
       at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1582)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1349)
       at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
       at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:239)
       at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
       at org.eclipse.jetty.server.Server.handle(Server.java:516)
       at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
       at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)
       at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
       at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
       at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
       at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
       at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
       at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
       at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
       at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
       at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
       at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
       at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:773)
       at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:905)
       at java.lang.Thread.run(Thread.java:748)
2021-03-02 13:37:14,144+0100 WARN  [qtp2002264051-222]  MariskaHoogenboom org.sonatype.nexus.siesta.internal.UnexpectedExceptionMapper - (ID c795ec78-064b-4c50-a888-183ee81dc287) Response: [500] 'ERROR: (ID c795ec78-0
64b-4c50-a888-183ee81dc287) java.lang.NullPointerException'; mapped from: java.lang.NullPointerException

Mariska

unread,
Mar 2, 2021, 9:38:04 AM3/2/21
to Nexus Users, Mariska, Matthew Piggott

And I think it is a folder, the empty SNAPSHOT, but it doesn't contain any data nor metadata.

Mariska

unread,
Mar 2, 2021, 2:24:58 PM3/2/21
to Nexus Users, Mariska, Matthew Piggott
By rebuilding the browser tree the NullPointerException is solved and the empty folder is removed. Thanks for the suggestion.

Does someone has a solution how to make the builder with a wildcard to return all SNAPSHOT versions from version 1.2.3-SNAPSHOT

Builder : group = :p0 AND name =:p1 AND version MATCHES :p2 [p0:xxx.yyy.zzz, p1:aaaa, p2:1.2.3*].

With xxx.yyy.zzz the group, aaaa the name and 1.2.3-SNAPSHOT the snapshot version. Above doesn't work. I've tried with and without the wildcard, I've tried with "LIKE" instead of "MATCHES". No luck yet.

Matthew Piggott

unread,
Mar 2, 2021, 2:29:09 PM3/2/21
to Mariska, Nexus Users

Mariska

unread,
Mar 3, 2021, 2:40:09 AM3/3/21
to Nexus Users, Matthew Piggott, Nexus Users, Mariska
Ha, with "attributes.maven2.baseVersion" it works indeed! Thank you very much. Now I can proceed with the rest of the script.
Reply all
Reply to author
Forward
0 new messages