java.util.NoSuchElementException: Iterator depleted

Sonatype JIRA | Benjamin Bentmann | 1 month ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafafviola and rp . Or join the community to write better ones.
  1. 0

    https://github.com/sonatype/nexus-internal/blob/c341bcc9311c122cc17d51df0abb30920b2fe33f/components/nexus-repository/src/main/java/org/sonatype/nexus/repository/storage/OrientAsyncHelper.java#L184 The {{queue.poll()}} invocation there yields no exception but {{null}} when the timeout elapses. This causes the following issues: # {{hasNext()}} returning {{true}} when in reality no element is available # {{next()}} returning a non-deterministic number of {{null}} elements tripping up processing of the query results, e.g. {noformat} 2017-01-10 15:09:20,084+0100 ERROR [qtp172586730-295] admin org.sonatype.nexus.extdirect.internal.ExtDirectServlet - Failed to invoke action method: coreui_Component.read, java-method: org.sonatype.nexus.coreui.ComponentComponent.read java.lang.IllegalArgumentException: expected one element but was: <null, null, null, null, null, ...> at com.google.common.collect.Iterators.getOnlyElement(Iterators.java:322) [com.google.guava:20.0.0] at com.google.common.collect.Iterables.getOnlyElement(Iterables.java:294) [com.google.guava:20.0.0] at org.sonatype.nexus.repository.browse.internal.BrowseServiceImpl.getCount(BrowseServiceImpl.java:192) [na:na] at org.sonatype.nexus.repository.browse.internal.BrowseServiceImpl.browseComponents(BrowseServiceImpl.java:95) [na:na] at org.sonatype.nexus.repository.browse.BrowseService$browseComponents.call(Unknown Source) [na:na] at org.sonatype.nexus.coreui.ComponentComponent.read(ComponentComponent.groovy:126) [na:na] {noformat} # {{next()}} failing with {{NoSuchElementException}} although the caller previously checked {{hasNext() == true}} ({{next()}} calls {{hasNext()}} again and can observe a different value than the caller, like the end-of-query sentinel), e.g. {noformat} Suppressed: java.util.NoSuchElementException: Iterator depleted at org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next(OrientAsyncHelper.java:202) [na:na] at org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next(OrientAsyncHelper.java:1) [na:na] at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47) [com.google.guava:20.0.0] at org.sonatype.nexus.repository.maven.internal.PurgeUnusedSnapshotsFacetImpl.deleteUnusedSnapshotComponents(PurgeUnusedSnapshotsFacetImpl.java:165) [na:na] {noformat}

    Sonatype JIRA | 1 month ago | Benjamin Bentmann
    java.util.NoSuchElementException: Iterator depleted
  2. 0
    samebug tip
    Try looking for variables that have been declared but not created as an object on the functions described in the stack trace.
  3. 0
    samebug tip
    Upgrade your old nexus to 2.14.1-01
    via Sonatype JIRA by Marc Lévi
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    We are getting the following exception trying to create Maven2 proxy repositories that point to our Nexus 2 hosted repositories. We've confirmed that the Content Type header is set to application/x-gzip for the file /nexus/content/repositories/thirdparty/.index/nexus-maven-repository-index.gz, so I'm not sure why Nexus is is trying to detect the Content Type and not just using the HTTP header. org.sonatype.nexus.repository.InvalidContentException: Detected content type [text/plain], but expected [application/x-gzip, application/gzip, application/x-tgz, application/gzip-compressed, application/gzipped, application/x-gunzip, application/x-gzip-compressed, gzip/document]: .index/nexus-maven-repository-index.gz at org.sonatype.nexus.repository.storage.DefaultContentValidator.determineContentType(DefaultContentValidator.java:95) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenContentValidator.determineContentType(MavenContentValidator.java:79) [na:na] at org.sonatype.nexus.repository.storage.StorageTxImpl.determineContentType(StorageTxImpl.java:717) [na:na] at org.sonatype.nexus.repository.storage.StorageTxImpl.createBlob(StorageTxImpl.java:544) [na:na] at sun.reflect.GeneratedMethodAccessor260.invoke(Unknown Source) [na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [na:1.8.0_77] at java.lang.reflect.Method.invoke(Method.java:498) [na:1.8.0_77] at org.sonatype.nexus.common.stateguard.SimpleMethodInvocation.proceed(SimpleMethodInvocation.java:53) [na:na] at org.sonatype.nexus.common.stateguard.MethodInvocationAction.run(MethodInvocationAction.java:39) [na:na] at org.sonatype.nexus.common.stateguard.StateGuard$GuardImpl.run(StateGuard.java:270) [na:na] at org.sonatype.nexus.common.stateguard.GuardedInterceptor.invoke(GuardedInterceptor.java:53) [na:na] at org.sonatype.nexus.common.stateguard.StateGuardAspect$1.invoke(StateGuardAspect.java:63) [na:na] at com.sun.proxy.$Proxy162.createBlob(Unknown Source) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenFacetImpl.doPut(MavenFacetImpl.java:224) [na:na] at org.sonatype.nexus.transaction.TransactionalWrapper.proceedWithTransaction(TransactionalWrapper.java:54) [org.sonatype.nexus.transaction:3.0.0.03] at org.sonatype.nexus.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:53) [org.sonatype.nexus.transaction:3.0.0.03] at org.sonatype.nexus.repository.maven.internal.MavenFacetImpl.put(MavenFacetImpl.java:200) [na:na] at org.sonatype.nexus.repository.maven.internal.proxy.MavenProxyFacet.store(MavenProxyFacet.java:90) [na:na] at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.get(ProxyFacetSupport.java:166) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenIndexPublisher.prefetch(MavenIndexPublisher.java:244) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenIndexPublisher.prefetchIndexFiles(MavenIndexPublisher.java:151) [na:na] at org.sonatype.nexus.repository.maven.internal.proxy.MavenProxyIndexFacet.publishIndex(MavenProxyIndexFacet.java:80) [na:na] at org.sonatype.nexus.repository.maven.tasks.PublishMavenIndexTask.execute(PublishMavenIndexTask.java:39) [na:na] at org.sonatype.nexus.repository.RepositoryTaskSupport.execute(RepositoryTaskSupport.java:56) [na:na] at org.sonatype.nexus.scheduling.TaskSupport.call(TaskSupport.java:89) [org.sonatype.nexus.scheduling:3.0.0.03] at org.sonatype.nexus.quartz.internal.task.QuartzTaskJob.doExecute(QuartzTaskJob.java:141) [org.sonatype.nexus.quartz:3.0.0.03] at org.sonatype.nexus.quartz.internal.task.QuartzTaskJob.execute(QuartzTaskJob.java:103) [org.sonatype.nexus.quartz:3.0.0.03] at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [org.quartz-scheduler.quartz:2.2.2] at org.sonatype.nexus.thread.internal.MDCAwareRunnable.run(MDCAwareRunnable.java:40) [org.sonatype.nexus.thread:3.0.0.03] at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) [org.apache.shiro.core:1.2.4] at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) [org.apache.shiro.core:1.2.4] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_77] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_77] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_77] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_77] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_77] 2016-04-18 20:49:20,319-0500 WARN [quartz-2-thread-10] *SYSTEM org.sonatype.nexus.quartz.internal.task.QuartzTaskJob - Task 4b273a19-b582-4659-bc7c-f0c044b62492 : 'Publish Indexes' [repository.maven.publish-dotindex] execution failure org.sonatype.goodies.common.MultipleFailures$MultipleFailuresException: Failed to run task 'Publish Maven indexes of *'; 2 failures at org.sonatype.goodies.common.MultipleFailures.maybePropagate(MultipleFailures.java:95) [org.sonatype.goodies.common:2.1.0] at org.sonatype.nexus.repository.RepositoryTaskSupport.execute(RepositoryTaskSupport.java:64) [na:na] at org.sonatype.nexus.scheduling.TaskSupport.call(TaskSupport.java:89) [org.sonatype.nexus.scheduling:3.0.0.03] at org.sonatype.nexus.quartz.internal.task.QuartzTaskJob.doExecute(QuartzTaskJob.java:141) [org.sonatype.nexus.quartz:3.0.0.03] at org.sonatype.nexus.quartz.internal.task.QuartzTaskJob.execute(QuartzTaskJob.java:103) [org.sonatype.nexus.quartz:3.0.0.03] at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [org.quartz-scheduler.quartz:2.2.2] at org.sonatype.nexus.thread.internal.MDCAwareRunnable.run(MDCAwareRunnable.java:40) [org.sonatype.nexus.thread:3.0.0.03] at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) [org.apache.shiro.core:1.2.4] at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) [org.apache.shiro.core:1.2.4] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_77] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_77] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_77] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_77] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_77] Suppressed: org.sonatype.nexus.repository.InvalidContentException: Detected content type [text/plain], but expected [application/x-gzip, application/gzip, application/x-tgz, application/gzip-compressed, application/gzipped, application/x-gunzip, application/x-gzip-compressed, gzip/document]: .index/nexus-maven-repository-index.gz at org.sonatype.nexus.repository.storage.DefaultContentValidator.determineContentType(DefaultContentValidator.java:95) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenContentValidator.determineContentType(MavenContentValidator.java:79) [na:na] at org.sonatype.nexus.repository.storage.StorageTxImpl.determineContentType(StorageTxImpl.java:717) [na:na] at org.sonatype.nexus.repository.storage.StorageTxImpl.createBlob(StorageTxImpl.java:544) [na:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.8.0_77] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [na:1.8.0_77] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [na:1.8.0_77] at java.lang.reflect.Method.invoke(Method.java:498) [na:1.8.0_77] at org.sonatype.nexus.common.stateguard.SimpleMethodInvocation.proceed(SimpleMethodInvocation.java:53) [na:na] at org.sonatype.nexus.common.stateguard.MethodInvocationAction.run(MethodInvocationAction.java:39) [na:na] at org.sonatype.nexus.common.stateguard.StateGuard$GuardImpl.run(StateGuard.java:270) [na:na] at org.sonatype.nexus.common.stateguard.GuardedInterceptor.invoke(GuardedInterceptor.java:53) [na:na] at org.sonatype.nexus.common.stateguard.StateGuardAspect$1.invoke(StateGuardAspect.java:63) [na:na] at com.sun.proxy.$Proxy162.createBlob(Unknown Source) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenFacetImpl.doPut(MavenFacetImpl.java:224) [na:na] at org.sonatype.nexus.transaction.TransactionalWrapper.proceedWithTransaction(TransactionalWrapper.java:54) [org.sonatype.nexus.transaction:3.0.0.03] at org.sonatype.nexus.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:53) [org.sonatype.nexus.transaction:3.0.0.03] at org.sonatype.nexus.repository.maven.internal.MavenFacetImpl.put(MavenFacetImpl.java:200) [na:na] at org.sonatype.nexus.repository.maven.internal.proxy.MavenProxyFacet.store(MavenProxyFacet.java:90) [na:na] at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.get(ProxyFacetSupport.java:166) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenIndexPublisher.prefetch(MavenIndexPublisher.java:244) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenIndexPublisher.prefetchIndexFiles(MavenIndexPublisher.java:151) [na:na] at org.sonatype.nexus.repository.maven.internal.proxy.MavenProxyIndexFacet.publishIndex(MavenProxyIndexFacet.java:80) [na:na] at org.sonatype.nexus.repository.maven.tasks.PublishMavenIndexTask.execute(PublishMavenIndexTask.java:39) [na:na] at org.sonatype.nexus.repository.RepositoryTaskSupport.execute(RepositoryTaskSupport.java:56) [na:na] ... 12 common frames omitted Suppressed: org.sonatype.nexus.repository.InvalidContentException: Detected content type [text/plain], but expected [application/x-gzip, application/gzip, application/x-tgz, application/gzip-compressed, application/gzipped, application/x-gunzip, application/x-gzip-compressed, gzip/document]: .index/nexus-maven-repository-index.gz at org.sonatype.nexus.repository.storage.DefaultContentValidator.determineContentType(DefaultContentValidator.java:95) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenContentValidator.determineContentType(MavenContentValidator.java:79) [na:na] at org.sonatype.nexus.repository.storage.StorageTxImpl.determineContentType(StorageTxImpl.java:717) [na:na] at org.sonatype.nexus.repository.storage.StorageTxImpl.createBlob(StorageTxImpl.java:544) [na:na] at sun.reflect.GeneratedMethodAccessor260.invoke(Unknown Source) [na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [na:1.8.0_77] at java.lang.reflect.Method.invoke(Method.java:498) [na:1.8.0_77] at org.sonatype.nexus.common.stateguard.SimpleMethodInvocation.proceed(SimpleMethodInvocation.java:53) [na:na] at org.sonatype.nexus.common.stateguard.MethodInvocationAction.run(MethodInvocationAction.java:39) [na:na] at org.sonatype.nexus.common.stateguard.StateGuard$GuardImpl.run(StateGuard.java:270) [na:na] at org.sonatype.nexus.common.stateguard.GuardedInterceptor.invoke(GuardedInterceptor.java:53) [na:na] at org.sonatype.nexus.common.stateguard.StateGuardAspect$1.invoke(StateGuardAspect.java:63) [na:na] at com.sun.proxy.$Proxy162.createBlob(Unknown Source) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenFacetImpl.doPut(MavenFacetImpl.java:224) [na:na] at org.sonatype.nexus.transaction.TransactionalWrapper.proceedWithTransaction(TransactionalWrapper.java:54) [org.sonatype.nexus.transaction:3.0.0.03] at org.sonatype.nexus.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:53) [org.sonatype.nexus.transaction:3.0.0.03] at org.sonatype.nexus.repository.maven.internal.MavenFacetImpl.put(MavenFacetImpl.java:200) [na:na] at org.sonatype.nexus.repository.maven.internal.proxy.MavenProxyFacet.store(MavenProxyFacet.java:90) [na:na] at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.get(ProxyFacetSupport.java:166) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenIndexPublisher.prefetch(MavenIndexPublisher.java:244) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenIndexPublisher.prefetchIndexFiles(MavenIndexPublisher.java:151) [na:na] at org.sonatype.nexus.repository.maven.internal.proxy.MavenProxyIndexFacet.publishIndex(MavenProxyIndexFacet.java:80) [na:na] at org.sonatype.nexus.repository.maven.tasks.PublishMavenIndexTask.execute(PublishMavenIndexTask.java:39) [na:na] at org.sonatype.nexus.repository.RepositoryTaskSupport.execute(RepositoryTaskSupport.java:56) [na:na] ... 12 common frames omitted

    Sonatype JIRA | 10 months ago | Dan McLaughlin
    org.sonatype.nexus.repository.InvalidContentException: Detected content type [text/plain], but expected [application/x-gzip, application/gzip, application/x-tgz, application/gzip-compressed, application/gzipped, application/x-gunzip, application/x-gzip-compressed, gzip/document]: .index/nexus-maven-repository-index.gz
  6. 0

    If a user has read privileges to a npm group, but not the underlying npm proxy, then the "npm install <package>" will get a 500 response for any package that is not locally cached in the npm proxy. Steps to reproduce: 1) Setup a npm group _npm-all_ that has npm proxy _npmjs_ as a member 2) Setup a user that has access to group repo _npm-all_ (privilege nx-repository-view-npm-npm-all). 3) Try to install a npm package that is not locally cached in proxy _npmjs_ The npm install command will fail with something like the following: {noformat} npm http fetch GET http://localhost:8081/repository/npm-all/glob/-/glob-7.1.1.tgz npm http fetch 500 http://localhost:8081/repository/npm-all/glob/-/glob-7.1.1.tgz npm info retry will retry, error on last attempt: Error: server error 500 {noformat} Nexus logs will show the following: {noformat} 2016-12-21 11:21:38,899+0000 WARN [qtp1898010376-415] test org.sonatype.nexus.repository.httpbridge.internal.ViewServlet - Service failure java.lang.RuntimeException: java.io.IOException: org.apache.shiro.authz.AuthorizationException at com.google.common.base.Throwables.propagate(Throwables.java:160) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.getUrl(NpmProxyFacetImpl.java:142) [na:na] at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.fetch(ProxyFacetSupport.java:210) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.fetch(NpmProxyFacetImpl.java:62) [na:na] at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.get(ProxyFacetSupport.java:166) [na:na] at org.sonatype.nexus.repository.proxy.ProxyHandler.handle(ProxyHandler.java:49) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.storage.UnitOfWorkHandler.handle(UnitOfWorkHandler.java:39) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.Context$proceed.call(Unknown Source) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyRecipe$_closure1.doCall(NpmProxyRecipe.groovy:160) [na:na] ... ... Caused by: java.io.IOException: org.apache.shiro.authz.AuthorizationException at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.retrievePackageRoot(NpmProxyFacetImpl.java:347) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.retrievePackageVersion(NpmProxyFacetImpl.java:299) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.getUrl(NpmProxyFacetImpl.java:138) [na:na] ... 131 common frames omitted Caused by: org.apache.shiro.authz.AuthorizationException: null at org.sonatype.nexus.repository.security.SecurityFacetSupport.ensurePermitted(SecurityFacetSupport.java:72) [na:na] at org.sonatype.nexus.repository.security.SecurityHandler.handle(SecurityHandler.java:48) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.handlers.TimingHandler.handle(TimingHandler.java:46) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.Context.start(Context.java:114) [na:na] at org.sonatype.nexus.repository.view.Router.dispatch(Router.java:60) [na:na] at org.sonatype.nexus.repository.view.ConfigurableViewFacet.dispatch(ConfigurableViewFacet.java:52) [na:na] at org.sonatype.nexus.repository.view.ConfigurableViewFacet.dispatch(ConfigurableViewFacet.java:43) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.retrievePackageRoot(NpmProxyFacetImpl.java:336) [na:na] ... 133 common frames omitted {noformat} *Workaround* If you give that user a read privilege to the proxy _npmjs_ (nx-repository-view-npm-npmjs-read) then the user should be able to install the package that is not already cached. Group level permissions should be transitive, therefore use has the same privileges for all member repositories.

    Sonatype JIRA | 2 months ago | Mahendra Surani
    java.lang.RuntimeException: java.io.IOException: org.apache.shiro.authz.AuthorizationException

    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.util.NoSuchElementException

      Iterator depleted

      at org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next()
    2. org.sonatype.nexus
      OrientAsyncHelper$QueueConsumingIterable.next
      1. org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next(OrientAsyncHelper.java:202)[na:na]
      2. org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next(OrientAsyncHelper.java:1)[na:na]
      2 frames
    3. Guava
      TransformedIterator.next
      1. com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47)[com.google.guava:20.0.0]
      1 frame
    4. org.sonatype.nexus
      PurgeUnusedSnapshotsFacetImpl.deleteUnusedSnapshotComponents
      1. org.sonatype.nexus.repository.maven.internal.PurgeUnusedSnapshotsFacetImpl.deleteUnusedSnapshotComponents(PurgeUnusedSnapshotsFacetImpl.java:165)[na:na]
      1 frame