Skip to content
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

Add dependencies to top-level project #436

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kneth
Copy link
Contributor

@kneth kneth commented Nov 11, 2024

Summary of the changes / Why this is an improvement

I am building the driver from current HEAD of master with the command:

./gradlew publishJdbcStandalonePublicationToMavenLocal

All tests pass when running the command

CRATE_URL=https://cdn2.crate.io/downloads/releases/cratedb/x64_mac/crate-5.9.0.tar.gz ./gradlew test

In a simple application, I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: io/crate/shade/com/fasterxml/jackson/core/JsonProcessingException

The simple application's build.gradle is:

plugins {
    // Apply the application plugin to add support for building a CLI application in Java.
    id 'application'
}

repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()
    mavenLocal()
}

dependencies {
    // Use JUnit Jupiter for testing.
    testImplementation libs.junit.jupiter

    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

    // This dependency is used by the application.
    implementation libs.guava
    implementation files('../../../Projects/crate-jdbc/build/libs/crate-jdbc-standalone-2.7.0-f2f040a.jar')
}

// Apply a specific Java toolchain to ease working on different environments.
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(11)
    }
}

application {
    // Define the main class for the application.
    mainClass = 'cratejdbcexperiments.App'
}

tasks.named('test') {
    // Use JUnit Platform for unit tests.
    useJUnitPlatform()
}

and the application is:

package cratejdbcexperiments;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;

public class App {
    public static void main(String[] args) {
        Properties connectionProps = new Properties();
        connectionProps.put("user", "crate");
        connectionProps.put("tcpKeepAlive", true);

        try {
            System.out.println("Initializing");
            Connection conn = DriverManager.getConnection("jdbc:crate://localhost:5432/", connectionProps);
            PreparedStatement stmt = conn.prepareStatement("SELECT * FROM iris");
            System.out.println("Query");
            ResultSet results = stmt.executeQuery();
            long size = 0;
            while (results.next()) {
                size++;
            }
            System.out.println("Length: " + size);
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
        System.out.println("Done");
    }
}

By adding the dependencies to the top-level build.gradle, the app is able to run.

Checklist

  • Link to issue this PR refers to (if applicable): Fixes #???

@cla-bot cla-bot bot added the cla-signed label Nov 11, 2024
@kneth kneth requested review from seut and amotl November 11, 2024 16:21
@kneth kneth self-assigned this Nov 11, 2024
Copy link
Member

@seut seut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot reproduce this issue. The crate-jdbc-standalone JAR 2.7.0 released at https://repo1.maven.org/maven2/io/crate/crate-jdbc-standalone/2.7.0/ does contain the mentioned JsonProcessingException.class (and all others of jackson-core).

How did you encounter this issue, could you please add reproducible steps?

@kneth
Copy link
Contributor Author

kneth commented Nov 12, 2024

@seut I have updated the description to capture all the details. If I use crate-jdbc-standalone 2.7.0, my simple application works fine.

@amotl amotl removed their request for review December 9, 2024 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants