Redox
Redox

Reputation: 993

Jenkins String index out of range: -1

Updated Jenkins to latest version, updated all plugins and now get an String index out of range: -1 error (full log below).

When I change authorizationStrategy from hudson.security.ProjectMatrixAuthorizationStrategy to hudson.security.FullControlOnceLoggedInAuthorizationStrategy the error is gone. I can login, basically do everything we normally do. But when we change it back, the error is there.

Anybody any clue what to do to fix this? Or where to start debugging?

Error log:

    at java.lang.String.substring(String.java:1967)
    at org.jenkinsci.plugins.matrixauth.AuthorizationContainer.add(AuthorizationContainer.java:76)
    at org.jenkinsci.plugins.matrixauth.AbstractAuthorizationContainerConverter.unmarshalContainer(AbstractAuthorizationContainerConverter.java:82)
    at org.jenkinsci.plugins.matrixauth.AbstractAuthorizationContainerConverter.unmarshal(AbstractAuthorizationContainerConverter.java:94)
    at hudson.util.XStream2$AssociatedConverterImpl.unmarshal(XStream2.java:464)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
Caused: com.thoughtworks.xstream.converters.ConversionException: String index out of range: -1 : String index out of range: -1
---- Debugging information ----
message             : String index out of range: -1
cause-exception     : java.lang.StringIndexOutOfBoundsException
cause-message       : String index out of range: -1
class               : hudson.security.ProjectMatrixAuthorizationStrategy
required-type       : hudson.security.ProjectMatrixAuthorizationStrategy
converter-type      : hudson.util.XStream2$AssociatedConverterImpl
path                : /hudson/authorizationStrategy/denyAnonymousReadAccess
line number         : 14
-------------------------------
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at hudson.util.RobustReflectionConverter.unmarshalField(RobustReflectionConverter.java:391)
    at hudson.util.RobustReflectionConverter.doUnmarshal(RobustReflectionConverter.java:329)
Caused: jenkins.util.xstream.CriticalXStreamException: String index out of range: -1 : String index out of range: -1
---- Debugging information ----
message             : String index out of range: -1
cause-exception     : java.lang.StringIndexOutOfBoundsException
cause-message       : String index out of range: -1
class               : hudson.security.ProjectMatrixAuthorizationStrategy
required-type       : hudson.security.ProjectMatrixAuthorizationStrategy
converter-type      : hudson.util.XStream2$AssociatedConverterImpl
path                : /hudson/authorizationStrategy/denyAnonymousReadAccess
line number         : 14
------------------------------- : String index out of range: -1 : String index out of range: -1
---- Debugging information ----
message             : String index out of range: -1
cause-exception     : java.lang.StringIndexOutOfBoundsException
cause-message       : String index out of range: -1
class               : hudson.security.ProjectMatrixAuthorizationStrategy
required-type       : hudson.security.ProjectMatrixAuthorizationStrategy
converter-type      : hudson.util.XStream2$AssociatedConverterImpl
path                : /hudson/authorizationStrategy/denyAnonymousReadAccess
line number         : 14
-------------------------------
message             : String index out of range: -1 : String index out of range: -1
---- Debugging information ----
message             : String index out of range: -1
cause-exception     : java.lang.StringIndexOutOfBoundsException
cause-message       : String index out of range: -1
class               : hudson.security.ProjectMatrixAuthorizationStrategy
required-type       : hudson.security.ProjectMatrixAuthorizationStrategy
converter-type      : hudson.util.XStream2$AssociatedConverterImpl
path                : /hudson/authorizationStrategy/denyAnonymousReadAccess
line number         : 14
-------------------------------
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       : String index out of range: -1 : String index out of range: -1
class               : hudson.model.Hudson
required-type       : hudson.security.ProjectMatrixAuthorizationStrategy
converter-type      : hudson.util.RobustReflectionConverter
path                : /hudson/authorizationStrategy/denyAnonymousReadAccess
line number         : 14
version             : not available
-------------------------------
    at hudson.util.RobustReflectionConverter.doUnmarshal(RobustReflectionConverter.java:354)
    at hudson.util.RobustReflectionConverter.unmarshal(RobustReflectionConverter.java:268)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1189)
    at hudson.util.XStream2.unmarshal(XStream2.java:161)
    at hudson.util.XStream2.unmarshal(XStream2.java:132)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1173)
    at hudson.XmlFile.unmarshal(XmlFile.java:178)
