2

On a Windows 10 system, I can connect my Jenkins slave through the command line but not via Services.

jenkins-slave.err.log shows MalformedByteSequence: invalid byte 2 of 2-byte UTF-8 sequence
MalformedByteSequenceException explained why it happens (and saved me the headache of transcribing the traceback stack!), but not how to find where the problem is so that I can fix it.

In a browser, I entered http://my-jenkins-master:8080/computer/my_agent/slave-agent.jnlp
Got the dialog window You have chose to open slave-agent.jnlp with size 377 bytes
But when I select "Save File" -- nothing happens, and jenkins-slave.err.log shows Content is not allowed in prolog

Other agents can download their slave-agent.jnlp OK, so I don't know where the problem is so that I can fix it.

Will be glad to supply any other information you need.

TheBick
  • 341
  • 1
  • 5
  • 12
  • You don't really need to download `slave-agent.jnlp`. I recommend to install the service through the command-line using `jenkins-slave.exe`. It is not difficult, see [this tutorial](https://hayato-iriumi.net/2019/05/23/how-to-install-jenkins-slave-as-windows-service/). In addition it allows you to automate slave setup. – zett42 Feb 26 '20 at 20:26
  • The whole Jenkins thing had been already set up before I inherited. Somehow this one item got broken and I'd like to fix it. Where is the file (presumably on the Jenkins master) so I can fix it? – TheBick Feb 27 '20 at 01:02

1 Answers1

1

TL;DR

The error message comes from a wrong combination of the jnlpUrl and secret parameters. E.g. jnlpUrl from build-node-01 and secret from an other build-node.

Check your script where you connect the agent (build-node) to your jenkins.

java -jar agent.jar -jnlpUrl http://your-jenkins.com/computer/your-build-node-ABC/jenkins-agent.jnlp -secret <secret for your build node DEF>

Make sure the jnlpUrland secret are for the same agent.

Details

I encountered the same problem today, and in my case, it turned out to be a copy-and-paste error! On all our build-nodes we have startup script with this line

java -jar agent.jar -jnlpUrl http://my-jenkins.com/computer/my-build-node-01/jenkins-agent.jnlp -secret <secret for my-build-node-01>

I copied this startup script to the new build-node and only replaced the secret

java -jar agent.jar -jnlpUrl http://my-jenkins.com/computer/my-build-node-01/jenkins-agent.jnlp -secret <secret for my-build-node-02>

The URL was from build-node-01 and the secret was from build-node-02!

WRONG    java -jar agent.jar -jnlpUrl http://my-jenkins.com/computer/my-build-node-01/jenkins-agent.jnlp -secret <secret for my-build-node-02>
CORRECT  java -jar agent.jar -jnlpUrl http://my-jenkins.com/computer/my-build-node-02/jenkins-agent.jnlp -secret <secret for my-build-node-02>

The error message

This was the whole error message if you mess up the jnlpUrl and the secret

[Fatal Error] :1:1: Invalid byte 2 of 2-byte UTF-8 sequence.
Exception in thread "main" org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Invalid byte 2 of 2-byte UTF-8 sequence.
        at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:263)
        at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:342)
        at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:122)
        at hudson.remoting.Launcher.loadDom(Launcher.java:604)
        at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:546)
        at hudson.remoting.Launcher.run(Launcher.java:346)
        at hudson.remoting.Launcher.main(Launcher.java:297)
Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence.
        at java.xml/com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:702)
        at java.xml/com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:373)
        at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1913)
        at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(XMLEntityScanner.java:1779)
        at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(XMLEntityScanner.java:1817)
        at java.xml/com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:158)
        at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:861)
        at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
        at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
        at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:247)
        ... 6 more
harry
  • 672
  • 3
  • 13