Skip to content

[BUG] Required dependency missing: org.json:json #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
johan-afm opened this issue May 14, 2025 · 0 comments
Open
1 task done

[BUG] Required dependency missing: org.json:json #568

johan-afm opened this issue May 14, 2025 · 0 comments
Labels

Comments

@johan-afm
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

SDK Version

<dependency>
  <groupId>com.optimizely.ab</groupId>
  <artifactId>core-api</artifactId>
  <version>4.1.1</version>
</dependency>

Current Behavior

Using JsonConfigParser leads to runtime exception, because it requires org.json.JsonObject from org.json:json which is not provided as an implementation dependency.

JsonConfigParser https://github.com/optimizely/java-sdk/blob/master/core-api/src/main/java/com/optimizely/ab/config/parser/JsonConfigParser.java

Dependency excluded here: https://github.com/optimizely/java-sdk/blob/master/core-api/build.gradle#L11

Expected Behavior

Users of your library should be able to use JsonConfigParser without knowing about its internal dependencies.

Steps To Reproduce

Create a Project with
pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>repro</artifactId>
    <groupId>repro</groupId>
    <version>1.0.0</version>


    <dependencies>
        <dependency>
            <groupId>com.optimizely.ab</groupId>
            <artifactId>core-api</artifactId>
            <version>4.1.1</version>
        </dependency>
    </dependencies>
</project>

and settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
          https://maven.apache.org/xsd/settings-1.0.0.xsd">

</settings>

and src/main/java/Main.java

import com.optimizely.ab.config.parser.ConfigParseException;
import com.optimizely.ab.config.parser.JsonConfigParser;

public class Main {

    public static void main(String[] args) {

        System.out.println("Hello, World!");

        JsonConfigParser parser = new JsonConfigParser();
        try {
            parser.parseProjectConfig("{}");
        } catch (ConfigParseException e) {
            e.printStackTrace();
        }
    }
}

% mvn clean compile
% mvn exec:java -Dexec.mainClass=Main

Java Version

% mvn -version
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /usr/local/Cellar/maven/3.9.9/libexec
Java version: 11.0.22, vendor: Amazon.com Inc.

Link

No response

Logs

No response

Severity

No response

Workaround/Solution

Solution
Change https://github.com/optimizely/java-sdk/blob/master/core-api/build.gradle#L11
from compileOnly to implementation

Alternatively, do not expose JsonConfigParser to consumers of your library.

Recent Change

No response

Conflicts

No response

@johan-afm johan-afm added the bug label May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant