question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Basic usage throws org.json.JSONException

See original GitHub issue

Probably something I’m overlooking but running the most basic example fails for me:

jenkins@5e3eb1c93a51:~$ java -jar jenkins-plugin-manager-1.1.2.jar --war /usr/share/jenkins/jenkins.war --plugin-file /var/jenkins_home/plugins.txt --verbose
File containing list of plugins to be downloaded: /var/jenkins_home/plugins.txt
Reading in plugins from /var/jenkins_home/plugins.txt

No directory to download plugins entered. Will use default of /usr/share/jenkins/ref/plugins
Using update center https://updates.jenkins.io from JENKINS_UC environment variable
Using experimental update center https://updates.jenkins.io/experimental from JENKINS_UC_EXPERIMENTAL environment variable
Using incrementals mirror https://repo.jenkins-ci.org/incrementals from JENKINS_INCREMENTALS_REPO_MIRROR environment variable
No CLI option or environment variable set for plugin info, using default of https://updates.jenkins.io/current/plugin-versions.json
Will use war file: /usr/share/jenkins/jenkins.war
Jenkins version: 2.235.1
No version specific update center for Jenkins version 2.235.1

Retrieving update center information
org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
	at org.json.JSONTokener.syntaxError(JSONTokener.java:505)
	at org.json.JSONObject.<init>(JSONObject.java:215)
	at org.json.JSONObject.<init>(JSONObject.java:399)
	at io.jenkins.tools.pluginmanager.impl.CacheManager.retrieveFromCache(CacheManager.java:73)
	at io.jenkins.tools.pluginmanager.impl.PluginManager.getJson(PluginManager.java:561)
	at io.jenkins.tools.pluginmanager.impl.PluginManager.getUCJson(PluginManager.java:591)
	at io.jenkins.tools.pluginmanager.impl.PluginManager.start(PluginManager.java:141)
	at io.jenkins.tools.pluginmanager.impl.PluginManager.start(PluginManager.java:112)
	at io.jenkins.tools.pluginmanager.cli.Main.main(Main.java:37)
A JSONObject text must begin with '{' at 1 [character 2 line 1]

I’m running this command from inside a docker container using the jenkins/jenkins:2.235.1 image.

Plugin file:

blueocean:1.23.2
configuration-as-code:1.41
gitlab-plugin:1.5.13
ssh-credentials:1.18.1
job-dsl:1.77

What I am doing wrong here?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
wokingercommented, Jul 14, 2020

+1 same here.

~ $ java -jar ./jenkins-plugin-manager-1.1.2.jar    --plugin-file ./pluginfile.txt --verbose
File containing list of plugins to be downloaded: ./pluginfile.txt
Reading in plugins from ./pluginfile.txt

No directory to download plugins entered. Will use default of /usr/share/jenkins/ref/plugins
Using update center https://updates.jenkins.io from JENKINS_UC environment variable
Using experimental update center https://updates.jenkins.io/experimental from JENKINS_UC_EXPERIMENTAL environment variable
Using incrementals mirror https://repo.jenkins-ci.org/incrementals from JENKINS_INCREMENTALS_REPO_MIRROR environment variable
No CLI option or environment variable set for plugin info, using default of https://updates.jenkins.io/current/plugin-versions.json
No war entered. Will use default of /usr/share/jenkins/jenkins.war
Jenkins version: 2.235.1
No version specific update center for Jenkins version 2.235.1

Retrieving update center information
Returning cached value for: update-center
org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
        at org.json.JSONTokener.syntaxError(JSONTokener.java:505)
        at org.json.JSONObject.<init>(JSONObject.java:215)
        at org.json.JSONObject.<init>(JSONObject.java:399)
        at io.jenkins.tools.pluginmanager.impl.CacheManager.retrieveFromCache(CacheManager.java:73)
        at io.jenkins.tools.pluginmanager.impl.PluginManager.getJson(PluginManager.java:561)
        at io.jenkins.tools.pluginmanager.impl.PluginManager.getUCJson(PluginManager.java:593)
        at io.jenkins.tools.pluginmanager.impl.PluginManager.start(PluginManager.java:141)
        at io.jenkins.tools.pluginmanager.impl.PluginManager.start(PluginManager.java:112)
        at io.jenkins.tools.pluginmanager.cli.Main.main(Main.java:37)
A JSONObject text must begin with '{' at 1 [character 2 line 1]

looks like the json files

in my case a workaround was to point the command to these versions of the json files:

Here is my command with the adapted json files

java -jar ./jenkins-plugin-manager-1.1.2.jar    --plugin-file ./pluginfile.txt --verbose --jenkins-update-center https://updates.jenkins.io/current/update-center
.actual.json --jenkins-experimental-update-center https://updates.jenkins.io/experimental/update-center.actual.json
Read more comments on GitHub >

github_iconTop Results From Across the Web

Org.Json - JSONException Handling - Tutorialspoint
Utility classes of org.json throws JSONException in case of invalid JSON. Following example shows how to handle JSONException.
Read more >
unhandled exception org.json.jsonexception - Stack Overflow
Re this exception message: org.json.JSONException: Value A of type java.lang.String cannot be converted to JSONObject. I assume it is thrown by this line:...
Read more >
org.json.JSONException java code examples - Tabnine
The JSONException is thrown by the JSON.org classes when things are amiss. Most used methods. printStackTrace · getMessage · <init>. Constructs a new ......
Read more >
Uses of Class org.json.JSONException - javadoc.io
Uses of JSONException in org. json. The JSONPointerException is thrown by JSONPointer if an error occurs during evaluating a pointer.
Read more >
Use org.openqa.selenium.json.JsonException in JUnit With ...
It is an example code of JsonException which has been thrown by selenium client if the response data is not in Json format....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found