0

I am trying to get the Java session example for Snowflake to work as described in the developer guide, but have not had success. Expected behavior is that a session is created and the contents of the INFORMATION_SCHEMA.TABLES table is output to the terminal. The code from the developer documentation is as follows:

import com.snowflake.snowpark_java.*;
import java.util.HashMap;
import java.util.Map;

public class snowpark {
    public static void main(String[] args) {
        Map<String, String> properties = new HashMap<>();
        properties.put("URL", "https://**********");
        properties.put("USER", "JOHN");
        properties.put("PASSWORD", "********");
        properties.put("ROLE", "DBA_CITIBIKE");
        properties.put("WAREHOUSE", "LOAD_WH");
        properties.put("DB", "CITIBIKE");
        properties.put("SCHEMA", "DEMO");
        SessionBuilder builder = Session.builder();
        Session session = Session.builder().configs(properties).create();

I have modified the code to include attributes that are relevant to my environment. This code compiles just fine. However, when I run it I am presented with the following error:

RonaldCoeJrsMBP:_Dev ron$ java snowpark
Exception in thread "main" java.lang.NoClassDefFoundError: scala/Option
        at com.snowflake.snowpark_java.SessionBuilder.<init>(SessionBuilder.java:17)
        at com.snowflake.snowpark_java.Session.builder(Session.java:52)
        at snowpark.main(snowpark.java:15)
Caused by: java.lang.ClassNotFoundException: scala.Option
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 3 more

I have tried installing Scala and including its location in my path--one thing to note here is that there is no such file on my system called scala-library.jar. I have successfully executed the developer example that is written in Python.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • The reply likely depends heavily on how you are producing the runnable artifact. What build system are you using (if any)? – stefanobaghino Jul 21 '22 at 11:37
  • The Snowflake docs offer some nice documentation about how to set up your development environment that will probably be useful: https://docs.snowflake.com/en/developer-guide/snowpark/java/setup-other-environments.html – stefanobaghino Jul 21 '22 at 11:47
  • I am not using a build system. Compiling with javac from the command line and running the class with the java executable. Turns out that the `scala-library` is in the `lib` folder included with the snowpark API, but it is named with its version suffixed. Had previously been testing this on Mac OS. Now adding a Fedora Linux machine to the evaluation set. – Ronald Coe Jr. Jul 21 '22 at 12:41
  • In case you end up working with Scala libraries again, consider that their artifacts always include the Scala compiler version with which they were compiled (in your case probably something like `_2.12`). – stefanobaghino Jul 21 '22 at 13:29

0 Answers0