Caused: java.io.IOException: Unable to read /var/jenkins_home/config.xml
    at hudson.XmlFile.unmarshal(XmlFile.java:181)
    at hudson.XmlFile.unmarshal(XmlFile.java:161)
    at jenkins.model.Jenkins.loadConfig(Jenkins.java:3078)
    at jenkins.model.Jenkins.access$1200(Jenkins.java:312)
    at jenkins.model.Jenkins$13.run(Jenkins.java:3180)
    at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
    at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
    at jenkins.model.Jenkins$5.runTask(Jenkins.java:1118)
    at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
    at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused: org.jvnet.hudson.reactor.ReactorException
    at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
    at jenkins.InitReactorRunner.run(InitReactorRunner.java:48)
    at jenkins.model.Jenkins.executeReactor(Jenkins.java:1152)
    at jenkins.model.Jenkins.<init>(Jenkins.java:959)
    at hudson.model.Hudson.<init>(Hudson.java:85)
    at hudson.model.Hudson.<init>(Hudson.java:81)
    at hudson.WebAppMain$3.run(WebAppMain.java:233)
Caused: hudson.util.HudsonFailedToLoad
    at hudson.WebAppMain$3.run(WebAppMain.java:250)

Our Config:

<hudson>
  <disabledAdministrativeMonitors>
    <string>OldData</string>
    <string>jenkins.security.s2m.MasterKillSwitchWarning</string>
    <string>jenkins.security.csrf.CSRFAdministrativeMonitor</string>
  </disabledAdministrativeMonitors>
  <version>2.190.2</version>
  <installStateName>DOWNGRADE</installStateName>
  <numExecutors>2</numExecutors>
  <mode>NORMAL</mode>
  <useSecurity>true</useSecurity>
  <authorizationStrategy class="hudson.security.ProjectMatrixAuthorizationStrategy">
    <denyAnonymousReadAccess>false</denyAnonymousReadAccess>
  </authorizationStrategy>
  <securityRealm class="hudson.security.HudsonPrivateSecurityRealm">
    <disableSignup>true</disableSignup>
    <enableCaptcha>false</enableCaptcha>
  </securityRealm>
  <disableRememberMe>false</disableRememberMe>
  <projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/>
  <workspaceDir>${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}</workspaceDir>
  <buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
  <markupFormatter class="hudson.markup.EscapedMarkupFormatter"/>
  <jdks/>
  <viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
  <myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
  <clouds/>
  <quietPeriod>5</quietPeriod>
  <scmCheckoutRetryCount>0</scmCheckoutRetryCount>
  <views>
  ...
  </views>                                                                                                              
  <primaryView>all</primaryView>                                                                                        
  <slaveAgentPort>50000</slaveAgentPort>                                                                                
  <label></label>                                                                                                       
  <nodeProperties/>                                                                                                     
  <globalNodeProperties/>                                                                                               
</hudson>

Upvotes: 0

Views: 2733

Answers (1)

BlackoutDev
BlackoutDev

Reputation: 107

If you are updating, then there could be a syntax error in config.xml. You can try to recover doing:

Stop jenkins

cmd> service jenkins stop

Move or make a copy of the file config.xml

cmd> mv Jenkins_Home/config.xml Jenkins_Home/config_copy.xml

Start Jenkins again

cmd> service jenkins start

Or it could be a problem with a git pluging if you have one, sometimes it can be fixed by changing git version to a older one.

Upvotes: 1

Related Questions