Splunk Dev

Connecting to Splunk via Java SDK, why am I getting error "java.lang.IllegalArgumentException: URI can't be null."

thewho123
Explorer

I am trying to connect to Splunk using the Java SDK. I created a new project in Java using Maven and have the following code provided by Splunk.

ServiceArgs loginArgs = new
ServiceArgs();
loginArgs.setUsername("username");
loginArgs.setPassword("password");
loginArgs.setHost("hostname");
loginArgs.setPort(8089);

Service service = Service.connect(loginArgs);

When I run this, I get "java.lang.IllegalArgumentException: URI can't be null."

What am I supposed to use for the hostname? Most examples show hostname as localhost.

I normally access Splunk using a url "mycompany.splunkcloud.com" and enter my credentials.

Tags (4)
0 Karma

steelecomp99
Explorer

Hi thewho123,

I had the same problem recently. The issue turned out to be a default setting when running Java 1.8. I'm linking to the resolution here: https://answers.splunk.com/answers/463594/severe-uri-cant-be-null.html

You have to explicitly set the SslSecurityProtocol before calling Service.connect:

 HttpService.setSslSecurityProtocol( SSLSecurityProtocol.TLSv1_2 );

Hope this helps

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...