<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to resolve error &amp;quot;java.lang.IllegalArgumentException: URI can't be null&amp;quot; when testing HTTP Event Collector from a Java client? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-resolve-error-quot-java-lang-IllegalArgumentException-URI/m-p/214014#M42064</link>
    <description>&lt;P&gt;Bit ridiculous that following the provided example does not work isn't it? &lt;/P&gt;</description>
    <pubDate>Fri, 20 Jan 2017 08:42:28 GMT</pubDate>
    <dc:creator>ordiel</dc:creator>
    <dc:date>2017-01-20T08:42:28Z</dc:date>
    <item>
      <title>How to resolve error "java.lang.IllegalArgumentException: URI can't be null" when testing HTTP Event Collector from a Java client?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-resolve-error-quot-java-lang-IllegalArgumentException-URI/m-p/214013#M42063</link>
      <description>&lt;P&gt;I am trying to test the HTTP Event Collector from a java client, referred the Java project from splunk.com. Please help to resolve the issue.&lt;BR /&gt;
We use cookie for the authorization . Thanks SG&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        serviceArgs.setHost("https://test2751.md4.abc.com");
        serviceArgs.setCookie("credential=cookie value");
        serviceArgs.setPort(8088);
        serviceArgs.setScheme("https");
        serviceArgs.setToken("0B999603-81C7-4930-abcd-639825CE66E6");
        serviceArgs.setSSLSecurityProtocol(SSLSecurityProtocol.TLSv1_2); // TLSv1 didn't work.

      service = Service.connect(serviceArgs);
      service.login();
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Below is the exception trace:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;java.lang.IllegalArgumentException: URI can't be null.
    at sun.net.spi.DefaultProxySelector.select(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
    at com.splunk.HttpService.send(HttpService.java:403)
    at com.splunk.Service.send(Service.java:1293)
    at com.splunk.HttpService.post(HttpService.java:308)
    at com.abc.splunk.logging.test.TestUtil.enableHttpEventCollector(TestUtil.java:197)
    at com.abc.splunk.logging.test.HttpEventCollector_Log4j2Test.canSendEventUsingLog4j2(HttpEventCollector_Log4j2Test.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Nov 2016 21:37:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-resolve-error-quot-java-lang-IllegalArgumentException-URI/m-p/214013#M42063</guid>
      <dc:creator>SGADE</dc:creator>
      <dc:date>2016-11-07T21:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve error "java.lang.IllegalArgumentException: URI can't be null" when testing HTTP Event Collector from a Java client?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-resolve-error-quot-java-lang-IllegalArgumentException-URI/m-p/214014#M42064</link>
      <description>&lt;P&gt;Bit ridiculous that following the provided example does not work isn't it? &lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 08:42:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-resolve-error-quot-java-lang-IllegalArgumentException-URI/m-p/214014#M42064</guid>
      <dc:creator>ordiel</dc:creator>
      <dc:date>2017-01-20T08:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve error "java.lang.IllegalArgumentException: URI can't be null" when testing HTTP Event Collector from a Java client?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-resolve-error-quot-java-lang-IllegalArgumentException-URI/m-p/214015#M42065</link>
      <description>&lt;P&gt;Did you resolve this? I am having the same problem...&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 20:19:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-resolve-error-quot-java-lang-IllegalArgumentException-URI/m-p/214015#M42065</guid>
      <dc:creator>jantona</dc:creator>
      <dc:date>2017-05-10T20:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve error "java.lang.IllegalArgumentException: URI can't be null" when testing HTTP Event Collector from a Java client?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-resolve-error-quot-java-lang-IllegalArgumentException-URI/m-p/214016#M42066</link>
      <description>&lt;P&gt;FU**&lt;EM&gt;#$(&lt;/EM&gt;@#)#(@)(# The WORST API EVER&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 05:53:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-resolve-error-quot-java-lang-IllegalArgumentException-URI/m-p/214016#M42066</guid>
      <dc:creator>marcellodesales</dc:creator>
      <dc:date>2017-08-10T05:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve error "java.lang.IllegalArgumentException: URI can't be null" when testing HTTP Event Collector from a Java client?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-resolve-error-quot-java-lang-IllegalArgumentException-URI/m-p/214017#M42067</link>
      <description>&lt;P&gt;I was able to work-around these issues by effectively embedding the REST API with CURL into Java like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;public String curlConnect() throws Exception {
        String r = null;
        try {
            List&amp;lt;String&amp;gt; theCommand = new ArrayList&amp;lt;String&amp;gt;();
            theCommand.add("curl");
            theCommand.add("-sk");
            theCommand.add(this.surl + "/services/auth/login?output_mode=json");
            logger.debug(this.surl+ "/services/auth/login?output_mode=json");
            logger.debug("-d username=" + this.user + " password=XXXXXX");
            theCommand.add("-d");
            theCommand.add("username=" + this.user);
            theCommand.add("-d");
            theCommand.add("password=" + this.token);

            ProcessBuilder pb = new ProcessBuilder(theCommand);

            pb.directory(new File(System.getProperty("input.file.path")));
            pb.redirectErrorStream(true);
            Process p = pb.start();
            InputStream is = p.getInputStream();

            r = IOUtils.toString(is);
            r = r.substring(r.indexOf("{\"sessionKey\":\""), r.length());
            JSONObject jsonResponse = new JSONObject(r);
            this.sessionKey = jsonResponse.getString("sessionKey");
            r = this.sessionKey;
            logger.debug(r);

        } catch ( Exception e ) {
            logger.error(this.surl);
            logger.error(e.getMessage());
            throw e;
        }
        return r;
    }

    public String query(String splunkQuery) throws Exception {
        String r = null;
        try {
            List&amp;lt;String&amp;gt; theCommand = new ArrayList&amp;lt;String&amp;gt;();
            theCommand.add("curl");
            theCommand.add("-sku");
            theCommand.add(this.user+":"+this.token);
            //theCommand.add("-H");
            //theCommand.add("\"Authorization: Splunk " + this.sessionKey + "\"");
            theCommand.add(this.surl + "/services/search/jobs?output_mode=json");
            logger.debug(this.surl+ "/services/search/jobs?output_mode=json");
            theCommand.add("-d");
            theCommand.add("search=" + URLEncoder.encode(splunkQuery, "UTF-8"));
            logger.info("search=" + URLEncoder.encode(splunkQuery, "UTF-8"));
            //theCommand.add("-d");
            //theCommand.add("output_mode=json");

            ProcessBuilder pb = new ProcessBuilder(theCommand);

            pb.directory(new File(System.getProperty("input.file.path")));
            pb.redirectErrorStream(true);
            Process p = pb.start();
            InputStream is = p.getInputStream();

            String theResult = IOUtils.toString(is);
            logger.info(theResult);

            theResult = theResult.substring(theResult.indexOf("{\"sid\":\""), theResult.length());
            JSONObject jsonResponse = new JSONObject(theResult);
            r = jsonResponse.getString("sid");

            while ( !resultsReady(r)) {
                logger.info("waiting 30 seconds for async report to finish running sid " + r);
                java.util.concurrent.TimeUnit.SECONDS.sleep(30);
            }
        } catch ( Exception e) {
            logger.error(this.surl);
            logger.error(e.getMessage());
            throw e;
        }
        return r;
    }
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Aug 2017 11:32:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-resolve-error-quot-java-lang-IllegalArgumentException-URI/m-p/214017#M42067</guid>
      <dc:creator>jantona</dc:creator>
      <dc:date>2017-08-10T11:32:08Z</dc:date>
    </item>
  </channel>
</rss>

