Splunk Dev

Getting XML parsing error while connecting to Splunk via java SDK.

chitranjan155
New Member

Hi
PFB code

HttpService.setSslSecurityProtocol( SSLSecurityProtocol.TLSv1_2 );

     ServiceArgs serviceArgs = new ServiceArgs();
     serviceArgs.setHost("mycompanyserver.com");
     serviceArgs.setPort(8089);
     serviceArgs.setUsername("myuser");
     serviceArgs.setPassword("mypasword");


     // Create a Service instance and log in with the argument map
     Service service = Service.connect(serviceArgs);  // throwing error here 

     System.out.println(service.getToken().toString());
     for (Application app : service.getApplications().values()) {
         System.out.println(app.getName());
     }

PFB the error

[Fatal Error] :1:3: The markup in the document preceding the root element must be well-formed.
Exception in thread "main" java.lang.RuntimeException: The markup in the document preceding the root element must be well-formed.
at com.splunk.Xml.parse(Xml.java:63)
at com.splunk.Xml.parse(Xml.java:40)
at com.splunk.Service.login(Service.java:1125)
at com.splunk.Service.login(Service.java:1103)
at com.splunk.Service.connect(Service.java:189)
Labels (2)
0 Karma
Get Updates on the Splunk Community!

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...