I'm trying to connect to an OLAP Cube using Olap4J. I'm using jdk14
and olap4j-1.0.0.445.jar
. I know the IP address of the server and the Catalog. But I'm unable to connect. The following exception seems to be the biggest problem:
Server returned HTTP response code: 401 for URL: http://xx.xx.xx.xxx/olap/msmdpump.dll
Am I missing some kind of authentication information in my request or am I missing something more fundamental?
Connection:
try {
Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
OlapConnection con;
try {
con = (OlapConnection) DriverManager.getConnection("jdbc:xmla:Server=http://xx.xx.xx.xxx/olap/msmdpump.dll;Catalog=xxx");
OlapWrapper wrapper = con;
OlapConnection olapConnection = wrapper.unwrap(OlapConnection.class);
OlapStatement stmt = olapConnection.createStatement();
olapConnection.setCatalog("Analysis Services Tutorial");
stmt.executeOlapQuery("SELECT {[Customer].[City]} ON Rows FROM [Internet Sales] ");
} catch (SQLException e) {
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Exception:
"C:\Program Files\Java\jdk1.8.0_121\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:55443,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_121\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\rt.jar;C:\Users\name\Documents\project directory\Olap4JTest\target\classes;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\xercesImpl.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\asm.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\asm-commons.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\asm-tree.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\javacup.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\olap4j-1.0.0.445.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\olap4j-jdk14-1.0.0.445.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\olap4j-tck-1.0.0.445.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\olap4j-xmla-1.0.0.445.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\retroweaver.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\retroweaver-rt.jar;C:\Users\name\.m2\repository\backport-util-concurrent\backport-util-concurrent-java12\3.1\backport-util-concurrent-java12-3.1.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3.4\lib\idea_rt.jar" main.Main
Connected to the target VM, address: '127.0.0.1:55443', transport: 'socket'
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
/C:/Users/name/Documents/project%20directory/Olap4JTest/target/classes/main/static/scene.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at main.Main.start(Main.java:13)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Caused by: java.lang.RuntimeException: org.olap4j.OlapException: This connection encountered an exception while executing a query.
at org.olap4j.driver.xmla.DeferredNamedListImpl.getList(DeferredNamedListImpl.java:75)
at org.olap4j.driver.xmla.DeferredNamedListImpl.size(DeferredNamedListImpl.java:89)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.getOlapDatabase(XmlaOlap4jConnection.java:365)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.getOlapCatalogs(XmlaOlap4jConnection.java:441)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.setCatalog(XmlaOlap4jConnection.java:397)
at main.MainController.initialize(MainController.java:30)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
... 17 more
Caused by: org.olap4j.OlapException: This connection encountered an exception while executing a query.
at org.olap4j.driver.xmla.XmlaHelper.createException(XmlaHelper.java:35)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.executeMetadataRequest(XmlaOlap4jConnection.java:735)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.populateList(XmlaOlap4jConnection.java:708)
at org.olap4j.driver.xmla.DeferredNamedListImpl.populateList(DeferredNamedListImpl.java:101)
at org.olap4j.driver.xmla.DeferredNamedListImpl.getList(DeferredNamedListImpl.java:69)
... 23 more
Caused by: org.olap4j.driver.xmla.proxy.XmlaOlap4jProxyException: This proxy encountered an exception while processing the query.
at org.olap4j.driver.xmla.proxy.XmlaOlap4jHttpProxy.getResponse(XmlaOlap4jHttpProxy.java:158)
at org.olap4j.driver.xmla.proxy.XmlaOlap4jAbstractHttpProxy.get(XmlaOlap4jAbstractHttpProxy.java:176)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.executeMetadataRequest(XmlaOlap4jConnection.java:733)
... 26 more
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://10.96.10.243/olap/msmdpump.dll
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at org.olap4j.driver.xmla.proxy.XmlaOlap4jHttpProxy.getResponse(XmlaOlap4jHttpProxy.java:121)
... 28 more
Disconnected from the target VM, address: '127.0.0.1:55443', transport: 'socket'
Exception running application main.Main
Process finished with exit code 1
I had the same problem as yours. I wanted to connect to my OLAP cube, which was hosted in localhost.
I've noticed that when I send GET request to http://192.168.0.151/OLAP/msmdpump.dll in my browser I need to enter username and password. I thought that probably my driver didn't have an access to this resource. Aha! I was right ;)
So I guess the simplest solution is as follows: try to set anonymous IIS authentication. I know it isn't the best option but it works when you just want to get started with OLAP.
My working connection string:
Connection connection = DriverManager.getConnection(
"jdbc:xmla: Server=http://192.168.0.151/OLAP/msmdpump.dll;" +
"Data Source=http://192.168.0.151/OLAP/msmdpump.dll;" +
"Initial Catalog=AdventureWorksDW2014; " +
"Integrated Security=Basic; " +
"User ID=XXX; " +
"Password=XXX;");
User ID - it's a db username Password - it's a db username's password
One tip more - I suspect that your olap query it isn't a right mdx query so probably you will get OlapException.
Good luck!